blob: 36637542960a019e738c50ad6521874f19fc1834 (
plain)
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
|
/*
* Tiny hashmap implementation.
* Copyright (c) 2023-2024, Quinn Stephens and the OSMORA team.
* Provided under the BSD 3-Clause license.
*/
#ifndef _HASHMAP_H
#define _HASHMAP_H
#include <stddef.h>
#include "list.h"
#include "hash.h"
struct hashmap_entry {
struct list_entry list_entry;
hash_t hash;
};
struct hashmap {
struct list *rows;
size_t n_rows;
};
static inline void
hashmap_remove(struct hashmap_entry *entry)
{
list_remove(&entry->list_entry);
}
void hashmap_add(struct hashmap *map, struct hashmap_entry *entry);
struct hashmap_entry *hashmap_find(struct hashmap *map, hash_t hash);
void hashmap_free_entries(struct hashmap *map);
void hashmap_init(struct hashmap *map);
#endif /* !_HASHMAP_H */
|