7#ifndef ZEPHYR_INCLUDE_SYS_HASHMAP_API_H_
8#define ZEPHYR_INCLUDE_SYS_HASHMAP_API_H_
84typedef void *(*sys_hashmap_allocator_t)(
void *ptr,
size_t new_size);
214#define SYS_HASHMAP_CONFIG(_max_size, _load_factor) \
216 .max_size = (size_t)_max_size, .load_factor = (uint8_t)_load_factor, \
217 .initial_n_buckets = NHPOT(DIV_ROUND_UP(100, _load_factor)), \
static bool sys_hashmap_iterator_has_next(const struct sys_hashmap_iterator *it)
Check if a Hashmap iterator has a next entry.
Definition hash_map_api.h:68
void(* sys_hashmap_callback_t)(uint64_t key, uint64_t value, void *cookie)
Callback interface for sys_hashmap.
Definition hash_map_api.h:106
bool(* sys_hashmap_remove_t)(struct sys_hashmap *map, uint64_t key, uint64_t *value)
Remove an entry from a sys_hashmap.
Definition hash_map_api.h:149
bool(* sys_hashmap_get_t)(const struct sys_hashmap *map, uint64_t key, uint64_t *value)
Get a value from a sys_hashmap.
Definition hash_map_api.h:163
void(* sys_hashmap_clear_t)(struct sys_hashmap *map, sys_hashmap_callback_t cb, void *cookie)
Clear all entries contained in a sys_hashmap.
Definition hash_map_api.h:117
int(* sys_hashmap_insert_t)(struct sys_hashmap *map, uint64_t key, uint64_t value, uint64_t *old_value)
Insert a new entry into a sys_hashmap.
Definition hash_map_api.h:134
void(* sys_hashmap_iterator_t)(const struct sys_hashmap *map, struct sys_hashmap_iterator *it)
In-place iterator constructor for sys_hashmap.
Definition hash_map_api.h:94
#define bool
Definition stdbool.h:13
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Generic Hashmap API.
Definition hash_map_api.h:168
sys_hashmap_iterator_t iter
Iterator constructor (in-place)
Definition hash_map_api.h:170
sys_hashmap_remove_t remove
Remove a key-value pair from the Hashmap.
Definition hash_map_api.h:176
sys_hashmap_clear_t clear
Clear the hash table, freeing all resources.
Definition hash_map_api.h:172
sys_hashmap_insert_t insert
Insert a key-value pair into the Hashmap.
Definition hash_map_api.h:174
sys_hashmap_get_t get
Retrieve the value associated with a given key from the Hashmap.
Definition hash_map_api.h:178
Generic Hashmap configuration.
Definition hash_map_api.h:197
uint8_t initial_n_buckets
Initial number of buckets to allocate.
Definition hash_map_api.h:203
uint8_t load_factor
Maximum load factor expressed in hundredths.
Definition hash_map_api.h:201
size_t max_size
Maximum number of entries.
Definition hash_map_api.h:199
Generic Hashmap data.
Definition hash_map_api.h:225
size_t n_buckets
The number of buckets currently allocated.
Definition hash_map_api.h:229
size_t size
The number of entries currently in the Hashmap.
Definition hash_map_api.h:231
void * buckets
Pointer for implementation-specific Hashmap storage.
Definition hash_map_api.h:227
Generic Hashmap iterator interface.
Definition hash_map_api.h:44
size_t pos
Number of entries already iterated.
Definition hash_map_api.h:58
const struct sys_hashmap * map
Pointer to the associated Hashmap.
Definition hash_map_api.h:46
void * state
Implementation-specific iterator state.
Definition hash_map_api.h:50
const size_t size
Number of entries in the map.
Definition hash_map_api.h:56
uint64_t key
Key associated with the current entry.
Definition hash_map_api.h:52
void(* next)(struct sys_hashmap_iterator *it)
Modify the iterator in-place to point to the next Hashmap entry.
Definition hash_map_api.h:48
uint64_t value
Value associated with the current entry.
Definition hash_map_api.h:54
Generic Hashmap.
Definition hash_map.h:125