Typedefs | |
typedef _HashTable | HashTable |
A hash table structure. | |
typedef unsigned long(* | HashTableHashFunc )(void *data) |
Hash function used to generate hash values for keys used in a hash table. | |
typedef int(* | HashTableEqualFunc )(void *data1, void *data2) |
Function used to compare two keys for equality. | |
typedef void(* | HashTableFreeFunc )(void *data) |
Type of function used to free keys and values when entries are removed from a hash table. | |
typedef void(* | HashTableIterator )(void *key, void *value, void *user_data) |
Type of function used as a callback when iterating over data. | |
typedef int(* | HashTableRemoveIterator )(void *key, void *value, void *user_data) |
Type of function used as a callback when iterating over a hash table, selectively removing entries. | |
Functions | |
HashTable * | hash_table_new (HashTableHashFunc hash_func, HashTableEqualFunc equal_func) |
Create a new hash table. | |
void | hash_table_free (HashTable *hashtable) |
Destroy a hash table. | |
void | hash_table_register_free_functions (HashTable *hashtable, HashTableFreeFunc key_free_func, HashTableFreeFunc value_free_func) |
Register functions used to free the key and value when an entry is removed from a hash table. | |
void | hash_table_insert (HashTable *hashtable, void *key, void *value) |
Insert a value into a hash table, overwriting any existing entry using the same key. | |
void * | hash_table_lookup (HashTable *hashtable, void *key) |
Look up a value in a hash table by key. | |
int | hash_table_remove (HashTable *hashtable, void *key) |
Remove a value from a hash table. | |
int | hash_table_num_entries (HashTable *hashtable) |
Retrieve the number of entries in a hash table. | |
void | hash_table_foreach (HashTable *hashtable, HashTableIterator iterator, void *user_data) |
Iterate over all key-value pairs in a hash table. | |
int | hash_table_foreach_remove (HashTable *hashtable, HashTableRemoveIterator iterator, void *user_data) |
Iterate over all key-value pairs in a hash table, selectively removing entries. |
A hash table stores a set of values which can be addressed by a key. Given the key, the corresponding value can be looked up quickly.
To create a hash table, use hash_table_new. To destroy a hash table, use hash_table_free.
To insert a value into a hash table, use hash_table_insert.
To remove a value from a hash table, use hash_table_remove.
To look up a value by its key, use hash_table_lookup.
|
Function used to compare two keys for equality.
|
|
Hash function used to generate hash values for keys used in a hash table.
|
|
Type of function used as a callback when iterating over data. See hash_table_foreach.
|
|
Type of function used as a callback when iterating over a hash table, selectively removing entries. See hash_table_foreach_remove.
|
|
Iterate over all key-value pairs in a hash table.
|
|
Iterate over all key-value pairs in a hash table, selectively removing entries.
|
|
Destroy a hash table.
|
|
Insert a value into a hash table, overwriting any existing entry using the same key.
|
|
Look up a value in a hash table by key.
|
|
Create a new hash table.
|
|
Retrieve the number of entries in a hash table.
|
|
Register functions used to free the key and value when an entry is removed from a hash table.
|
|
Remove a value from a hash table.
|