This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashmap.h
53 lines (43 loc) · 1.46 KB
/
hashmap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <_cheader.h>
#ifdef _KERNEL_
# include <kernel/system.h>
#else
# include <string.h>
# include <stddef.h>
# include <stdlib.h>
#endif
#include <sirius/list.h>
_Begin_C_Header
typedef unsigned int (*hashmap_hash_t) (const void * key);
typedef int (*hashmap_comp_t) (const void * a, const void * b);
typedef void (*hashmap_free_t) (void *);
typedef void * (*hashmap_dupe_t) (const void *);
typedef struct hashmap_entry {
char * key;
void * value;
struct hashmap_entry * next;
} hashmap_entry_t;
typedef struct hashmap {
hashmap_hash_t hash_func;
hashmap_comp_t hash_comp;
hashmap_dupe_t hash_key_dup;
hashmap_free_t hash_key_free;
hashmap_free_t hash_val_free;
size_t size;
hashmap_entry_t ** entries;
} hashmap_t;
extern hashmap_t * hashmap_create(int size);
extern hashmap_t * hashmap_create_int(int size);
extern void * hashmap_set(hashmap_t * map, const void * key, void * value);
extern void * hashmap_get(hashmap_t * map, const void * key);
extern void * hashmap_remove(hashmap_t * map, const void * key);
extern int hashmap_has(hashmap_t * map, const void * key);
extern list_t * hashmap_keys(hashmap_t * map);
extern list_t * hashmap_values(hashmap_t * map);
extern void hashmap_free(hashmap_t * map);
extern unsigned int hashmap_string_hash(const void * key);
extern int hashmap_string_comp(const void * a, const void * b);
extern void * hashmap_string_dupe(const void * key);
extern int hashmap_is_empty(hashmap_t * map);
_End_C_Header