ftwin 0.8.10
|
A high-performance hash table implementation built on APR. More...
#include <apr.h>
#include <apr_pools.h>
Go to the source code of this file.
Typedefs | |
typedef struct napr_hash_t | napr_hash_t |
Opaque hash table structure. | |
typedef struct napr_hash_index_t | napr_hash_index_t |
Opaque hash table iterator structure. | |
typedef const void *() | get_key_callback_fn_t(const void *) |
Callback function to extract the key from a stored data item. | |
typedef apr_size_t() | get_key_len_callback_fn_t(const void *) |
Callback function to get the length of a key. | |
typedef int() | key_cmp_callback_fn_t(const void *, const void *, apr_size_t) |
Callback function to compare two keys. | |
typedef apr_uint32_t() | hash_callback_fn_t(register const void *, register apr_size_t) |
Callback function to compute the hash value of a key. | |
Functions | |
napr_hash_t * | napr_hash_make (apr_pool_t *pool, apr_size_t nel, apr_size_t ffactor, get_key_callback_fn_t get_key, get_key_len_callback_fn_t get_key_len, key_cmp_callback_fn_t key_cmp, hash_callback_fn_t hash) |
Create a hash table with custom key handling and hashing functions. | |
napr_hash_t * | napr_hash_str_make (apr_pool_t *pool, apr_size_t nel, apr_size_t ffactor) |
Create a hash table optimized for storing C strings as keys. | |
void * | napr_hash_search (napr_hash_t *hash, const void *key, apr_size_t key_len, apr_uint32_t *hash_value) |
Searches the hash table for an item. | |
void | napr_hash_remove (napr_hash_t *hash, void *data, apr_uint32_t hash_value) |
Removes an item from the hash table. | |
apr_status_t | napr_hash_set (napr_hash_t *hash, void *data, apr_uint32_t hash_value) |
Inserts or updates an item in the hash table. | |
apr_pool_t * | napr_hash_pool_get (const napr_hash_t *thehash) |
Get a pointer to the pool from which the hash table was allocated. | |
napr_hash_index_t * | napr_hash_first (apr_pool_t *pool, napr_hash_t *hash) |
Start iterating over the entries in a hash table. | |
napr_hash_index_t * | napr_hash_next (napr_hash_index_t *index) |
Continue iterating over the entries in a hash table. | |
void | napr_hash_this (napr_hash_index_t *hi, const void **key, apr_size_t *klen, void **val) |
Get the current entry's details from the iteration state. | |
A high-performance hash table implementation built on APR.
Definition in file napr_hash.h.
typedef const void *() get_key_callback_fn_t(const void *) |
Callback function to extract the key from a stored data item.
[in] | data | A pointer to the stored data item. |
Definition at line 43 of file napr_hash.h.
typedef apr_size_t() get_key_len_callback_fn_t(const void *) |
Callback function to get the length of a key.
[in] | data | A pointer to the stored data item. |
Definition at line 50 of file napr_hash.h.
typedef apr_uint32_t() hash_callback_fn_t(register const void *, register apr_size_t) |
Callback function to compute the hash value of a key.
[in] | key | The key to hash. |
[in] | klen | A pointer to the key's length. |
Definition at line 68 of file napr_hash.h.
typedef int() key_cmp_callback_fn_t(const void *, const void *, apr_size_t) |
Callback function to compare two keys.
[in] | key1 | The first key. |
[in] | key2 | The second key. |
[in] | len | The length to compare (can be ignored if keys are null-terminated). |
Definition at line 60 of file napr_hash.h.
napr_hash_index_t * napr_hash_first | ( | apr_pool_t * | pool, |
napr_hash_t * | hash | ||
) |
Start iterating over the entries in a hash table.
[in] | pool | The pool to allocate the iterator from. If NULL, a non-thread-safe internal iterator is used. |
[in] | hash | The hash table to iterate over. |
Definition at line 280 of file napr_hash.c.
References napr_hash_next().
napr_hash_t * napr_hash_make | ( | apr_pool_t * | pool, |
apr_size_t | nel, | ||
apr_size_t | ffactor, | ||
get_key_callback_fn_t | get_key, | ||
get_key_len_callback_fn_t | get_key_len, | ||
key_cmp_callback_fn_t | key_cmp, | ||
hash_callback_fn_t | hash | ||
) |
Create a hash table with custom key handling and hashing functions.
[in] | pool | The pool to allocate the hash table from. |
[in] | nel | The desired number of pre-allocated buckets (will be rounded up to the next power of 2). |
[in] | ffactor | The maximum number of collisions for a given key before resizing. |
[in] | get_key | A callback to extract the key from a data item. |
[in] | get_key_len | A callback to get the length of the key. |
[in] | key_cmp | A callback to compare two keys. |
[in] | hash | A callback to compute the hash of a key. |
Definition at line 100 of file napr_hash.c.
References DEBUG_ERR.
Referenced by napr_hash_str_make().
napr_hash_index_t * napr_hash_next | ( | napr_hash_index_t * | index | ) |
Continue iterating over the entries in a hash table.
[in] | index | The current iteration state. |
Definition at line 294 of file napr_hash.c.
Referenced by napr_hash_first().
apr_pool_t * napr_hash_pool_get | ( | const napr_hash_t * | thehash | ) |
Get a pointer to the pool from which the hash table was allocated.
[in] | thehash | The hash table. |
Definition at line 275 of file napr_hash.c.
void napr_hash_remove | ( | napr_hash_t * | hash, |
void * | data, | ||
apr_uint32_t | hash_value | ||
) |
Removes an item from the hash table.
[in] | hash | The hash table. |
[in] | data | The data item to remove. |
[in] | hash_value | The pre-computed hash of the item's key. |
Definition at line 210 of file napr_hash.c.
References DEBUG_DBG.
void * napr_hash_search | ( | napr_hash_t * | hash, |
const void * | key, | ||
apr_size_t | key_len, | ||
apr_uint32_t * | hash_value | ||
) |
Searches the hash table for an item.
[in] | hash | The hash table to search. |
[in] | key | The key to search for. |
[in] | key_len | The length of the key. |
[out] | hash_value | A pointer to store the computed hash of the key. Can be NULL. |
hash_value
for efficient subsequent insertion. Definition at line 145 of file napr_hash.c.
Referenced by ft_report_duplicates(), and ft_report_json().
apr_status_t napr_hash_set | ( | napr_hash_t * | hash, |
void * | data, | ||
apr_uint32_t | hash_value | ||
) |
Inserts or updates an item in the hash table.
[in] | hash | The hash table. |
[in] | data | The data item to insert. |
[in] | hash_value | The pre-computed hash of the item's key. |
Definition at line 242 of file napr_hash.c.
References DEBUG_ERR.
napr_hash_t * napr_hash_str_make | ( | apr_pool_t * | pool, |
apr_size_t | nel, | ||
apr_size_t | ffactor | ||
) |
Create a hash table optimized for storing C strings as keys.
[in] | pool | The pool to allocate the hash table from. |
[in] | nel | The desired number of pre-allocated buckets. |
[in] | ffactor | The maximum number of collisions for a given key. |
Definition at line 95 of file napr_hash.c.
References napr_hash_make().
void napr_hash_this | ( | napr_hash_index_t * | hi, |
const void ** | key, | ||
apr_size_t * | klen, | ||
void ** | val | ||
) |
Get the current entry's details from the iteration state.
[in] | hi | The iteration state. |
[out] | key | Pointer to store the key. Can be NULL. |
[out] | klen | Pointer to store the key length. Can be NULL. |
[out] | val | Pointer to store the value (the data item). Can be NULL. |
Definition at line 314 of file napr_hash.c.