140#ifndef __TOMMYHASHLIN_H
141#define __TOMMYHASHLIN_H
152#define TOMMY_HASHLIN_BIT 6
215 bsr = tommy_ilog2(pos | 1);
217 return &hashlin->
bucket[bsr][pos];
232 if (pos < hashlin->split) {
246 return tommy_hashlin_pos(hashlin, pos);
259 return *tommy_hashlin_bucket_ref(hashlin, hash);
278 if (i->
index == hash && cmp(cmp_arg, i->
data) == 0)
335 return hashlin->
count;
Hashtable container type.
Definition: tommyhashlin.h:164
tommy_uint_t bucket_bit
Bits used in the bit mask.
Definition: tommyhashlin.h:172
tommy_size_t bucket_mask
Bit mask to access the buckets.
Definition: tommyhashlin.h:167
tommy_size_t low_max
Low order max value.
Definition: tommyhashlin.h:168
tommy_size_t low_mask
Low order mask value.
Definition: tommyhashlin.h:169
tommy_size_t split
Split position.
Definition: tommyhashlin.h:170
tommy_size_t bucket_max
Number of buckets.
Definition: tommyhashlin.h:166
tommy_hashlin_node ** bucket[TOMMY_SIZE_BIT]
Dynamic array of hash buckets.
Definition: tommyhashlin.h:165
tommy_size_t count
Number of elements.
Definition: tommyhashlin.h:171
tommy_uint_t state
Reallocation state.
Definition: tommyhashlin.h:173
Data structure node.
Definition: tommytypes.h:211
tommy_size_t index
Index of the node.
Definition: tommytypes.h:236
struct tommy_node_struct * next
Next node.
Definition: tommytypes.h:216
void * data
Pointer to the object containing the node.
Definition: tommytypes.h:228
Hash functions for the use with tommy_hashtable, tommy_hashdyn and tommy_hashlin.
tommy_hashlin_node * tommy_hashlin_bucket(tommy_hashlin *hashlin, tommy_hash_t hash)
Gets the bucket of the specified hash.
Definition: tommyhashlin.h:257
struct tommy_hashlin_struct tommy_hashlin
Hashtable container type.
tommy_size_t tommy_hashlin_count(tommy_hashlin *hashlin)
Gets the number of elements.
Definition: tommyhashlin.h:333
TOMMY_API void tommy_hashlin_foreach_arg(tommy_hashlin *hashlin, tommy_foreach_arg_func *func, void *arg)
Calls the specified function with an argument for each element in the hashtable.
TOMMY_API void tommy_hashlin_insert(tommy_hashlin *hashlin, tommy_hashlin_node *node, void *data, tommy_hash_t hash)
Inserts an element in the hashtable.
TOMMY_API void * tommy_hashlin_remove(tommy_hashlin *hashlin, tommy_search_func *cmp, const void *cmp_arg, tommy_hash_t hash)
Searches and removes an element from the hashtable.
TOMMY_API void tommy_hashlin_foreach(tommy_hashlin *hashlin, tommy_foreach_func *func)
Calls the specified function for each element in the hashtable.
tommy_node tommy_hashlin_node
Hashtable node.
Definition: tommyhashlin.h:158
void * tommy_hashlin_search(tommy_hashlin *hashlin, tommy_search_func *cmp, const void *cmp_arg, tommy_hash_t hash)
Searches an element in the hashtable.
Definition: tommyhashlin.h:272
TOMMY_API void tommy_hashlin_done(tommy_hashlin *hashlin)
Deinitializes the hashtable.
TOMMY_API tommy_size_t tommy_hashlin_memory_usage(tommy_hashlin *hashlin)
Gets the size of allocated memory.
TOMMY_API void tommy_hashlin_init(tommy_hashlin *hashlin)
Initializes the hashtable.
TOMMY_API void * tommy_hashlin_remove_existing(tommy_hashlin *hashlin, tommy_hashlin_node *node)
Removes an element from the hashtable.
uint64_t tommy_size_t
Generic size_t type.
Definition: tommytypes.h:60
void tommy_foreach_func(void *obj)
Foreach function.
Definition: tommytypes.h:318
int tommy_search_func(const void *arg, const void *obj)
Search function for elements.
Definition: tommytypes.h:307
void tommy_foreach_arg_func(void *arg, void *obj)
Foreach function with an argument.
Definition: tommytypes.h:325
tommy_size_t tommy_hash_t
Type used in hashtables to store the hash of an object.
Definition: tommytypes.h:193
tommy_uint32_t tommy_uint_t
Generic unsigned integer type.
Definition: tommytypes.h:80