From 68d53c01b0b8e9a007a6a30158c19e34b2d2a34e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= This module provides a This module provides exactly the same interface as the module
- This module provides the same interface as the
+
Dictionary as returned by
Dictionary as returned by
+
This function appends a new
Appends a new
See also section
This function appends a list of values
Appends a list of values
See also section
This function erases all items with a given key from a - dictionary.
+Erases all items with a specified key from a dictionary.
This function returns the value associated with
Returns the value associated with
See also section
This function returns a list of all keys in the dictionary.
+Returns a list of all keys in a dictionary.
This function searches for a key in a dictionary. Returns
-
Searches for a key in a dictionary. Returns
+
See also section
Calls
This function converts the
Converts the
Returns
This function tests if
Tests if
Calls
Merges two dictionaries,
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.
+Creates a new dictionary.
Returns the number of elements in an
Returns
This function stores a
Stores a
This function converts the dictionary to a list - representation.
+Converts a dictionary to a list representation.
Update a value in a dictionary by calling
Updates a value in a dictionary by calling
Update a value in a dictionary by calling
Updates a value in a dictionary by calling
append(Key, Val, D) ->
update(Key, fun (Old) -> Old ++ [Val] end, [Val], D).
Add
Adds
This could be defined as:
+This can be defined as follows, but is faster:
update_counter(Key, Incr, D) ->
update(Key, fun (Old) -> Old + Incr end, Incr, D).
- but is faster.
The functions
Functions
> D0 = orddict:new(), @@ -264,19 +293,18 @@ update_counter(Key, Incr, D) -> D3 = orddict:append(files, f2, D2), D4 = orddict:append(files, f3, D3), orddict:fetch(files, D4). -[f1,f2,f3]+[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
Function