A.OrdMap.new
You're seeing just the function
new
, go back to A.OrdMap module for more information.
Specs
new() :: t()
Returns a new empty ordered map.
Examples
iex> A.OrdMap.new()
ord(%{})
Specs
new(Enumerable.t()) :: t(key(), value())
Creates an ordered map from an enumerable
.
Preserves the original order of keys. Duplicated keys are removed; the latest one prevails.
Examples
iex> A.OrdMap.new(b: "Bat", a: "Ant", c: "Cat")
ord(%{b: "Bat", a: "Ant", c: "Cat"})
iex> A.OrdMap.new(b: "Bat", a: "Ant", b: "Buffalo", a: "Antelope")
ord(%{b: "Buffalo", a: "Antelope"})
new/1
will return dense ord maps untouched, but will rebuild sparse ord maps from scratch.
This can be used to build a dense ord map from from a sparse one.
See the section about sparse structures for more information.
iex> sparse = A.OrdMap.new(c: "Cat", a: "Ant", b: "Bat") |> A.OrdMap.delete(:c)
#A.OrdMap<%{a: "Ant", b: "Bat"}, sparse?: true>
iex> A.OrdMap.new(sparse)
ord(%{a: "Ant", b: "Bat"})
Specs
new(Enumerable.t(), (term() -> {k, v})) :: t(k, v) when k: key(), v: value()
Creates an ordered map from an enumerable
via the given transform
function.
Preserves the original order of keys. Duplicated keys are removed; the latest one prevails.
Examples
iex> A.OrdMap.new([:a, :b], fn x -> {x, x} end)
ord(%{a: :a, b: :b})