aboutsummaryrefslogtreecommitdiff
path: root/hashmap.ha
diff options
context:
space:
mode:
Diffstat (limited to 'hashmap.ha')
-rw-r--r--hashmap.ha15
1 files changed, 15 insertions, 0 deletions
diff --git a/hashmap.ha b/hashmap.ha
new file mode 100644
index 0000000..dd580b0
--- /dev/null
+++ b/hashmap.ha
@@ -0,0 +1,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);
+};