![]() |
ATLAS Offline Software
|
Hash table. More...
Go to the source code of this file.
Classes | |
| struct | _HashTableIterator |
| Definition of a HashTableIterator. More... | |
Macros | |
| #define | HASH_TABLE_NULL ((void *) 0) |
| A null HashTableValue. More... | |
Typedefs | |
| typedef struct _HashTable | HashTable |
| A hash table structure. More... | |
| typedef struct _HashTableIterator | HashTableIterator |
| Structure used to iterate over a hash table. More... | |
| typedef struct _HashTableEntry | HashTableEntry |
| Internal structure representing an entry in a hash table. More... | |
| typedef void * | HashTableKey |
| A key to look up a value in a HashTable. More... | |
| typedef void * | HashTableValue |
| A value stored in a HashTable. More... | |
| typedef unsigned long(* | HashTableHashFunc) (HashTableKey value) |
| Hash function used to generate hash values for keys used in a hash table. More... | |
| typedef int(* | HashTableEqualFunc) (HashTableKey value1, HashTableKey value2) |
| Function used to compare two keys for equality. More... | |
| typedef void(* | HashTableKeyFreeFunc) (HashTableKey value) |
| Type of function used to free keys when entries are removed from a hash table. More... | |
| typedef void(* | HashTableValueFreeFunc) (HashTableValue value) |
| Type of function used to free values when entries are removed from a hash table. More... | |
Functions | |
| HashTable * | hash_table_new (HashTableHashFunc hash_func, HashTableEqualFunc equal_func) |
| Create a new hash table. More... | |
| void | hash_table_free (HashTable *hash_table) |
| Destroy a hash table. More... | |
| void | hash_table_register_free_functions (HashTable *hash_table, HashTableKeyFreeFunc key_free_func, HashTableValueFreeFunc value_free_func) |
| Register functions used to free the key and value when an entry is removed from a hash table. More... | |
| int | hash_table_insert (HashTable *hash_table, HashTableKey key, HashTableValue value) |
| Insert a value into a hash table, overwriting any existing entry using the same key. More... | |
| HashTableValue | hash_table_lookup (HashTable *hash_table, HashTableKey key) |
| Look up a value in a hash table by key. More... | |
| int | hash_table_remove (HashTable *hash_table, HashTableKey key) |
| Remove a value from a hash table. More... | |
| int | hash_table_num_entries (HashTable *hash_table) |
| Retrieve the number of entries in a hash table. More... | |
| void | hash_table_iterate (HashTable *hash_table, HashTableIterator *iter) |
| Initialise a HashTableIterator to iterate over a hash table. More... | |
| int | hash_table_iter_has_more (HashTableIterator *iterator) |
| Determine if there are more keys in the hash table to iterate over. More... | |
| HashTableValue | hash_table_iter_next (HashTableIterator *iterator) |
| Using a hash table iterator, retrieve the next key. More... | |
Hash table.
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.
To iterate over all values in a hash table, use hash_table_iterate to initialise a HashTableIterator structure. Each value can then be read in turn using hash_table_iter_next and hash_table_iter_has_more.
Definition in file hash-table.h.
| #define HASH_TABLE_NULL ((void *) 0) |
A null HashTableValue.
Definition at line 97 of file hash-table.h.
| typedef struct _HashTable HashTable |
A hash table structure.
Definition at line 1 of file hash-table.h.
| typedef struct _HashTableEntry HashTableEntry |
Internal structure representing an entry in a hash table.
Definition at line 1 of file hash-table.h.
| typedef int(* HashTableEqualFunc) (HashTableKey value1, HashTableKey value2) |
Function used to compare two keys for equality.
Definition at line 115 of file hash-table.h.
| typedef unsigned long(* HashTableHashFunc) (HashTableKey value) |
Hash function used to generate hash values for keys used in a hash table.
| value | The value to generate a hash value for. |
Definition at line 106 of file hash-table.h.
| typedef struct _HashTableIterator HashTableIterator |
Structure used to iterate over a hash table.
Definition at line 1 of file hash-table.h.
| typedef void* HashTableKey |
A key to look up a value in a HashTable.
Definition at line 74 of file hash-table.h.
| typedef void(* HashTableKeyFreeFunc) (HashTableKey value) |
Type of function used to free keys when entries are removed from a hash table.
Definition at line 122 of file hash-table.h.
| typedef void* HashTableValue |
A value stored in a HashTable.
Definition at line 80 of file hash-table.h.
| typedef void(* HashTableValueFreeFunc) (HashTableValue value) |
Type of function used to free values when entries are removed from a hash table.
Definition at line 129 of file hash-table.h.
| void hash_table_free | ( | HashTable * | hash_table | ) |
Destroy a hash table.
| hash_table | The hash table to destroy. |
| int hash_table_insert | ( | HashTable * | hash_table, |
| HashTableKey | key, | ||
| HashTableValue | value | ||
| ) |
Insert a value into a hash table, overwriting any existing entry using the same key.
| hash_table | The hash table. |
| key | The key for the new value. |
| value | The value to insert. |
| int hash_table_iter_has_more | ( | HashTableIterator * | iterator | ) |
Determine if there are more keys in the hash table to iterate over.
| iterator | The hash table iterator. |
| HashTableValue hash_table_iter_next | ( | HashTableIterator * | iterator | ) |
Using a hash table iterator, retrieve the next key.
| iterator | The hash table iterator. |
| void hash_table_iterate | ( | HashTable * | hash_table, |
| HashTableIterator * | iter | ||
| ) |
Initialise a HashTableIterator to iterate over a hash table.
| hash_table | The hash table. |
| iter | Pointer to an iterator structure to initialise. |
| HashTableValue hash_table_lookup | ( | HashTable * | hash_table, |
| HashTableKey | key | ||
| ) |
Look up a value in a hash table by key.
| hash_table | The hash table. |
| key | The key of the value to look up. |
| HashTable* hash_table_new | ( | HashTableHashFunc | hash_func, |
| HashTableEqualFunc | equal_func | ||
| ) |
Create a new hash table.
| hash_func | Function used to generate hash keys for the keys used in the table. |
| equal_func | Function used to test keys used in the table for equality. |
| int hash_table_num_entries | ( | HashTable * | hash_table | ) |
Retrieve the number of entries in a hash table.
| hash_table | The hash table. |
| void hash_table_register_free_functions | ( | HashTable * | hash_table, |
| HashTableKeyFreeFunc | key_free_func, | ||
| HashTableValueFreeFunc | value_free_func | ||
| ) |
Register functions used to free the key and value when an entry is removed from a hash table.
| hash_table | The hash table. |
| key_free_func | Function used to free keys. |
| value_free_func | Function used to free values. |
| int hash_table_remove | ( | HashTable * | hash_table, |
| HashTableKey | key | ||
| ) |
Remove a value from a hash table.
| hash_table | The hash table. |
| key | The key of the value to remove. |
1.8.18