![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
| union | HASH_DATA |
| union of the possibles data values of a node More... | |
| struct | HASH_NODE |
| structure of a hash table node More... | |
| struct | HASH_TABLE |
| structure of a hash table More... | |
Macros | |
| #define | HASH_CLASSIC 128 |
| Murmur hash using hash key string, hash key numeric value, index table with lists of elements. | |
| #define | HASH_DOUBLE 2 |
| value of double type inside the hash node | |
| #define | HASH_INT 1 |
| compatibility with existing rot func | |
| #define | HASH_INT_TYPE int64_t |
| type of a HASH_INT in 64 bits | |
| #define | HASH_PTR 8 |
| value of pointer type inside the hash node | |
| #define | HASH_STRING 4 |
| value of char * type inside the hash node | |
| #define | HASH_TRIE 256 |
| TRIE tree using hash key string. | |
| #define | HASH_UNKNOWN 16 |
| value of unknow type inside the hash node | |
| #define | hash_val(node, type) ((node && node->ptr) ? ((type*)(((HASH_NODE*)node->ptr)->data.ptr)) : NULL) |
| Cast a HASH_NODE element. | |
| #define | HASH_VAL(node, type) ((node && node->data.ptr) ? ((type*)node->data.ptr) : NULL) |
| Cast a HASH_NODE element. | |
| #define | ht_foreach(__ITEM_, __HASH_) |
| ForEach macro helper (classic / old) | |
| #define | HT_FOREACH(__ITEM_, __HASH_, ...) |
| ForEach macro helper. | |
| #define | HT_FOREACH_R(__ITEM_, __HASH_, __ITERATOR, ...) |
| ForEach macro helper. | |
| #define | ht_foreach_r(__ITEM_, __HASH_, __ITERATOR_) |
| ForEach macro helper, reentrant (classic / old) | |
| #define | MurmurHash(__key, __len, __seed, __out) MurmurHash3_x64_128(__key, __len, __seed, __out) |
| Murmur hash macro helper 64 bits. | |
Typedefs | |
| typedef size_t | HASH_VALUE |
| type of a HASH_VALUE | |
Functions | |
| int | destroy_ht (HASH_TABLE **table) |
| destroy a hash table and free all resources | |
| int | empty_ht (HASH_TABLE *table) |
| empty a hash table, freeing all nodes | |
| HASH_TABLE * | ht_duplicate (HASH_TABLE *table) |
| duplicate a hash table | |
| LIST * | ht_get_completion_list (HASH_TABLE *table, const char *keybud, size_t max_results) |
| get a list of key completions matching the given prefix | |
| int | ht_get_double (HASH_TABLE *table, const char *key, double *val) |
| get a double value from the hash table by key | |
| int | ht_get_int (HASH_TABLE *table, const char *key, int64_t *val) |
| get an integer value from the hash table by key | |
| HASH_NODE * | ht_get_node (HASH_TABLE *table, const char *key) |
| get the HASH_NODE associated with the given key | |
| HASH_NODE * | ht_get_node_ex (HASH_TABLE *table, HASH_VALUE hash_value) |
| get a HASH_NODE by numeric hash value | |
| size_t | ht_get_optimal_size (HASH_TABLE *table) |
| compute the optimal size for the hash table | |
| int | ht_get_ptr (HASH_TABLE *table, const char *key, void **val) |
| get a pointer value from the hash table by key | |
| int | ht_get_ptr_ex (HASH_TABLE *table, HASH_VALUE hash_value, void **val) |
| get a pointer value by numeric hash value | |
| int | ht_get_string (HASH_TABLE *table, const char *key, char **val) |
| get a string value from the hash table by key | |
| int | ht_get_table_collision_percentage (HASH_TABLE *table) |
| get the collision percentage of the hash table | |
| char * | ht_node_type (const HASH_NODE *node) |
| return the type of a hash node as a string | |
| int | ht_optimize (HASH_TABLE **table) |
| optimize a hash table by resizing to the optimal size | |
| void | ht_print (HASH_TABLE *table) |
| print the contents of a hash table | |
| int | ht_put_double (HASH_TABLE *table, const char *key, double value) |
| put a double value into the hash table | |
| int | ht_put_int (HASH_TABLE *table, const char *key, int64_t value) |
| put an integer value into the hash table | |
| int | ht_put_ptr (HASH_TABLE *table, const char *key, void *ptr, void(*destructor)(void *ptr), void *(*duplicator)(void *ptr)) |
| put a pointer value into the hash table with destructor and duplicator | |
| int | ht_put_ptr_ex (HASH_TABLE *table, HASH_VALUE hash_value, void *val, void(*destructor)(void *ptr), void *(*duplicator)(void *ptr)) |
| put a pointer value by numeric hash value | |
| int | ht_put_string (HASH_TABLE *table, const char *key, char *string) |
| put a string value (duplicated) into the hash table | |
| int | ht_put_string_ptr (HASH_TABLE *table, const char *key, char *string) |
| put a string pointer into the hash table without copying | |
| int | ht_remove (HASH_TABLE *table, const char *key) |
| remove a node from the hash table by key | |
| int | ht_remove_ex (HASH_TABLE *table, HASH_VALUE hash_value) |
| remove a node by numeric hash value | |
| int | ht_resize (HASH_TABLE **table, size_t size) |
| resize a hash table to the given size | |
| LIST * | ht_search (HASH_TABLE *table, int(*node_is_matching)(HASH_NODE *node)) |
| search the hash table for nodes matching a predicate | |
| int | is_prime (size_t nb) |
| check if a number is prime | |
| void | MurmurHash3_x64_128 (const void *key, const size_t len, const uint64_t seed, void *out) |
| compute a 128-bit MurmurHash3 hash for x64 | |
| void | MurmurHash3_x86_128 (const void *key, const size_t len, const uint32_t seed, void *out) |
| compute a 128-bit MurmurHash3 hash for x86 | |
| void | MurmurHash3_x86_32 (const void *key, const size_t len, const uint32_t seed, void *out) |
| compute a 32-bit MurmurHash3 hash | |
| HASH_TABLE * | new_ht (size_t size) |
| create a new classic hash table of the given size | |
| HASH_TABLE * | new_ht_trie (size_t alphabet_size, size_t alphabet_offset) |
| create a new trie hash table with the given alphabet size and offset | |
| size_t | next_prime (size_t nb) |
| return the next prime number greater than or equal to nb | |
| union HASH_DATA |
| struct HASH_NODE |
Collaboration diagram for HASH_NODE:Data Fields | |
| size_t | alphabet_length |
| HASH_TRIE mode: size of alphabet and so size of children allocated array. | |
| struct HASH_NODE ** | children |
| HASH_TRIE mode: pointers to children. | |
| union HASH_DATA | data |
| data inside the node | |
| void(* | destroy_func )(void *ptr) |
| destroy_func | |
| void *(* | duplicate_func )(void *ptr) |
| duplicator_func | |
| HASH_VALUE | hash_value |
| numeric key of the node if any, else < 0 | |
| int | is_leaf |
| HASH_TRIE mode: does it have a value. | |
| char * | key |
| string key of the node if any, else NULL | |
| char | key_id |
| key id of the node if any | |
| int | need_rehash |
| flag to mark a node for rehash | |
| int | type |
| type of the node | |
| size_t HASH_NODE::alphabet_length |
HASH_TRIE mode: size of alphabet and so size of children allocated array.
Definition at line 133 of file n_hash.h.
Referenced by _ht_depth_first_search(), _ht_new_node(), _ht_new_node_trie(), _ht_node_destroy(), and _ht_search_trie_helper().
| struct HASH_NODE** HASH_NODE::children |
HASH_TRIE mode: pointers to children.
Definition at line 131 of file n_hash.h.
Referenced by _ht_check_trie_divergence(), _ht_depth_first_search(), _ht_get_node_trie(), _ht_is_leaf_node_trie(), _ht_new_node(), _ht_new_node_trie(), _ht_node_destroy(), _ht_print_trie_helper(), _ht_put_double_trie(), _ht_put_int_trie(), _ht_put_ptr_trie(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _ht_remove_trie(), _ht_search_trie_helper(), and ht_get_completion_list().
| union HASH_DATA HASH_NODE::data |
data inside the node
Definition at line 121 of file n_hash.h.
Referenced by _ht_get_double(), _ht_get_double_trie(), _ht_get_int(), _ht_get_int_trie(), _ht_get_ptr(), _ht_get_ptr_trie(), _ht_get_string(), _ht_get_string_trie(), _ht_new_double_node(), _ht_new_int_node(), _ht_new_node(), _ht_new_node_trie(), _ht_new_ptr_node(), _ht_new_string_node(), _ht_new_string_ptr_node(), _ht_node_destroy(), _ht_print_trie_helper(), _ht_put_double(), _ht_put_double_trie(), _ht_put_int(), _ht_put_int_trie(), _ht_put_ptr(), _ht_put_ptr_trie(), _ht_put_string(), _ht_put_string_ptr(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _n_nodup_log(), _n_nodup_log_indexed(), check_n_log_dup(), check_n_log_dup_indexed(), dump_nodup_log(), ht_duplicate(), ht_get_ptr_ex(), and ht_put_ptr_ex().
| void(* HASH_NODE::destroy_func) (void *ptr) |
destroy_func
Definition at line 123 of file n_hash.h.
Referenced by _ht_new_node(), _ht_new_node_trie(), _ht_new_ptr_node(), _ht_node_destroy(), _ht_put_ptr(), _ht_put_ptr_trie(), ht_duplicate(), and ht_put_ptr_ex().
| void *(* HASH_NODE::duplicate_func) (void *ptr) |
duplicator_func
Definition at line 125 of file n_hash.h.
Referenced by _ht_new_ptr_node(), _ht_put_ptr(), _ht_put_ptr_trie(), ht_duplicate(), and ht_put_ptr_ex().
| HASH_VALUE HASH_NODE::hash_value |
numeric key of the node if any, else < 0
Definition at line 117 of file n_hash.h.
Referenced by _ht_new_node(), _ht_new_node_trie(), _ht_put_double(), _ht_put_int(), _ht_put_ptr(), _ht_put_string(), _ht_put_string_ptr(), ht_get_node_ex(), ht_put_ptr_ex(), ht_remove_ex(), and ht_resize().
| int HASH_NODE::is_leaf |
HASH_TRIE mode: does it have a value.
Definition at line 127 of file n_hash.h.
Referenced by _ht_depth_first_search(), _ht_get_double_trie(), _ht_get_int_trie(), _ht_get_ptr_trie(), _ht_get_string_trie(), _ht_is_leaf_node_trie(), _ht_new_node(), _ht_new_node_trie(), _ht_print_trie_helper(), _ht_put_double_trie(), _ht_put_int_trie(), _ht_put_ptr_trie(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), and _ht_search_trie_helper().
| char* HASH_NODE::key |
string key of the node if any, else NULL
Definition at line 113 of file n_hash.h.
Referenced by _ht_depth_first_search(), _ht_get_node(), _ht_new_node(), _ht_new_node_trie(), _ht_node_destroy(), _ht_print(), _ht_print_trie_helper(), _ht_put_double(), _ht_put_double_trie(), _ht_put_int(), _ht_put_int_trie(), _ht_put_ptr(), _ht_put_ptr_trie(), _ht_put_string(), _ht_put_string_ptr(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _ht_remove(), _ht_search(), _ht_search_trie_helper(), ht_duplicate(), ht_get_completion_list(), ht_put_ptr_ex(), and main().
| char HASH_NODE::key_id |
key id of the node if any
Definition at line 115 of file n_hash.h.
Referenced by _ht_new_node(), and _ht_new_node_trie().
| int HASH_NODE::need_rehash |
flag to mark a node for rehash
Definition at line 129 of file n_hash.h.
Referenced by _ht_new_node(), _ht_new_node_trie(), and ht_resize().
| int HASH_NODE::type |
type of the node
Definition at line 119 of file n_hash.h.
Referenced by _ht_get_double(), _ht_get_double_trie(), _ht_get_int(), _ht_get_int_trie(), _ht_get_ptr(), _ht_get_ptr_trie(), _ht_get_string(), _ht_get_string_trie(), _ht_new_double_node(), _ht_new_int_node(), _ht_new_ptr_node(), _ht_new_string_node(), _ht_new_string_ptr_node(), _ht_node_destroy(), _ht_print_trie_helper(), _ht_put_double(), _ht_put_double_trie(), _ht_put_int(), _ht_put_int_trie(), _ht_put_ptr(), _ht_put_ptr_trie(), _ht_put_string(), _ht_put_string_ptr(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), ht_duplicate(), ht_get_ptr_ex(), ht_node_type(), and ht_put_ptr_ex().
| struct HASH_TABLE |
structure of a hash table
Collaboration diagram for HASH_TABLE:Data Fields | |
| size_t | alphabet_length |
| HASH_TRIE mode: size of the alphabet. | |
| size_t | alphabet_offset |
| HASH_TRIE mode: offset to deduce to individual key digits. | |
| int(* | destroy_ht )(struct HASH_TABLE **table) |
| destroy a hash table | |
| int(* | empty_ht )(struct HASH_TABLE *table) |
| empty a hash table. | |
| LIST ** | hash_table |
| HASH_CLASSIC mode: preallocated hash table. | |
| int(* | ht_get_double )(struct HASH_TABLE *table, const char *key, double *val) |
| get a double from a key's node | |
| int(* | ht_get_int )(struct HASH_TABLE *table, const char *key, int64_t *val) |
| get an int from a key's node | |
| HASH_NODE *(* | ht_get_node )(struct HASH_TABLE *table, const char *key) |
| get HASH_NODE at 'key' from table | |
| int(* | ht_get_ptr )(struct HASH_TABLE *table, const char *key, void **val) |
| get a pointer from a key's node | |
| int(* | ht_get_string )(struct HASH_TABLE *table, const char *key, char **val) |
| get a char *string from a key's node | |
| void(* | ht_print )(struct HASH_TABLE *table) |
| print table | |
| int(* | ht_put_double )(struct HASH_TABLE *table, const char *key, double val) |
| put a double | |
| int(* | ht_put_int )(struct HASH_TABLE *table, const char *key, int64_t val) |
| put an integer | |
| int(* | ht_put_ptr )(struct HASH_TABLE *table, const char *key, void *ptr, void(*destructor)(void *ptr), void *(*duplicator)(void *ptr)) |
| put a a pointer | |
| int(* | ht_put_string )(struct HASH_TABLE *table, const char *key, char *val) |
| put an char *string | |
| int(* | ht_put_string_ptr )(struct HASH_TABLE *table, const char *key, char *val) |
| put an char *string pointer | |
| int(* | ht_remove )(struct HASH_TABLE *table, const char *key) |
| remove given's key node from the table | |
| LIST *(* | ht_search )(struct HASH_TABLE *table, int(*node_is_matching)(HASH_NODE *node)) |
| search elements given an expression | |
| unsigned int | mode |
| hashing mode, murmurhash and classic HASH_MURMUR, or HASH_TRIE | |
| size_t | nb_keys |
| total number of used keys in the table | |
| HASH_NODE * | root |
| HASH_TRIE mode: Start of tree. | |
| size_t | seed |
| table's seed | |
| size_t | size |
| size of the hash table | |
| size_t HASH_TABLE::alphabet_length |
HASH_TRIE mode: size of the alphabet.
Definition at line 149 of file n_hash.h.
Referenced by _ht_check_trie_divergence(), _ht_get_node_trie(), _ht_is_leaf_node_trie(), _ht_new_node_trie(), _ht_print_trie_helper(), _ht_put_double_trie(), _ht_put_int_trie(), _ht_put_ptr_trie(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _ht_remove_trie(), ht_get_completion_list(), and new_ht_trie().
| size_t HASH_TABLE::alphabet_offset |
HASH_TRIE mode: offset to deduce to individual key digits.
Definition at line 151 of file n_hash.h.
Referenced by _ht_check_trie_divergence(), _ht_get_node_trie(), _ht_is_leaf_node_trie(), _ht_put_double_trie(), _ht_put_int_trie(), _ht_put_ptr_trie(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _ht_remove_trie(), ht_get_completion_list(), and new_ht_trie().
| int(* HASH_TABLE::destroy_ht) (struct HASH_TABLE **table) |
destroy a hash table
Definition at line 181 of file n_hash.h.
Referenced by new_ht(), and new_ht_trie().
| int(* HASH_TABLE::empty_ht) (struct HASH_TABLE *table) |
empty a hash table.
char *strings are also freed
Definition at line 179 of file n_hash.h.
Referenced by empty_ht(), new_ht(), and new_ht_trie().
| LIST** HASH_TABLE::hash_table |
HASH_CLASSIC mode: preallocated hash table.
Definition at line 145 of file n_hash.h.
Referenced by _empty_ht(), _ht_get_node(), _ht_print(), _ht_put_double(), _ht_put_int(), _ht_put_ptr(), _ht_put_string(), _ht_put_string_ptr(), _ht_remove(), dump_nodup_log(), ht_get_node_ex(), ht_get_table_collision_percentage(), ht_put_ptr_ex(), ht_remove_ex(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_get_double) (struct HASH_TABLE *table, const char *key, double *val) |
get a double from a key's node
Definition at line 169 of file n_hash.h.
Referenced by ht_get_double(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_get_int) (struct HASH_TABLE *table, const char *key, int64_t *val) |
get an int from a key's node
Definition at line 167 of file n_hash.h.
Referenced by ht_get_int(), new_ht(), and new_ht_trie().
| HASH_NODE *(* HASH_TABLE::ht_get_node) (struct HASH_TABLE *table, const char *key) |
get HASH_NODE at 'key' from table
Definition at line 155 of file n_hash.h.
Referenced by ht_get_node(), and new_ht().
| int(* HASH_TABLE::ht_get_ptr) (struct HASH_TABLE *table, const char *key, void **val) |
get a pointer from a key's node
Definition at line 171 of file n_hash.h.
Referenced by ht_get_ptr(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_get_string) (struct HASH_TABLE *table, const char *key, char **val) |
get a char *string from a key's node
Definition at line 173 of file n_hash.h.
Referenced by ht_get_string(), new_ht(), and new_ht_trie().
| void(* HASH_TABLE::ht_print) (struct HASH_TABLE *table) |
print table
Definition at line 183 of file n_hash.h.
Referenced by ht_print(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_put_double) (struct HASH_TABLE *table, const char *key, double val) |
put a double
Definition at line 159 of file n_hash.h.
Referenced by ht_put_double(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_put_int) (struct HASH_TABLE *table, const char *key, int64_t val) |
put an integer
Definition at line 157 of file n_hash.h.
Referenced by ht_put_int(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_put_ptr) (struct HASH_TABLE *table, const char *key, void *ptr, void(*destructor)(void *ptr), void *(*duplicator)(void *ptr)) |
put a a pointer
Definition at line 161 of file n_hash.h.
Referenced by ht_put_ptr(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_put_string) (struct HASH_TABLE *table, const char *key, char *val) |
put an char *string
Definition at line 163 of file n_hash.h.
Referenced by ht_put_string(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_put_string_ptr) (struct HASH_TABLE *table, const char *key, char *val) |
put an char *string pointer
Definition at line 165 of file n_hash.h.
Referenced by ht_put_string_ptr(), new_ht(), and new_ht_trie().
| int(* HASH_TABLE::ht_remove) (struct HASH_TABLE *table, const char *key) |
remove given's key node from the table
Definition at line 175 of file n_hash.h.
Referenced by ht_remove(), new_ht(), and new_ht_trie().
| LIST *(* HASH_TABLE::ht_search) (struct HASH_TABLE *table, int(*node_is_matching)(HASH_NODE *node)) |
search elements given an expression
Definition at line 177 of file n_hash.h.
Referenced by ht_search(), new_ht(), and new_ht_trie().
| unsigned int HASH_TABLE::mode |
hashing mode, murmurhash and classic HASH_MURMUR, or HASH_TRIE
Definition at line 153 of file n_hash.h.
Referenced by ht_duplicate(), ht_get_completion_list(), ht_get_node_ex(), ht_get_optimal_size(), ht_get_ptr_ex(), ht_get_table_collision_percentage(), ht_put_ptr_ex(), ht_remove_ex(), new_ht(), and new_ht_trie().
| size_t HASH_TABLE::nb_keys |
total number of used keys in the table
Definition at line 141 of file n_hash.h.
Referenced by _empty_ht(), _empty_ht_trie(), _ht_put_double(), _ht_put_double_trie(), _ht_put_int(), _ht_put_int_trie(), _ht_put_ptr(), _ht_put_ptr_trie(), _ht_put_string(), _ht_put_string_ptr(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _ht_remove(), _ht_remove_trie(), ht_get_optimal_size(), ht_put_ptr_ex(), ht_remove_ex(), netw_pool_nbclients(), new_ht(), and new_ht_trie().
| HASH_NODE* HASH_TABLE::root |
HASH_TRIE mode: Start of tree.
Definition at line 147 of file n_hash.h.
Referenced by _empty_ht_trie(), _ht_check_trie_divergence(), _ht_get_node_trie(), _ht_is_leaf_node_trie(), _ht_print_trie(), _ht_put_double_trie(), _ht_put_int_trie(), _ht_put_ptr_trie(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _ht_remove_trie(), _ht_search_trie(), ht_get_completion_list(), and new_ht_trie().
| size_t HASH_TABLE::seed |
table's seed
Definition at line 143 of file n_hash.h.
Referenced by _ht_get_node(), _ht_new_node(), _ht_remove(), new_ht(), and new_ht_trie().
| size_t HASH_TABLE::size |
size of the hash table
Definition at line 139 of file n_hash.h.
Referenced by _empty_ht(), _ht_get_node(), _ht_put_double(), _ht_put_int(), _ht_put_ptr(), _ht_put_string(), _ht_put_string_ptr(), _ht_remove(), dump_nodup_log(), ht_duplicate(), ht_get_node_ex(), ht_get_table_collision_percentage(), ht_put_ptr_ex(), ht_remove_ex(), main(), new_ht(), and new_ht_trie().
| #define HASH_CLASSIC 128 |
| #define HASH_DOUBLE 2 |
| #define HASH_INT 1 |
| #define HASH_INT_TYPE int64_t |
| #define HASH_PTR 8 |
| #define HASH_STRING 4 |
| #define HASH_UNKNOWN 16 |
| #define hash_val | ( | node, | |
| type | |||
| ) | ((node && node->ptr) ? ((type*)(((HASH_NODE*)node->ptr)->data.ptr)) : NULL) |
| #define HASH_VAL | ( | node, | |
| type | |||
| ) | ((node && node->data.ptr) ? ((type*)node->data.ptr) : NULL) |
| #define ht_foreach | ( | __ITEM_, | |
| __HASH_ | |||
| ) |
ForEach macro helper (classic / old)
| #define HT_FOREACH | ( | __ITEM_, | |
| __HASH_, | |||
| ... | |||
| ) |
ForEach macro helper.
| #define HT_FOREACH_R | ( | __ITEM_, | |
| __HASH_, | |||
| __ITERATOR, | |||
| ... | |||
| ) |
ForEach macro helper.
| #define ht_foreach_r | ( | __ITEM_, | |
| __HASH_, | |||
| __ITERATOR_ | |||
| ) |
ForEach macro helper, reentrant (classic / old)
| #define MurmurHash | ( | __key, | |
| __len, | |||
| __seed, | |||
| __out | |||
| ) | MurmurHash3_x64_128(__key, __len, __seed, __out) |
| typedef size_t HASH_VALUE |
| int destroy_ht | ( | HASH_TABLE ** | table | ) |
destroy a hash table and free all resources
destroy a hash table and free all resources
| table | targeted hash table |
Definition at line 2234 of file n_hash.c.
References __n_assert.
Referenced by close_nodup_log(), destroy_config_file_section(), handle_request(), ht_duplicate(), main(), main(), n_gui_destroy_ctx(), and netw_destroy_pool().
Here is the caller graph for this function:| int empty_ht | ( | HASH_TABLE * | table | ) |
empty a hash table, freeing all nodes
empty a hash table, freeing all nodes
| table | targeted hash table |
Definition at line 2224 of file n_hash.c.
References __n_assert, and empty_ht.
Referenced by empty_nodup_table(), and main().
Here is the caller graph for this function:| HASH_TABLE * ht_duplicate | ( | HASH_TABLE * | table | ) |
duplicate a hash table
duplicate a hash table
| table | the HASH_TABLE *table to duplicate |
Definition at line 2636 of file n_hash.c.
References __n_assert, HASH_NODE::data, HASH_NODE::destroy_func, destroy_ht(), HASH_NODE::duplicate_func, HASH_DATA::fval, HASH_CLASSIC, HASH_DOUBLE, HASH_INT, HASH_PTR, HASH_STRING, ht_foreach, ht_put_double(), ht_put_int(), ht_put_ptr(), ht_put_string(), HASH_DATA::ival, HASH_NODE::key, LOG_ERR, mode, n_log, new_ht(), HASH_DATA::ptr, size, HASH_DATA::string, and HASH_NODE::type.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * ht_get_completion_list | ( | HASH_TABLE * | table, |
| const char * | keybud, | ||
| size_t | max_results | ||
| ) |
get a list of key completions matching the given prefix
get a list of key completions matching the given prefix
| table | targeted hash table |
| keybud | starting characters of the keys we want |
| max_results | maximum number of matching keys in list. From UNLIMITED_LIST_ITEMS (0) to MAX_LIST_ITEMS (SIZE_MAX). |
Definition at line 2391 of file n_hash.c.
References __n_assert, _ht_depth_first_search(), _ht_get_node_trie(), alphabet_length, alphabet_offset, HASH_NODE::children, Free, HASH_CLASSIC, HASH_TRIE, ht_foreach, key, HASH_NODE::key, list_destroy(), list_push(), LOG_ERR, max_results, mode, n_log, LIST::nb_items, new_generic_list(), and root.
Referenced by main(), and update_completion().
Here is the call graph for this function:
Here is the caller graph for this function:| int ht_get_double | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| double * | val | ||
| ) |
get a double value from the hash table by key
get a double value from the hash table by key
| table | targeted table |
| key | key to retrieve |
| val | pointer to double storage |
Definition at line 2074 of file n_hash.c.
References __n_assert, ht_get_double, and key.
Referenced by main().
Here is the caller graph for this function:| int ht_get_int | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| int64_t * | val | ||
| ) |
get an integer value from the hash table by key
get an integer value from the hash table by key
| table | targeted table |
| key | key to retrieve |
| val | pointer to int storage |
Definition at line 2087 of file n_hash.c.
References __n_assert, ht_get_int, and key.
Referenced by main().
Here is the caller graph for this function:| HASH_NODE * ht_get_node | ( | HASH_TABLE * | table, |
| const char * | key | ||
| ) |
get the HASH_NODE associated with the given key
get the HASH_NODE associated with the given key
| table | targeted table |
| key | key to retrieve |
Definition at line 2061 of file n_hash.c.
References __n_assert, ht_get_node, and key.
Referenced by _n_nodup_log(), _n_nodup_log_indexed(), check_n_log_dup(), and check_n_log_dup_indexed().
Here is the caller graph for this function:| HASH_NODE * ht_get_node_ex | ( | HASH_TABLE * | table, |
| HASH_VALUE | hash_value | ||
| ) |
get a HASH_NODE by numeric hash value
get a HASH_NODE by numeric hash value
| table | Targeted hash table |
| hash_value | Associated hash_value |
Definition at line 2245 of file n_hash.c.
References __n_assert, HASH_CLASSIC, hash_table, HASH_NODE::hash_value, list_foreach, mode, size, and LIST::start.
Referenced by ht_get_ptr_ex().
Here is the caller graph for this function:| size_t ht_get_optimal_size | ( | HASH_TABLE * | table | ) |
compute the optimal size for the hash table
compute the optimal size for the hash table
| table | targeted table |
Definition at line 2501 of file n_hash.c.
References __n_assert, HASH_CLASSIC, is_prime(), LOG_ERR, mode, n_log, nb_keys, and next_prime().
Referenced by ht_optimize(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:| int ht_get_ptr | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| void ** | val | ||
| ) |
get a pointer value from the hash table by key
get a pointer value from the hash table by key
| table | targeted table |
| key | key to retrieve |
| val | pointer to pointer storage |
Definition at line 2100 of file n_hash.c.
References __n_assert, ht_get_ptr, and key.
Referenced by get_config_section_value(), get_nb_config_file_sections_entries(), load_config_file(), main(), main(), n_gui_get_widget(), netw_pool_add(), and update_definitions().
Here is the caller graph for this function:| int ht_get_ptr_ex | ( | HASH_TABLE * | table, |
| HASH_VALUE | hash_value, | ||
| void ** | val | ||
| ) |
get a pointer value by numeric hash value
get a pointer value by numeric hash value
Leave val untouched if key is not found. (HASH_CLASSIC only)
| table | Targeted hash table |
| hash_value | key pre computed numeric hash value |
| val | A pointer to an empty pointer store |
Definition at line 2270 of file n_hash.c.
References __n_assert, HASH_NODE::data, HASH_CLASSIC, HASH_PTR, ht_get_node_ex(), ht_node_type(), LOG_ERR, mode, n_log, HASH_DATA::ptr, and HASH_NODE::type.
Here is the call graph for this function:| int ht_get_string | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| char ** | val | ||
| ) |
get a string value from the hash table by key
get a string value from the hash table by key
| table | targeted table |
| key | key to retrieve |
| val | pointer to string storage |
Definition at line 2113 of file n_hash.c.
References __n_assert, ht_get_string, and key.
Referenced by main(), and n_str_template_expand().
Here is the caller graph for this function:| int ht_get_table_collision_percentage | ( | HASH_TABLE * | table | ) |
get the collision percentage of the hash table
get the collision percentage of the hash table
| table | targeted table |
Definition at line 2477 of file n_hash.c.
References __n_assert, HASH_CLASSIC, hash_table, LOG_ERR, mode, n_log, LIST::nb_items, and size.
Referenced by ht_optimize(), and main().
Here is the caller graph for this function:| char * ht_node_type | ( | const HASH_NODE * | node | ) |
return the type of a hash node as a string
return the type of a hash node as a string
| node | node to check |
Definition at line 1316 of file n_hash.c.
References __n_assert, HASH_DOUBLE, HASH_INT, HASH_PTR, HASH_STRING, and HASH_NODE::type.
Referenced by _ht_get_double(), _ht_get_double_trie(), _ht_get_int(), _ht_get_int_trie(), _ht_get_ptr(), _ht_get_ptr_trie(), _ht_get_string(), _ht_get_string_trie(), _ht_put_double(), _ht_put_int(), _ht_put_ptr(), _ht_put_string(), _ht_put_string_ptr(), ht_get_ptr_ex(), and ht_put_ptr_ex().
Here is the caller graph for this function:| int ht_optimize | ( | HASH_TABLE ** | table | ) |
optimize a hash table by resizing to the optimal size
optimize a hash table by resizing to the optimal size
| table | targeted table |
Definition at line 2602 of file n_hash.c.
References __n_assert, HASH_CLASSIC, ht_get_optimal_size(), ht_get_table_collision_percentage(), ht_resize(), LOG_ERR, and n_log.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void ht_print | ( | HASH_TABLE * | table | ) |
print the contents of a hash table
print the contents of a hash table
| table | targeted hash table |
Definition at line 2202 of file n_hash.c.
References __n_assert, and ht_print.
| int ht_put_double | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| double | value | ||
| ) |
put a double value into the hash table
put a double value into the hash table
| table | targeted table |
| key | key to retrieve |
| value | double value to put |
Definition at line 2126 of file n_hash.c.
References __n_assert, ht_put_double, and key.
Referenced by ht_duplicate(), and main().
Here is the caller graph for this function:| int ht_put_int | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| int64_t | value | ||
| ) |
put an integer value into the hash table
put an integer value into the hash table
| table | targeted hash table |
| key | associated value's key |
| value | integral value to put |
Definition at line 2139 of file n_hash.c.
References __n_assert, ht_put_int, and key.
Referenced by ht_duplicate(), and main().
Here is the caller graph for this function:| int ht_put_ptr | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| void * | ptr, | ||
| void(*)(void *ptr) | destructor, | ||
| void *(*)(void *ptr) | duplicator | ||
| ) |
put a pointer value into the hash table with destructor and duplicator
put a pointer value into the hash table with destructor and duplicator
| table | targeted hash table |
| key | key of the entry |
| ptr | pointer value to put |
| destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't |
| duplicator | Pointer to the ptr type duplicator function. Leave to NULL if there isn't |
Definition at line 2154 of file n_hash.c.
References __n_assert, ht_put_ptr, and key.
Referenced by _register_widget(), ht_duplicate(), load_config_file(), main(), main(), and netw_pool_add().
Here is the caller graph for this function:| int ht_put_ptr_ex | ( | HASH_TABLE * | table, |
| HASH_VALUE | hash_value, | ||
| void * | val, | ||
| void(*)(void *ptr) | destructor, | ||
| void *(*)(void *ptr) | duplicator | ||
| ) |
put a pointer value by numeric hash value
put a pointer value by numeric hash value
| table | targeted hash table |
| hash_value | precomputed hash value for the key |
| val | pointer value to put |
| destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't |
| duplicator | Pointer to the ptr type duplicator function. Leave to NULL if there isn't |
Definition at line 2297 of file n_hash.c.
References __n_assert, _ht_node_destroy(), HASH_NODE::data, HASH_NODE::destroy_func, HASH_NODE::duplicate_func, HASH_CLASSIC, HASH_PTR, hash_table, HASH_NODE::hash_value, ht_node_type(), HASH_NODE::key, list_foreach, list_push(), LOG_ERR, Malloc, mode, n_log, nb_keys, HASH_DATA::ptr, size, and HASH_NODE::type.
Here is the call graph for this function:| int ht_put_string | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| char * | string | ||
| ) |
put a string value (duplicated) into the hash table
put a string value (duplicated) into the hash table
| table | targeted hash table |
| key | associated value's key |
| string | string value to put (copy) |
Definition at line 2167 of file n_hash.c.
References __n_assert, ht_put_string, and key.
Referenced by _n_nodup_log(), _n_nodup_log_indexed(), ht_duplicate(), main(), and netw_parse_post_data().
Here is the caller graph for this function:| int ht_put_string_ptr | ( | HASH_TABLE * | table, |
| const char * | key, | ||
| char * | string | ||
| ) |
put a string pointer into the hash table without copying
put a string pointer into the hash table without copying
| table | targeted hash table |
| key | associated value's key |
| string | string value to put (pointer) |
Definition at line 2180 of file n_hash.c.
References __n_assert, ht_put_string_ptr, and key.
| int ht_remove | ( | HASH_TABLE * | table, |
| const char * | key | ||
| ) |
remove a node from the hash table by key
remove a node from the hash table by key
| table | targeted hash table |
| key | key of node to destroy |
Definition at line 2192 of file n_hash.c.
References __n_assert, ht_remove, and key.
Referenced by main(), and netw_pool_remove().
Here is the caller graph for this function:| int ht_remove_ex | ( | HASH_TABLE * | table, |
| HASH_VALUE | hash_value | ||
| ) |
remove a node by numeric hash value
remove a node by numeric hash value
| table | Targeted hash table |
| hash_value | key pre computed numeric hash value |
Definition at line 2350 of file n_hash.c.
References __n_assert, _ht_node_destroy(), HASH_CLASSIC, hash_table, HASH_NODE::hash_value, list_foreach, LOG_ERR, mode, n_log, nb_keys, remove_list_node, size, and LIST::start.
Here is the call graph for this function:| int ht_resize | ( | HASH_TABLE ** | table, |
| size_t | size | ||
| ) |
resize a hash table to the given size
resize a hash table to the given size
| table | targeted table |
| size | new hash table size |
Definition at line 2520 of file n_hash.c.
References __n_assert, HASH_CLASSIC, HASH_NODE::hash_value, HT_FOREACH, list_destroy(), list_node_push(), list_node_shift(), LOG_ERR, MAX_LIST_ITEMS, n_log, HASH_NODE::need_rehash, new_generic_list(), LIST_NODE::next, LIST_NODE::prev, and Realloc.
Referenced by ht_optimize(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * ht_search | ( | HASH_TABLE * | table, |
| int(*)(HASH_NODE *node) | node_is_matching | ||
| ) |
search the hash table for nodes matching a predicate
search the hash table for nodes matching a predicate
| table | targeted hash table |
| node_is_matching | matching function |
Definition at line 2214 of file n_hash.c.
References __n_assert, and ht_search.
Referenced by main().
Here is the caller graph for this function:| int is_prime | ( | size_t | nb | ) |
check if a number is prime
check if a number is prime
| nb | number to test |
Definition at line 2438 of file n_hash.c.
Referenced by ht_get_optimal_size(), and next_prime().
Here is the caller graph for this function:| void MurmurHash3_x64_128 | ( | const void * | key, |
| const size_t | len, | ||
| const uint64_t | seed, | ||
| void * | out | ||
| ) |
compute a 128-bit MurmurHash3 hash for x64
compute a 128-bit MurmurHash3 hash for x64
The author hereby disclaims copyright to this source code. Note - The x86 and x64 versions do not produce the same results, as the algorithms are optimized for their respective platforms. You can still compile and run any of them on any platform, but your performance with the non-native version will be less than optimal.
| key | char *string as the key |
| len | size of the key |
| seed | seed value for murmur hash |
| out | generated hash |
Definition at line 1194 of file n_hash.c.
References FALL_THROUGH, fmix64(), getblock64(), key, and ROTL64.
Here is the call graph for this function:| void MurmurHash3_x86_128 | ( | const void * | key, |
| const size_t | len, | ||
| const uint32_t | seed, | ||
| void * | out | ||
| ) |
compute a 128-bit MurmurHash3 hash for x86
compute a 128-bit MurmurHash3 hash for x86
The author hereby disclaims copyright to this source code. Note - The x86 and x64 versions do not produce the same results, as the algorithms are optimized for their respective platforms. You can still compile and run any of them on any platform, but your performance with the non-native version will be less than optimal.
| key | char *string as the key |
| len | size of the key |
| seed | seed value for murmur hash |
| out | generated hash |
Definition at line 1026 of file n_hash.c.
References FALL_THROUGH, fmix32(), getblock32(), key, and ROTL32.
Here is the call graph for this function:| void MurmurHash3_x86_32 | ( | const void * | key, |
| const size_t | len, | ||
| const uint32_t | seed, | ||
| void * | out | ||
| ) |
compute a 32-bit MurmurHash3 hash
compute a 32-bit MurmurHash3 hash
The author hereby disclaims copyright to this source code. Note - The x86 and x64 versions do not produce the same results, as the algorithms are optimized for their respective platforms. You can still compile and run any of them on any platform, but your performance with the non-native version will be less than optimal.
| key | char *string as the key |
| len | size of the key |
| seed | seed value for murmur hash |
| out | generated hash |
Definition at line 968 of file n_hash.c.
References FALL_THROUGH, fmix32(), getblock32(), key, and ROTL32.
Here is the call graph for this function:| HASH_TABLE * new_ht | ( | size_t | size | ) |
create a new classic hash table of the given size
create a new classic hash table of the given size
| size | Size of the root hash node table |
Definition at line 2001 of file n_hash.c.
References __n_assert, _destroy_ht(), _empty_ht(), _ht_get_double(), _ht_get_int(), _ht_get_node(), _ht_get_ptr(), _ht_get_string(), _ht_print(), _ht_put_double(), _ht_put_int(), _ht_put_ptr(), _ht_put_string(), _ht_put_string_ptr(), _ht_remove(), _ht_search(), destroy_ht, empty_ht, Free, HASH_CLASSIC, hash_table, ht_get_double, ht_get_int, ht_get_node, ht_get_ptr, ht_get_string, ht_print, ht_put_double, ht_put_int, ht_put_ptr, ht_put_string, ht_put_string_ptr, ht_remove, ht_search, list_destroy(), LOG_ERR, Malloc, MAX_LIST_ITEMS, mode, n_log, nb_keys, new_generic_list(), seed, and size.
Referenced by ht_duplicate(), init_nodup_log(), load_config_file(), main(), n_gui_new_ctx(), netw_new_pool(), and netw_parse_post_data().
Here is the call graph for this function:
Here is the caller graph for this function:| HASH_TABLE * new_ht_trie | ( | size_t | alphabet_length, |
| size_t | alphabet_offset | ||
| ) |
create a new trie hash table with the given alphabet size and offset
create a new trie hash table with the given alphabet size and offset
| alphabet_length | of the alphabet |
| alphabet_offset | offset of each character in a key (i.e: to have 'a->z' with 'a' starting at zero, offset must be 32. |
Definition at line 1955 of file n_hash.c.
References __n_assert, _destroy_ht_trie(), _empty_ht_trie(), _ht_get_double_trie(), _ht_get_int_trie(), _ht_get_ptr_trie(), _ht_get_string_trie(), _ht_new_node_trie(), _ht_print_trie(), _ht_put_double_trie(), _ht_put_int_trie(), _ht_put_ptr_trie(), _ht_put_string_ptr_trie(), _ht_put_string_trie(), _ht_remove_trie(), _ht_search_trie(), alphabet_length, alphabet_offset, destroy_ht, empty_ht, Free, hash_table, HASH_TRIE, ht_get_double, ht_get_int, ht_get_ptr, ht_get_string, ht_print, ht_put_double, ht_put_int, ht_put_ptr, ht_put_string, ht_put_string_ptr, ht_remove, ht_search, LOG_ERR, Malloc, mode, n_log, nb_keys, root, seed, and size.
Referenced by main(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:| size_t next_prime | ( | size_t | nb | ) |
return the next prime number greater than or equal to nb
return the next prime number greater than or equal to nb
| nb | number to test |
Definition at line 2460 of file n_hash.c.
References is_prime(), and next_prime().
Referenced by ht_get_optimal_size(), and next_prime().
Here is the call graph for this function:
Here is the caller graph for this function: