#include <lib/utils/include/hashtable.h>
Data Fields | |
uint32_t | alloced |
uint32_t | nentries |
linked_list_t * | buckets |
int(* | cmp_func )(const void *const key_a, const void *const key_b) |
uint32_t(* | hash_func )(const void *const key) |
This structure defines a simple generic hashtable. It can store any type of elements, provided that suitable comparison and hash functions exist for the type of the keys used.
This hashtable implementation uses a simple sequential search in a linked list to solve the collisions.
Definition at line 59 of file hashtable.h.
uint32_t struct_hashtable_t::alloced |
Number of allocated buckets (always a power of two).
Definition at line 63 of file hashtable.h.
uint32_t struct_hashtable_t::nentries |
Current number of entries in the hashtable.
Definition at line 67 of file hashtable.h.
Array of linked_list_t
of size alloced
used to store the hashtable's entries.
Definition at line 72 of file hashtable.h.
int(* struct_hashtable_t::cmp_func)(const void *const key_a, const void *const key_b) |
Pointer to a comparison function for the keys stored in the hashtable. The function's signature should be: int cmp_func(const void* const, const void* const)
. The function should take two keys of identical type passed as pointers to void
.
For now, the only requirement if that the pointed function should return 0 if two identical keys are compared.
uint32_t(* struct_hashtable_t::hash_func)(const void *const key) |
Pointer to the hash function used by the hashtable. The hash function's signature should be: uint32_t hash_func(const void* const)
. The function should take a key passed as a pointer to void
.
Needless to say, the real type of the key handled by this function should be the same as the one handled by the comparison function pointed by cmp_int
.