This module provides exactly the same interface as the module
dictionary()
as returned by new/0
This function appends a new
This function appends a list of values
This function erases all items with a given key from a dictionary.
This function returns the value associated with
This function returns a list of all keys in the dictionary.
This function searches for a key in a dictionary. Returns
Calls
This function converts the key/value list
This function tests if
merge(Fun, D1, D2) ->
fold(fun (K, V1, D) ->
update(K, fun (V2) -> Fun(K, V1, V2) end, V1, D)
end, D2, D1).
but is faster.
This function creates a new dictionary.
Returns the number of elements in a
This function stores a
This function converts the dictionary to a list representation.
Update the a value in a dictionary by calling
Update the a value in a dictionary by calling
append(Key, Val, D) ->
update(Key, fun (Old) -> Old ++ [Val] end, [Val], D).
Add
This could be defined as:
update_counter(Key, Incr, D) ->
update(Key, fun (Old) -> Old + Incr end, Incr, D).
but is faster.
The functions
> D0 = dict:new(), D1 = dict:store(files, [], D0), D2 = dict:append(files, f1, D1), D3 = dict:append(files, f2, D2), D4 = dict:append(files, f3, D3), dict:fetch(files, D4). [f1,f2,f3]
This saves the trouble of first fetching a keyed value, appending a new value to the list of stored values, and storing the result.
The function