27 unsigned long (*hash_fn)(
29 int (*cmp_fn)(
void*,
void*);
45 size_t value_size,
unsigned long (*hash_fn)(
void*),
46 int (*cmp_fn)(
void*,
void*));
int hashmap_size(const HashMap *map)
Retrieves the total number of key-value pairs stored in the Hash Map.
Definition hashmap.c:172
void hashmap_init(HashMap *map, size_t bucket_count, size_t key_size, size_t value_size, unsigned long(*hash_fn)(void *), int(*cmp_fn)(void *, void *))
Initializes a Hash Map structure.
Definition hashmap.c:32
void hashmap_destroy(HashMap *map)
Destroys the Hash Map and frees all allocated buckets, nodes, and stored data.
Definition hashmap.c:53
void * hashmap_get(HashMap *map, void *key)
Retrieves the value associated with a given key.
Definition hashmap.c:154
bool hashmap_update(HashMap *map, void *key, const void *new_data)
Updates the value associated with an existing key in the Hash Map.
Definition hashmap.c:135
bool hashmap_remove(HashMap *map, void *key)
Removes a key-value pair from the Hash Map by key.
Definition hashmap.c:105
bool hashmap_insert(HashMap *map, void *key, const void *data)
Inserts a new key-value pair into the Hash Map.
Definition hashmap.c:77
Structure representing a generic Hash Map.
Definition hashmap.h:21
size_t value_size
Definition hashmap.h:25
HashNode ** buckets
Definition hashmap.h:22
size_t key_size
Definition hashmap.h:24
size_t size
Definition hashmap.h:26
size_t bucket_count
Definition hashmap.h:23
Node structure representing a key-value pair in a hash bucket's collision chain.
Definition hashmap.h:11
struct HashNode * next
Definition hashmap.h:14
void * key
Definition hashmap.h:12
void * value
Definition hashmap.h:13