-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashtable.h
More file actions
34 lines (25 loc) · 718 Bytes
/
Copy pathhashtable.h
File metadata and controls
34 lines (25 loc) · 718 Bytes
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
#ifndef HASHTABLE_H
#define HASHTABLE_H
#include <cstdint>
#include <cstddef>
#include <string>
struct HNode {
HNode *next = nullptr;
uint64_t hcode = 0;
};
struct HTab {
HNode **tab = nullptr; // an array of arrays (buckets)
size_t mask = 0; // % n mask
size_t size = 0; // size of current array ( may resize if it gets too large)
};
struct HMap {
HTab newer;
HTab older; // resizing
size_t migrate_pos;
};
HNode *hm_lookup(HMap *hmap, HNode *key, bool (*eq)(HNode *, HNode *));
void hm_insert(HMap *hmap, HNode *node);
HNode *hm_delete(HMap *hmap, HNode *key, bool (*eq)(HNode *, HNode *));
const size_t k_max_load_factor = 8;
const size_t k_rehashing_work = 128;
#endif