Copyright © 2011 Erlware, LLC.
This module defines the ec_dictionary behaviour.
Required callback functions: new/0, has_key/2, get/2, add/3, remove/2, has_value/2, size/1, to_list/1, from_list/1, keys/1.
Authors: Eric Merritt (ericbmerritt@gmail.com).
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.dictionary(_K, _V) = #dict_t{}
key(T) = T
value(T) = T
add/3 | add a new value to the existing dictionary. |
behaviour_info/1 | |
from_list/2 | Create a new dictionary, of the specified implementation using the list provided as the starting contents. |
get/2 | given a key return that key from the dictionary. |
get/3 | given a key return that key from the dictionary. |
has_key/2 | check to see if the dictionary provided has the specified key. |
has_value/2 | Check to see if the value exists in the dictionary. |
keys/1 | Return the keys of this dictionary as a list. |
new/1 | create a new dictionary object from the specified module. |
remove/2 | Remove a value from the dictionary returning a new dictionary with the value removed. |
size/1 | return the current number of key value pairs in the dictionary. |
to_list/1 | Return the contents of this dictionary as a list of key value pairs. |
add(Key::key(K), Value::value(V), Dict_t::dictionary(K, V)) -> dictionary(K, V)
Key: the key to add
Value: the value to add
add a new value to the existing dictionary. Return a new dictionary containing the value.
behaviour_info(Other::atom()) -> [{atom(), arity()}] | undefined
from_list(ModuleName::module(), List::[{key(K), value(V)}]) -> dictionary(K, V)
ModuleName: the type to create the dictionary from
List: The list of key value pairs to start with
Create a new dictionary, of the specified implementation using the list provided as the starting contents.
get(Key::key(K), Dict_t::dictionary(K, V)) -> value(V)
Key: The key requested
when the key does not exist @throws not_found
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)
Key: The key requested
Default: The value that will be returned if no value is found
in the database.
given a key return that key from the dictionary. If the key is not found then the default value is returned.
has_key(Key::key(K), Dict_t::dictionary(K, _V)) -> boolean()
Key: The key to check the dictionary for
check to see if the dictionary provided has the specified key.
has_value(Value::value(V), Dict_t::dictionary(_K, V)) -> boolean()
Value: The value to check if exists
Check to see if the value exists in the dictionary
keys(Dict::dictionary(K, _V)) -> [key(K)]
Dict: the base dictionary to make use of.
Return the keys of this dictionary as a list
new(ModuleName::module()) -> dictionary(_K, _V)
ModuleName: The module name.
create a new dictionary object from the specified module. The module should implement the dictionary behaviour.
remove(Key::key(K), Dict_t::dictionary(K, V)) -> dictionary(K, V)
Key: the key of the key/value pair to remove
Remove a value from the dictionary returning a new dictionary with the value removed.
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)}]
Dict: the base dictionary to make use of.
Return the contents of this dictionary as a list of key value pairs.
Generated by EDoc, Feb 15 2022, 15:17:47.