56#define HMAP_MASK (HMAP_BR - 1u)
57#define HMAP_HASH_SIZE 32u
58#define HMAP_HASH_TYPE uint32_t
59#define HMAP_BITMAP_TYPE uint32_t
121[[nodiscard]] [[gnu::nonnull(1, 2, 3)]]
hmap_t
126[[nodiscard]] [[gnu::nonnull(1, 2, 3)]]
135[[nodiscard]] [[gnu::nonnull(1, 2, 3)]]
137 void *default_value);
143 void *default_value);
151[[gnu::nonnull(1, 2)]]
hmap_control_t hmap_default_control
hmap_t hmap_empty(srn_context_t *ctx)
Create, initialize and return a new hashmap.
void * hmap_lookup(srn_context_t *ctx, const hmap_t *hmap, const hmap_key_t *k, void *default_value)
Lookup the given k in the given hmap and return the value if it's been found.
hmap_hash_t hmap_hash(srn_context_t *ctx, const void *data, size_t len)
This is a simple hack to mock the hash function during tests to force a high collision hashing functi...
hmap_t hmap_insert(srn_context_t *ctx, const hmap_t *hmap, hmap_key_t *k, void *v)
Insert the given key k with the value v in the given hash hmap and return the new map.
void * hmap_lookup_ctl(const hmap_control_t *ctl, srn_context_t *ctx, const hmap_t *hmap, const hmap_key_t *k, void *default_value)
Just like the hmap_lookup function but, it receives a hmap_control_t to customize the comparison and ...
hmap_key_t * hmap_make_key(srn_context_t *ctx, void *data, size_t len)
Create a new key out of the given data, with the given len.
HMAP_BITMAP_TYPE hmap_bitmap_t
HMAP_HASH_TYPE hmap_hash_t
hmap_t hmap_insert_ctl(const hmap_control_t *ctl, srn_context_t *ctx, const hmap_t *hmap, hmap_key_t *k, void *v)
Just like the hmap_insert function but, it receives a hmap_control_t to customize the comparison and ...
If we ever want to modify some of these behaviours for a new instance of hashmap, we should use this ...
hmap_hash_t(* hash)(srn_context_t *ctx, const hmap_key_t *k)
bool(* cmp)(srn_context_t *ctx, const hmap_key_t *a, const hmap_key_t *b)
hmap_t(* insert)(const struct hmap_control_t *ctl, srn_context_t *ctx, const hmap_t *hmap, hmap_key_t *k, void *v)
Note: For key equality we use the memcpy function.
void * data
len 0 -> data == nullptr
hmap_data_t * entries
This is really a (void **) which each entry in the array will be either (mutually exclusive):
size_t len
Number of key/value pairs in the map.