ec_dictionary

A module that supports association of keys to values.

A module that supports association of keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

This interface is a member of the Erlware Commons Library.

DATA TYPES

dictionary(_K, _V) = #dict_t{}
key(T) = T
value(T) = T

Functions


behaviour_info(Other::atom()) -> [{atom(), arity()}] | undefined

new(ModuleName::module()) -> dictionary(_K, _V)

create a new dictionary object from the specified module. The module should implement the dictionary behaviour.

has_key(Key::key(K), Dict_t::dictionary(K, _V)) -> boolean()

check to see if the dictionary provided has the specified key.

get(Key::key(K), Dict_t::dictionary(K, V)) -> value(V)

given a key return that key from the dictionary. If the key is not found throw a 'not_found' exception.

get(Key::key(K), Default::value(V), Dict_t::dictionary(K, V)) -> value(V)

given a key return that key from the dictionary. If the key is not found then the default value is returned.

add(Key::key(K), Value::value(V), Dict_t::dictionary(K, V)) -> dictionary(K, V)

add a new value to the existing dictionary. Return a new dictionary containing the value.

remove(Key::key(K), Dict_t::dictionary(K, V)) -> dictionary(K, V)

Remove a value from the dictionary returning a new dictionary with the value removed.

has_value(Value::value(V), Dict_t::dictionary(_K, V)) -> boolean()

Check to see if the value exists in the dictionary

size(Dict_t::dictionary(_K, _V)) -> integer()

return the current number of key value pairs in the dictionary

to_list(Dict::dictionary(K, V)) -> [{key(K), value(V)}]

Return the contents of this dictionary as a list of key value pairs.

from_list(ModuleName::module(), List::[{key(K), value(V)}]) -> dictionary(K, V)

Create a new dictionary, of the specified implementation using the list provided as the starting contents.

keys(Dict::dictionary(K, _V)) -> [key(K)]

Return the keys of this dictionary as a list

Eric Merritt ericbmerritt@gmail.com
View Functions