libdom
|
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#include "utils/hashtable.h"
#include <libwapcaplet/libwapcaplet.h>
Classes | |
struct | _dom_hash_entry |
struct | dom_hash_table |
Functions | |
dom_hash_table * | _dom_hash_create (unsigned int chains, const dom_hash_vtable *vtable, void *pw) |
dom_hash_table * | _dom_hash_clone (dom_hash_table *ht) |
void | _dom_hash_destroy (dom_hash_table *ht) |
bool | _dom_hash_add (dom_hash_table *ht, void *key, void *value, bool replace) |
void * | _dom_hash_get (struct dom_hash_table *ht, void *key) |
void * | _dom_hash_del (struct dom_hash_table *ht, void *key) |
void * | _dom_hash_iterate (struct dom_hash_table *ht, uintptr_t *c1, uintptr_t **c2) |
uint32_t | _dom_hash_get_length (struct dom_hash_table *ht) |
bool _dom_hash_add | ( | dom_hash_table * | ht, |
void * | key, | ||
void * | value, | ||
bool | replace ) |
Adds a key/value pair to a hash table
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. |
dom_hash_table * _dom_hash_clone | ( | dom_hash_table * | ht | ) |
Clone a hash table.
ht | Hash table to clone. |
dom_hash_table * _dom_hash_create | ( | unsigned int | chains, |
const dom_hash_vtable * | vtable, | ||
void * | pw ) |
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.
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 |
void * _dom_hash_del | ( | struct dom_hash_table * | ht, |
void * | key ) |
Delete the key from the hashtable.
ht | The hashtable object |
key | The key to delete |
void _dom_hash_destroy | ( | dom_hash_table * | ht | ) |
Destroys a hash table, freeing all memory associated with it.
ht | Hash table to destroy. After the function returns, this will nolonger be valid |
void * _dom_hash_get | ( | struct dom_hash_table * | ht, |
void * | key ) |
Looks up a the value associated with with a key from a specific hash table.
ht | The hash table context to look up |
key | The key to search for |
uint32_t _dom_hash_get_length | ( | struct dom_hash_table * | ht | ) |
Get the number of elements in this hash table
ht | The hash table |
void * _dom_hash_iterate | ( | struct dom_hash_table * | ht, |
uintptr_t * | c1, | ||
uintptr_t ** | c2 ) |
Iterate through all available hash keys.
ht | The hash table context to iterate. |
c1 | Pointer to first context |
c2 | Pointer to second context (set to 0 on first call) |