a simple hash table implementation More...
Functions | |
| hash_table_element_t * | hash_table_element_new () |
| void | hash_table_element_delete (hash_table_t *table, hash_table_element_t *element) |
| hash_table_t * | hash_table_new (hash_table_mode_t mode) |
| void | hash_table_delete (hash_table_t *table) |
| int | hash_table_add (hash_table_t *table, void *key, size_t key_len, void *value, size_t value_len) |
| int | hash_table_remove (hash_table_t *table, void *key, size_t key_len) |
| void * | hash_table_lookup (hash_table_t *table, void *key, size_t key_len) |
| int | hash_table_has_key (hash_table_t *table, void *key, size_t key_len) |
| size_t | hash_table_get_keys (hash_table_t *table, void ***keys_ptr) |
| size_t | hash_table_get_elements (hash_table_t *table, hash_table_element_t ***elements) |
| uint16_t | hash_table_do_hash (void *key, size_t key_len, uint16_t max_key) |
| int | hash_table_resize (hash_table_t *table, size_t len) |
| int | hash_table_iterate (hash_table_t *table, int(*fct)(void *user, void *value, void *key, size_t key_len), void *user) |
a simple hash table implementation
License GPLv3+
| int hash_table_add | ( | hash_table_t * | table, |
| void * | key, | ||
| size_t | key_len, | ||
| void * | value, | ||
| size_t | value_len | ||
| ) |
Function to add a key - value pair to the hash table, use HT_ADD macro
| table | hash table to add element to |
| key | pointer to the key for the hash table |
| key_len | length of the key in bytes |
| value | pointer to the value to be added against the key |
| value_len | length of the value in bytes |
| void hash_table_delete | ( | hash_table_t * | table | ) |
Function to delete the hash table
| table | hash table to be deleted |
| uint16_t hash_table_do_hash | ( | void * | key, |
| size_t | key_len, | ||
| uint16_t | max_key | ||
| ) |
Function that returns a hash value for a given key and key_len
| key | pointer to the key |
| key_len | length of the key |
| max_key | max value of the hash to be returned by the function |
| void hash_table_element_delete | ( | hash_table_t * | table, |
| hash_table_element_t * | element | ||
| ) |
Function to delete an hash table element
| table | table from which element has to be deleted |
| element | hash table element to be deleted |
| hash_table_element_t* hash_table_element_new | ( | ) |
Function to create a now hash_table element
| size_t hash_table_get_elements | ( | hash_table_t * | table, |
| hash_table_element_t *** | elements | ||
| ) |
Function to get all elements (key - value pairs) from the given hash table
| table | hash table from which elements have to be retrieved |
| elements | a pointer to an array of hash_table_element_t pointer (malloced by function) |
| size_t hash_table_get_keys | ( | hash_table_t * | table, |
| void *** | keys_ptr | ||
| ) |
Function to return all the keys in a given hash table
| table | hash table from which key are to be reterived |
| keys | a void** pointer where keys are filled in (memory allocated internally and must be freed) |
| int hash_table_has_key | ( | hash_table_t * | table, |
| void * | key, | ||
| size_t | key_len | ||
| ) |
Function to look if the exists in the hash table
| key | pointer to key to be looked for |
| key_len | size of the key to be searched |
| int hash_table_iterate | ( | hash_table_t * | table, |
| int(*)(void *user, void *value, void *key, size_t key_len) | fct, | ||
| void * | user | ||
| ) |
Function to iterate through all elements of the hashtable
| table | hash table to be iterated |
| fct | pointer to a function returning 1 if the element has to be removed |
| user | arbitrary user pointer passed to the fct callback |
| void* hash_table_lookup | ( | hash_table_t * | table, |
| void * | key, | ||
| size_t | key_len | ||
| ) |
Function to lookup a key in a particular table
| table | table to look key in |
| key | pointer to key to be looked for |
| key_len | size of the key to be searched |
| hash_table_t* hash_table_new | ( | hash_table_mode_t | mode | ) |
Fuction to create a new hash table
| mode | hash_table_mode which the hash table should follow |
| int hash_table_remove | ( | hash_table_t * | table, |
| void * | key, | ||
| size_t | key_len | ||
| ) |
Function to remove an hash table element (for a given key) from a given hash table
| table | hash table from which element has to be removed |
| key | pointer to the key which has to be removed |
| key_len | size of the key in bytes |
| int hash_table_resize | ( | hash_table_t * | table, |
| size_t | len | ||
| ) |
Function to resize the hash table store house
| table | hash table to be resized |
| len | new length of the hash table |