ref: 6f8ceb3bf2f16c16cf566b4dc99b09dd2b538479
parent: 1fc981b2ef099974206af6ad0242c38ccdffb02e
author: Ori Bernstein <ori@markovcorp.com>
date: Fri Mar 17 13:26:47 EDT 2017
Add a hash function for bitsets.
--- a/lib/std/bitset.myr
+++ b/lib/std/bitset.myr
@@ -6,6 +6,7 @@
use "sldup"
use "slfill"
use "types"
+use "hashfuncs"
pkg std =
type bitset = struct
@@ -29,6 +30,7 @@
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
@@ -151,6 +153,10 @@
;;
;;
-> true
+}
+
+const bshash = {a
+ -> std.slhash(a.bits)
}
const ensurelen = {bs, len