Hash table. More...

Go to the source code of this file.
Macros | |
| #define | HAT_HT_SUCCESS 0 |
| #define | HAT_HT_ERROR (-1) |
Typedefs | |
| typedef struct hat_ht_t | hat_ht_t |
| Hash table. | |
| typedef void * | hat_ht_iter_t |
| Hash table iterator. | |
Functions | |
| hat_ht_t * | hat_ht_create (hat_allocator_t *a) |
| Create new hash table. | |
| void | hat_ht_destroy (hat_ht_t *t) |
| Destroy hash table. | |
| size_t | hat_ht_count (hat_ht_t *t) |
| Number of elements in table. | |
| int | hat_ht_set (hat_ht_t *t, void *key, size_t key_size, void *value) |
| Set element in table. | |
| void * | hat_ht_get (hat_ht_t *t, void *key, size_t key_size) |
| Get element from table. | |
| void * | hat_ht_pop (hat_ht_t *t, void *key, size_t key_size) |
| Pop element from table. | |
| int | hat_ht_del (hat_ht_t *t, void *key, size_t key_size) |
| Delete element from table. | |
| hat_ht_iter_t | hat_ht_iter_next (hat_ht_t *t, hat_ht_iter_t prev) |
| Get next iterator position. | |
| void * | hat_ht_iter_key (hat_ht_iter_t i) |
| Get current key. | |
| size_t | hat_ht_iter_key_size (hat_ht_iter_t i) |
| Get current key size. | |
| void * | hat_ht_iter_value (hat_ht_iter_t i) |
| Get current value. | |
Hash table.
This hash table implementation stores copies of key data and value pointers.
| #define HAT_HT_ERROR (-1) |
| #define HAT_HT_SUCCESS 0 |
| typedef void* hat_ht_iter_t |
Hash table iterator.
| size_t hat_ht_count | ( | hat_ht_t * | t | ) |
Number of elements in table.
| [in] | t | table |
| hat_ht_t * hat_ht_create | ( | hat_allocator_t * | a | ) |
Create new hash table.
| [in] | a | allocator |
NULL on failure | int hat_ht_del | ( | hat_ht_t * | t, |
| void * | key, | ||
| size_t | key_size | ||
| ) |
Delete element from table.
| [in] | t | table |
| [in] | key | key |
| [in] | key_size | key size |
HAT_HT_SUCCESS or HAT_HT_ERROR | void hat_ht_destroy | ( | hat_ht_t * | t | ) |
Destroy hash table.
| [in] | t | table |
| void * hat_ht_get | ( | hat_ht_t * | t, |
| void * | key, | ||
| size_t | key_size | ||
| ) |
Get element from table.
| [in] | t | table |
| [in] | key | key |
| [in] | key_size | key size |
NULL on failure | void * hat_ht_iter_key | ( | hat_ht_iter_t | i | ) |
Get current key.
| [in] | i | iterator |
| size_t hat_ht_iter_key_size | ( | hat_ht_iter_t | i | ) |
Get current key size.
| [in] | i | iterator |
| hat_ht_iter_t hat_ht_iter_next | ( | hat_ht_t * | t, |
| hat_ht_iter_t | prev | ||
| ) |
Get next iterator position.
| [in] | t | table |
| [in] | prev | previous iterator position |
NULLIf prev is NULL, new iterator points to first entry. If all entries are iterated, NULL is returned.
| void * hat_ht_iter_value | ( | hat_ht_iter_t | i | ) |
Get current value.
| [in] | i | iterator |
| void * hat_ht_pop | ( | hat_ht_t * | t, |
| void * | key, | ||
| size_t | key_size | ||
| ) |
Pop element from table.
| [in] | t | table |
| [in] | key | key |
| [in] | key_size | key size |
NULL on failure | int hat_ht_set | ( | hat_ht_t * | t, |
| void * | key, | ||
| size_t | key_size, | ||
| void * | value | ||
| ) |
Set element in table.
| [in] | t | table |
| [in] | key | key |
| [in] | key_size | key size |
| [in] | value | value |
HAT_HT_SUCCESS or HAT_HT_ERRORIf key already exist, value is overridden.