|
| struct clod_table * | clod_table_create (const struct clod_table_opts *opts) |
| void | clod_table_destroy (struct clod_table *t) |
| size_t | clod_table_len (const struct clod_table *t) |
| bool | clod_table_add (struct clod_table *t, const void *element, size_t key_size, void **existing_out) |
| bool | clod_table_set (struct clod_table *t, const void *element, size_t key_size, void **existing_out) |
| void * | clod_table_get (const struct clod_table *t, const void *key, size_t key_size) |
| void * | clod_table_del (struct clod_table *t, const void *key, size_t key_size) |
| bool | clod_table_iter (const struct clod_table *t, struct clod_table_iter *iter) |
| uint64_t | clod_table_hash_ptr (uint64_t seed, const void *key, size_t key_size, void *user) |
| int | clod_table_cmp_ptr (const void *key1, size_t key1_size, const void *key2, size_t key2_size, void *user) |
A hash table implementation. It's a pure set at heart, but since methods never return a pointer not supplied by the user, it can be trivially extended to a key->value map by storing the value after the key. The difference in wording between 'element' and 'key' reflects this. If implementing a map, 'element' implies the key and trailing value data associated with it, while 'key' simply implies the key value. If instead a pure set is required - 'element' and 'key' become interchangeable. I would recommend using a struct with the first field being the key and subsequent fields being the value, although for maps with variable-length keys more manual intervention may be required.
| bool clod_table_iter |
( |
const struct clod_table * | t, |
|
|
struct clod_table_iter * | iter ) |
Get the next element in, or start, an iteration over table elements. Mutating the table, except deleting elements, during iteration can result in existing elements being iterated more than once or not at all.
The iterator should be zero initialised to start an iteration. The iterator is zeroed at the end of the iteration.
- Parameters
-
| [in] | t | Handle to the table. |
| [in,out] | iter | Iterator to be incremented. |
- Returns
- If the next element was found.
Definition at line 258 of file table.c.