MOS Source Code
Loading...
Searching...
No Matches
hashmap.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
6#include <mos/moslib_global.h>
7#include <mos/types.h>
8
16typedef hash_t (*hashmap_hash_t)(const uintn key);
17typedef int (*hashmap_key_compare_t)(const uintn key1, const uintn key2);
18typedef bool (*hashmap_foreach_func_t)(const uintn key, void *value, void *data);
19
20typedef struct hashmap_entry hashmap_entry_t;
21
32
33MOSAPI void hashmap_init(hashmap_t *map, size_t capacity, hashmap_hash_t hash_func, hashmap_key_compare_t compare_func);
35
36MOSAPI void *hashmap_put(hashmap_t *map, uintn key, void *value);
37MOSAPI void *hashmap_get(hashmap_t *map, uintn key);
38MOSAPI void *hashmap_remove(hashmap_t *map, uintn key);
39
40MOSAPI void hashmap_foreach(hashmap_t *map, hashmap_foreach_func_t func, void *data);
41
MOSAPI void * hashmap_get(hashmap_t *map, uintn key)
Definition hashmap.c:96
MOSAPI void * hashmap_put(hashmap_t *map, uintn key, void *value)
Definition hashmap.c:68
MOSAPI void hashmap_deinit(hashmap_t *map)
Deinitialize a hashmap.
Definition hashmap.c:49
int(* hashmap_key_compare_t)(const uintn key1, const uintn key2)
A hashmap hash function prototype.
Definition hashmap.h:17
hash_t(* hashmap_hash_t)(const uintn key)
Definition hashmap.h:16
MOSAPI void hashmap_init(hashmap_t *map, size_t capacity, hashmap_hash_t hash_func, hashmap_key_compare_t compare_func)
Definition hashmap.c:24
MOSAPI void * hashmap_remove(hashmap_t *map, uintn key)
Definition hashmap.c:117
MOSAPI void hashmap_foreach(hashmap_t *map, hashmap_foreach_func_t func, void *data)
Definition hashmap.c:146
bool(* hashmap_foreach_func_t)(const uintn key, void *value, void *data)
A hashmap key comparison function prototype.
Definition hashmap.h:18
MOSAPI int(2, 3) sprintf(char *__restrict str
#define MOSAPI
Definition mos_global.h:102
int bool
Definition pb_syshdr.h:57
struct _hashmap hashmap_t
Definition process.h:11
Definition types.h:97
Definition hashmap.c:15
s32 magic
Definition hashmap.h:24
spinlock_t lock
Definition hashmap.h:30
size_t size
Definition hashmap.h:27
hashmap_hash_t hash_func
Definition hashmap.h:28
hashmap_key_compare_t key_compare_func
Definition hashmap.h:29
hashmap_entry_t ** entries
Definition hashmap.h:25
size_t capacity
Definition hashmap.h:26
signed int s32
Definition types.h:15
unsigned long uintn
Definition types.h:30