127 #ifndef __TOMMYHASHTBL_H
128 #define __TOMMYHASHTBL_H
213 if (i->
key == hash && cmp(cmp_arg, i->
data) == 0)
270 return hashtable->
count;
tommy_size_t tommy_hashtable_memory_usage(tommy_hashtable *hashtable)
Gets the size of allocated memory.
tommy_count_t count
Number of elements.
Definition: tommyhashtbl.h:149
tommy_uint32_t tommy_count_t
Generic unsigned integer for counting objects.
Definition: tommytypes.h:67
struct tommy_node_struct * next
Next node.
Definition: tommytypes.h:188
void tommy_hashtable_init(tommy_hashtable *hashtable, tommy_count_t bucket_max)
Initializes the hashtable.
tommy_key_t tommy_hash_t
Hash type used in hashtables.
Definition: tommyhash.h:43
void tommy_hashtable_insert(tommy_hashtable *hashtable, tommy_hashtable_node *node, void *data, tommy_hash_t hash)
Inserts an element in the hashtable.
Hashtable container type.
Definition: tommyhashtbl.h:145
int tommy_search_func(const void *arg, const void *obj)
Search function for elements.
Definition: tommytypes.h:278
tommy_count_t bucket_mask
Bit mask to access the buckets.
Definition: tommyhashtbl.h:148
void * tommy_hashtable_search(tommy_hashtable *hashtable, tommy_search_func *cmp, const void *cmp_arg, tommy_hash_t hash)
Searches an element in the hashtable.
Definition: tommyhashtbl.h:207
tommy_hashtable_node * tommy_hashtable_bucket(tommy_hashtable *hashtable, tommy_hash_t hash)
Gets the bucket of the specified hash.
Definition: tommyhashtbl.h:192
void * tommy_hashtable_remove_existing(tommy_hashtable *hashtable, tommy_hashtable_node *node)
Removes an element from the hashtable.
void tommy_hashtable_foreach_arg(tommy_hashtable *hashtable, tommy_foreach_arg_func *func, void *arg)
Calls the specified function with an argument for each element in the hashtable.
tommy_hashtable_node ** bucket
Hash buckets.
Definition: tommyhashtbl.h:146
tommy_count_t bucket_max
Number of buckets.
Definition: tommyhashtbl.h:147
void tommy_hashtable_done(tommy_hashtable *hashtable)
Deinitializes the hashtable.
Data structure node.
Definition: tommytypes.h:183
void tommy_foreach_func(void *obj)
Foreach function.
Definition: tommytypes.h:289
tommy_count_t tommy_hashtable_count(tommy_hashtable *hashtable)
Gets the number of elements.
Definition: tommyhashtbl.h:268
void * data
Pointer to the object containing the node.
Definition: tommytypes.h:200
Hash functions for the use with tommy_hashtable, tommy_hashdyn and tommy_hashlin. ...
tommy_node tommy_hashtable_node
Hashtable node.
Definition: tommyhashtbl.h:139
size_t tommy_size_t
Generic size_t type.
Definition: tommytypes.h:50
void * tommy_hashtable_remove(tommy_hashtable *hashtable, tommy_search_func *cmp, const void *cmp_arg, tommy_hash_t hash)
Searches and removes an element from the hashtable.
struct tommy_hashtable_struct tommy_hashtable
Hashtable container type.
tommy_key_t key
Key used to store the node.
Definition: tommytypes.h:207
void tommy_hashtable_foreach(tommy_hashtable *hashtable, tommy_foreach_func *func)
Calls the specified function for each element in the hashtable.
void tommy_foreach_arg_func(void *arg, void *obj)
Foreach function with an argument.
Definition: tommytypes.h:296