summaryrefslogtreecommitdiff
path: root/libstd/bitset.myr
diff options
context:
space:
mode:
Diffstat (limited to 'libstd/bitset.myr')
-rw-r--r--libstd/bitset.myr11
1 files changed, 9 insertions, 2 deletions
diff --git a/libstd/bitset.myr b/libstd/bitset.myr
index 0cf8bbf..00b27c1 100644
--- a/libstd/bitset.myr
+++ b/libstd/bitset.myr
@@ -13,6 +13,8 @@ pkg std =
const bsdup : (bs : bitset# -> bitset#)
const bsfree : (bs : bitset# -> void)
+ const bsmax : (a : bitset# -> size)
+
generic bsput : (bs : bitset#, v : @a::(integral,numeric) -> void)
generic bsdel : (bs : bitset#, v : @a::(integral,numeric) -> void)
generic bshas : (bs : bitset#, v : @a::(integral,numeric) -> bool)
@@ -23,6 +25,7 @@ pkg std =
const bseq : (a : bitset#, b : bitset# -> bool)
const bsissubset : (a : bitset#, b : bitset# -> bool)
+
const bsclear : (bs : bitset# -> bitset#)
;;
@@ -44,6 +47,10 @@ const bsclear = {bs
-> bs
}
+const bsmax = {bs
+ -> bs.bits.len * sizeof(size) * 8
+}
+
generic bsput = {bs, v
var idx
var off
@@ -126,7 +133,7 @@ const bseq = {a, b
}
const ensurespace = {bs, v
- if bs.bits.len <= v
+ if bs.bits.len*8 <= v
bs.bits = slzgrow(bs.bits, v + 1)
;;
}
@@ -134,7 +141,7 @@ const ensurespace = {bs, v
const eqsz = {a, b
var sz
- sz = max(a.bits.len, b.bits.len)
+ sz = max(a.bits.len, b.bits.len)*8
ensurespace(a, sz)
ensurespace(b, sz)
}