Nilorea Library
C utilities for networking, threading, graphics
|
Hash functions and table. More...
Go to the source code of this file.
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. More... | |
#define | HASH_DOUBLE 2 |
value of double type inside the hash node More... | |
#define | HASH_INT 1 |
compatibility with existing rot func More... | |
#define | HASH_PTR 8 |
value of pointer type inside the hash node More... | |
#define | HASH_STRING 4 |
value of char * type inside the hash node More... | |
#define | HASH_TRIE 256 |
TRIE tree using hash key string. More... | |
#define | HASH_UNKNOWN 16 |
value of unknow type inside the hash node More... | |
#define | hash_val(node, type) ( (node && node -> ptr) ? ( (type *)( ( (HASH_NODE *)node -> ptr )-> data . ptr) ) : NULL ) |
Cast a HASH_NODE element. More... | |
#define | HASH_VAL(node, type) ( (node && node -> data . ptr) ? ( (type *)node -> data . ptr ) : NULL ) |
Cast a HASH_NODE element. More... | |
#define | ht_foreach(__ITEM_, __HASH_) |
ForEach macro helper (classic / old) More... | |
#define | HT_FOREACH(__ITEM_, __HASH_, ...) |
ForEach macro helper. More... | |
#define | HT_FOREACH_R(__ITEM_, __HASH_, __ITERATOR, ...) |
ForEach macro helper. More... | |
#define | ht_foreach_r(__ITEM_, __HASH_, __ITERATOR_) |
ForEach macro helper, reentrant (classic / old) More... | |
#define | MurmurHash(__key, __len, __seed, __out) MurmurHash3_x64_128( __key, __len, __seed, __out ) |
Murmur hash macro helper 64 bits. More... | |
Typedefs | |
typedef size_t | HASH_VALUE |
type of a HASH_VALUE More... | |
Functions | |
int | destroy_ht (HASH_TABLE **table) |
empty a table and destroy it More... | |
int | empty_ht (HASH_TABLE *table) |
empty a table More... | |
LIST * | ht_get_completion_list (HASH_TABLE *table, const char *keybud, size_t max_results) |
get next matching keys in table tree More... | |
int | ht_get_double (HASH_TABLE *table, const char *key, double *val) |
get double at 'key' from 'table' More... | |
int | ht_get_int (HASH_TABLE *table, const char *key, int *val) |
get node at 'key' from 'table' More... | |
HASH_NODE * | ht_get_node (HASH_TABLE *table, const char *key) |
get node at 'key' from 'table' More... | |
HASH_NODE * | ht_get_node_ex (HASH_TABLE *table, HASH_VALUE hash_value) |
return the associated key's node inside the hash_table (HASH_CLASSIC only) More... | |
int | ht_get_optimal_size (HASH_TABLE *table) |
get optimal array size based on nb=(number_of_key*1.3) && if( !isprime(nb) )nb=nextprime(nb) (HASH_CLASSIC mode only) More... | |
int | ht_get_ptr (HASH_TABLE *table, const char *key, void **val) |
get pointer at 'key' from 'table' More... | |
int | ht_get_ptr_ex (HASH_TABLE *table, HASH_VALUE hash_value, void **val) |
Retrieve a pointer value in the hash table, at the given key. More... | |
int | ht_get_string (HASH_TABLE *table, const char *key, char **val) |
get string at 'key' from 'table' More... | |
int | ht_get_table_collision_percentage (HASH_TABLE *table) |
get table collision percentage (HASH_CLASSIC mode only) More... | |
char * | ht_node_type (HASH_NODE *node) |
get the type of a node , text version More... | |
int | ht_optimize (HASH_TABLE **table) |
try an automatic optimization of the table More... | |
void | ht_print (HASH_TABLE *table) |
print contents of table More... | |
int | ht_put_double (HASH_TABLE *table, const char *key, double value) |
put a double value with given key in the targeted hash table More... | |
int | ht_put_int (HASH_TABLE *table, const char *key, int value) |
put an integral value with given key in the targeted hash table More... | |
int | ht_put_ptr (HASH_TABLE *table, const char *key, void *ptr, void(*destructor)(void *ptr)) |
put a pointer to the string value with given key in the targeted hash table More... | |
int | ht_put_ptr_ex (HASH_TABLE *table, HASH_VALUE hash_value, void *val, void(*destructor)(void *ptr)) |
put a pointer value with given key in the targeted hash table (HASH_CLASSIC only) More... | |
int | ht_put_string (HASH_TABLE *table, const char *key, char *string) |
put a string value (copy/dup) with given key in the targeted hash table More... | |
int | ht_put_string_ptr (HASH_TABLE *table, const char *key, char *string) |
put a string value (pointer) with given key in the targeted hash table More... | |
int | ht_remove (HASH_TABLE *table, const char *key) |
remove and delete node at key in table More... | |
int | ht_remove_ex (HASH_TABLE *table, HASH_VALUE hash_value) |
Remove a key from a hash table (HASH_CLASSIC only) More... | |
int | ht_resize (HASH_TABLE **table, size_t size) |
rehash table according to size (HASH_CLASSIC mode only) More... | |
LIST * | ht_search (HASH_TABLE *table, int(*node_is_matching)(HASH_NODE *node)) |
seach table for matching nodes More... | |
int | is_prime (int nb) |
test if number is a prime number or not More... | |
void | MurmurHash3_x64_128 (const void *key, const size_t len, const uint64_t seed, void *out) |
MurmurHash3 was written by Austin Appleby, and is placed in the public domain. More... | |
void | MurmurHash3_x86_128 (const void *key, int len, uint32_t seed, void *out) |
MurmurHash3 was written by Austin Appleby, and is placed in the public domain. More... | |
void | MurmurHash3_x86_32 (const void *key, int len, uint32_t seed, void *out) |
MurmurHash3 was written by Austin Appleby, and is placed in the public domain. More... | |
HASH_TABLE * | new_ht (size_t size) |
Create a hash table with the given size. More... | |
HASH_TABLE * | new_ht_trie (size_t alphabet_size, size_t alphabet_offset) |
create a TRIE hash table with the alphabet_size, each key value beeing decreased by alphabet_offset More... | |
int | next_prime (int nb) |
compute next prime number after nb More... | |