summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2017-03-17 17:26:47 -0700
committerOri Bernstein <ori@markovcorp.com>2017-03-17 17:26:47 -0700
commit6f8ceb3bf2f16c16cf566b4dc99b09dd2b538479 (patch)
tree70984a223cbb5b20f3755b050a8874af8baf447d
parent1fc981b2ef099974206af6ad0242c38ccdffb02e (diff)
downloadmc-6f8ceb3bf2f16c16cf566b4dc99b09dd2b538479.tar.gz
Add a hash function for bitsets.
-rw-r--r--lib/std/bitset.myr6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/std/bitset.myr b/lib/std/bitset.myr
index 5aa160d..0b25729 100644
--- a/lib/std/bitset.myr
+++ b/lib/std/bitset.myr
@@ -6,6 +6,7 @@ use "slcp"
use "sldup"
use "slfill"
use "types"
+use "hashfuncs"
pkg std =
type bitset = struct
@@ -29,6 +30,7 @@ pkg std =
const bsunion : (a : bitset#, b : bitset# -> void)
const bseq : (a : bitset#, b : bitset# -> bool)
const bsissubset : (a : bitset#, b : bitset# -> bool)
+ const bshash : (a : bitset# -> uint32)
type bsiter = struct
idx : size
@@ -153,6 +155,10 @@ const bseq = {a, b
-> true
}
+const bshash = {a
+ -> std.slhash(a.bits)
+}
+
const ensurelen = {bs, len
if bs.bits.len <= len
slzgrow(&bs.bits, len + 1)