- This does not mean that each distinct object must produce a
- distinct value, only that non-distinct objects must produce the
- same values! For instance, a hash function that returns 0 for
- any given object is a perfectly valid (albeit extremely bad) hash
- function. A hash function that hashes a string by adding up all
- its characters is another example of a valid (but quite bad) hash
- function.
-
- The above stated rule is quite easy to enforce. For example, if
- your testing function compares strings case-insensitively, all
- your function needs to do is lower-case the string characters
- before calculating a hash. That way you have easily guaranteed
- that case differences will not result in a different hash.
-
- - (optional) Choose the hash function to get as good "spreading" as
- possible. A good hash function will react to even a small change
- in its input with a completely different resulting hash.
- Finally, don't make your hash function extremely slow, because
- you're then defeating the purpose of hashing.
+ Hash tables are a technique used to implement mapping between
+ objects with near-constant-time access and storage. The table
+ associates keys to values, and a value can be very quickly
+ retrieved by providing the key. Fast lookup tables are typically
+ implemented as hash tables.
+
+ The entry points are
+ hash_table_new -- creates the table.
+ hash_table_destroy -- destroys the table.
+ hash_table_put -- establishes or updates key->value mapping.
+ hash_table_get -- retrieves value of key.
+ hash_table_get_pair -- get key/value pair for key.
+ hash_table_contains -- test whether the table contains key.
+ hash_table_remove -- remove key->value mapping for given key.
+ hash_table_for_each -- call function for each table entry.
+ hash_table_iterate -- iterate over entries in hash table.
+ hash_table_iter_next -- return next element during iteration.
+ hash_table_clear -- clear hash table contents.
+ hash_table_count -- return the number of entries in the table.
+
+ The hash table grows internally as new entries are added and is not
+ limited in size, except by available memory. The table doubles
+ with each resize, which ensures that the amortized time per
+ operation remains constant.
+
+ If not instructed otherwise, tables created by hash_table_new
+ consider the keys to be equal if their pointer values are the same.
+ You can use make_string_hash_table to create tables whose keys are
+ considered equal if their string contents are the same. In the
+ general case, the criterion of equality used to compare keys is
+ specified at table creation time with two callback functions,
+ "hash" and "test". The hash function transforms the key into an
+ arbitrary number that must be the same for two equal keys. The
+ test function accepts two keys and returns non-zero if they are to
+ be considered equal.