Elixir v1.1.0 Map

A Dict implementation that works on maps.

Maps are key-value stores where keys are compared using the match operator (===). Maps can be created with the %{} special form defined in the Kernel.SpecialForms module.

For more information about the functions in this module and their APIs, please consult the Dict module.

Summary

Functions

Callback implementation for Dict.delete/2

Callback implementation for Dict.drop/2

Callback implementation for Dict.equal?/2

Callback implementation for Dict.fetch/2

Callback implementation for Dict.fetch!/2

Converts a struct to map

Callback implementation for Dict.get/3

Gets a value and updates a map in one operation

Gets a value and updates a map only if the key exists in one operation

Callback implementation for Dict.get_lazy/3

Callback implementation for Dict.has_key?/2

Callback implementation for Dict.keys/1

Callback implementation for Dict.merge/2

Returns a new empty map

Callback implementation for Dict.pop/3

Callback implementation for Dict.pop_lazy/3

Callback implementation for Dict.put/3

Callback implementation for Dict.put_new/3

Callback implementation for Dict.size/1

Callback implementation for Dict.split/2

Callback implementation for Dict.take/2

Callback implementation for Dict.to_list/1

Callback implementation for Dict.update/4

Updates the value in the map with the given function

Callback implementation for Dict.values/1

Functions

delete(map, key)

Callback implementation for Dict.delete/2.

drop(dict, keys)

Callback implementation for Dict.drop/2.

equal?(dict1, dict2)

Callback implementation for Dict.equal?/2.

fetch(map, key)

Callback implementation for Dict.fetch/2.

fetch!(dict, key)

Callback implementation for Dict.fetch!/2.

from_struct(struct)

Converts a struct to map.

It accepts the struct module or a struct itself and simply removes the __struct__ field from the struct.

Example

defmodule User do
  defstruct [:name]
end

Map.from_struct(User)
#=> %{name: nil}

Map.from_struct(%User{name: "john"})
#=> %{name: "john"}
get(dict, key, default \\ nil)

Callback implementation for Dict.get/3.

get_and_update(dict, key, fun)

Gets a value and updates a map in one operation.

get_and_update!(map, key, fun)

Gets a value and updates a map only if the key exists in one operation.

get_lazy(dict, key, fun)

Callback implementation for Dict.get_lazy/3.

has_key?(dict, key)

Callback implementation for Dict.has_key?/2.

keys(dict)

Callback implementation for Dict.keys/1.

merge(map1, map2)

Callback implementation for Dict.merge/2.

merge(dict1, dict2, fun \\ fn _k, _v1, v2 -> v2 end)

Callback implementation for Dict.merge/3.

new()

Returns a new empty map.

pop(dict, key, default \\ nil)

Callback implementation for Dict.pop/3.

pop_lazy(dict, key, fun)

Callback implementation for Dict.pop_lazy/3.

put(map, key, val)

Callback implementation for Dict.put/3.

put_new(dict, key, value)

Callback implementation for Dict.put_new/3.

put_new_lazy(dict, key, fun)

Callback implementation for Dict.put_new_lazy/3.

size(map)

Callback implementation for Dict.size/1.

split(dict, keys)

Callback implementation for Dict.split/2.

take(dict, keys)

Callback implementation for Dict.take/2.

to_list(dict)

Callback implementation for Dict.to_list/1.

update(dict, key, initial, fun)

Callback implementation for Dict.update/4.

update!(dict, key, fun)

Updates the value in the map with the given function.

values(dict)

Callback implementation for Dict.values/1.