A hashtable associates keys of arbitrary size and content with values. This data structure is also called associative array sometimes because you use keys in order to access values instead of numbers. You cannot store two values associated with the same key. The values can have any simple C types like integers or pointers.
Create a new hash table with an initial capacity size. Return a
non-zero pointer to the newly created hash. The size is calculated down
to a binary value. The destroy callback specifies an
element destruction callback for use by
svz_hash_destroy for each value. If no such operation should be
performed the argument must be
Set the internal keylen, code and and equals functions for hash table hash. Return hash.
const char *data and returns
the number of bytes in data representing the key.
const char *data
const char *data1, const char *data2
int, which should be non-zero if equal.
As a special case, a
NULL value means don’t set that function,
leaving it to its default value.
Destroy the existing hash table hash,
all keys within the hash, the hash table and the hash itself.
If a non-
NULL element destruction callback was specified to
svz_hash_create, that function is called on each value.
Delete an existing entry accessed via a key from the
hash table hash. Return
NULL if there is no
such key, otherwise the previous value.
Add a new element consisting of key and value to hash. When key already exists, replace and return the old value. Note: This is sometimes the source of memory leaks.
Return the value associated with key in the hash table
NULL if there is no such key.
Iterate func over each key/value pair in hash.
func is called with three
void * args: the key,
the value and the opaque (to
Return the number of keys in the hash table hash.
If hash is
NULL, return zero.
Return the key associated with value in the hash table
NULL if there is no such value.
Return non-zero if
key is stored within
the hash table
hash, otherwise zero.
This function is useful when you cannot tell whether the return
== NULL) indicates a real
value in the hash or a non-existing hash key.