#include <stdbool.h>
#include <dom/functypes.h>
Go to the source code of this file.
◆ dom_hash_table
◆ dom_hash_vtable
◆ _dom_hash_add()
| bool _dom_hash_add |
( |
dom_hash_table * |
ht, |
|
|
void * |
key, |
|
|
void * |
value, |
|
|
bool |
replace |
|
) |
| |
Adds a key/value pair to a hash table
- Parameters
-
| ht | The hash table context to add the key/value pair to. |
| key | The key to associate the value with. |
| value | The value to associate the key with. |
- Returns
- true if the add succeeded, false otherwise. (Failure most likely indicates insufficent memory to make copies of the key and value.
◆ _dom_hash_clone()
Clone a hash table.
- Parameters
-
- Returns
- The cloned hash table.
◆ _dom_hash_create()
Create a new hash table, and return a context for it. The memory consumption of a hash table is approximately 8 + (nchains * 12) bytes if it is empty.
- Parameters
-
| chains | Number of chains/buckets this hash table will have. This should be a prime number, and ideally a prime number just over a power of two, for best performance and distribution |
| vtable | Client vtable |
| pw | Client private data |
- Returns
- struct dom_hash_table containing the context of this hash table or NULL if there is insufficent memory to create it and its chains.
◆ _dom_hash_del()
Delete the key from the hashtable.
- Parameters
-
| ht | The hashtable object |
| key | The key to delete |
- Returns
- The deleted value
◆ _dom_hash_destroy()
Destroys a hash table, freeing all memory associated with it.
- Parameters
-
| ht | Hash table to destroy. After the function returns, this will nolonger be valid |
◆ _dom_hash_get()
Looks up a the value associated with with a key from a specific hash table.
- Parameters
-
| ht | The hash table context to look up |
| key | The key to search for |
- Returns
- The value associated with the key, or NULL if it was not found.
◆ _dom_hash_get_length()
Get the number of elements in this hash table
- Parameters
-
- Returns
- the number of elements
◆ _dom_hash_iterate()
| void * _dom_hash_iterate |
( |
struct dom_hash_table * |
ht, |
|
|
uintptr_t * |
c1, |
|
|
uintptr_t ** |
c2 |
|
) |
| |
Iterate through all available hash keys.
- Parameters
-
| ht | The hash table context to iterate. |
| c1 | Pointer to first context |
| c2 | Pointer to second context (set to 0 on first call) |
- Returns
- The next hash key, or NULL for no more keys