axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
axlHash* axl_hash_new ( axlHashFunc  hash,
axlEqualFunc  equal 

Creates a new hash table using the function provided as hashing function.

The hash function (axlHashFunc) allows the hash table to distribute values across the table while performing inserts operation but it is also used while getting data from the table.

A second function is required (axlEqualFunc) to resolve internal table conflicts while placing data that are indexed using the same value generated by axlHashFunc. This hash implementation store items at the giving position using a linked list (Chaining collition resolution). Knowing this, an external function is required to compare items to ensure they are selected properly.

This hash accept any kind of key and values to be stored as long as the provided functions returns different identifiers to store items. However, because the common use of a hash is to store data using strings as keys two functions are provided by default to create a string index hash table: axl_hash_equal_string and axl_hash_string.

1 // create a string indexed hash
2 axlHash * hash = axl_hash_new (axl_hash_string, axl_hash_equal_string);

Additionally, two functions are provided to create hash containing integer values as keys: axl_hash_int and axl_hash_equal_int.

Once the hash is created the following functions must be used to store data:

Then, use the following function to get data associated to the provided key.

Finally, you can use the following functions to either remove items from the hash and to completely deallocate the memory used by the hash and all of its data:

hashThe hashing function to be used for this table.
equalThe equal function used by the hash to actually check that two stored items are equal (using the key value)
A newly created hash table that is deallocated by using axl_hash_free.

References axl_hash_new_full().

Referenced by axl_dtd_validate().