11#define HASHMAP_MAGIC MOS_FOURCC('H', 'M', 'a', 'p')
25 mos_panic(
"hashmap_init: hashmap %p is already initialized", (
void *) map);
30 map->
entries = kcalloc<hashmap_entry_t *>(capacity);
50 for (
size_t i = 0; i < map->
capacity; i++)
75 auto old_value = entry->
value;
102 const auto value = entry->
value;
120 while (entry !=
NULL)
128 void *value = entry->
value;
145 for (
size_t i = 0; i < map->
capacity; i++)
148 while (entry !=
NULL)
150 if (!func(entry->
key, entry->
value, data))
void * hashmap_get(hashmap_t *map, uintn key)
void * hashmap_put(hashmap_t *map, uintn key, void *value)
void hashmap_deinit(hashmap_t *map)
Deinitialize a hashmap.
int(* hashmap_key_compare_t)(const uintn key1, const uintn key2)
A hashmap hash function prototype.
hash_t(* hashmap_hash_t)(const uintn key)
void hashmap_init(hashmap_t *map, size_t capacity, hashmap_hash_t hash_func, hashmap_key_compare_t compare_func)
void * hashmap_remove(hashmap_t *map, uintn key)
void hashmap_foreach(hashmap_t *map, hashmap_foreach_func_t func, void *data)
bool(* hashmap_foreach_func_t)(const uintn key, void *value, void *data)
A hashmap key comparison function prototype.
T * create(Args &&...args)
#define mos_panic(fmt,...)
#define MOS_LIB_ASSERT_X(cond, msg)
#define memzero(ptr, size)
#define MOS_LIB_ASSERT(cond)
#define spinlock_acquire(lock)
#define spinlock_release(lock)
hashmap_key_compare_t key_compare_func
hashmap_entry_t ** entries