Erlang provides native support for hash tables through the dict and ets modules. dict provides a simple dictionary implementation, in which values (of any Erlang type) can be stored and accessed by keys (Erlang terms). ets has a similar interface, but is designed for dealing with vast quantities of data.
To create a new dictionary, dict:new. Alternatively, you can generate a new dictionary from an existing list, using the dict:from_list function. The ets table implementation has similar features.
An additional advantage of the ets implementation is that it can be used as a bag, allowing multiple entries for the same key value (unlike standard dictionaries). This behavior is frequently useful is real-world problems.
The details will be discussed in the various recipes, but for now suffice it to say that:
creates a new hash table (dictionary) and ets table (named dictionary, in this case holding duplicate copies of entries). By default this table will compare keys using ==.
In the following recipes we will discuss ways to manipulate our newly
created hash table.
Based on work by KarlaRamirez.
-- BrentAFulgham - 31 Aug 2004