12#define HASHMAP_MAGIC MOS_FOURCC('H', 'M', 'a', 'p')
14typedef struct hashmap_entry
29 mos_panic(
"hashmap_init: hashmap %p is already initialized", (
void *) map);
54 for (
size_t i = 0; i < map->
capacity; i++)
79 void *old_value = entry->
value;
102 while (entry !=
NULL)
106 void *value = entry->
value;
124 while (entry !=
NULL)
132 void *value = entry->
value;
149 for (
size_t i = 0; i < map->
capacity; i++)
152 while (entry !=
NULL)
154 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)
struct hashmap_entry hashmap_entry_t
A hashmap foreach callback function prototype.
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.
slab_t * hashmap_entry_slab
#define mos_panic(fmt,...)
#define memzero(ptr, size)
#define MOS_LIB_ASSERT_X(cond, msg)
#define MOS_LIB_ASSERT(cond)
#define SLAB_AUTOINIT(name, var, type)
#define spinlock_acquire(lock)
#define spinlock_release(lock)
hashmap_key_compare_t key_compare_func
hashmap_entry_t ** entries