aboutsummaryrefslogtreecommitdiff
path: root/hashmap.ha
blob: dd580b0b61b0bf4a7c41e2f3629f88f32bc1d047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use hash::fnv;

def BUCKETS: size = 1 << 17;

type hashmap = [BUCKETS](str, data);

fn getitem(map: *hashmap, hash: size) data = {
	let bucket = &map[hash & (BUCKETS - 1)];
	return bucket.1;
};

fn setitem(map: *hashmap, hash: size, key: str, value: data) void = {
	let bucket = &map[hash & (BUCKETS - 1)];
	*bucket = (key, value);
};