-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_hashmap.h
33 lines (20 loc) · 962 Bytes
/
simple_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
/* This hash map doesn't keep the address of key and value when user call insert.
So after user call insert, they can free key and value if necessary.
When user call get, the data returned point to the real content in hash table.
So DO NOT FREE THE RETURNED DATA! */
#ifndef _SIMPLE_HASHMAP_H_
#define _SIMPLE_HASHMAP_H_
#include <stddef.h>
#include <stdint.h>
struct _hashmap;
typedef struct _hashmap hashmap;
hashmap* create_hashmap(size_t size);
void free_hashmap(hashmap* map);
int hashmap_insert(hashmap* map, char* key, size_t key_len, void* data, size_t data_len);
int hashmap_insert_uint64_key(hashmap* map, uint64_t key, void* data, size_t data_len);
int hashmap_remove(hashmap* map, char* key, size_t key_len);
int hashmap_remove_uint64_key(hashmap* map, uint64_t key);
void* hashmap_get(hashmap* map, char* key, size_t key_len);
void* hashmap_get_uint64_key(hashmap* map, uint64_t key);
size_t hashmap_count(hashmap* map);
#endif