ExtraMojo 0.15.0 has two new collections:
bbhash is a minimal perfect hash for a set of keys. My implementation still needs the reverse lookup, and doesn’t do parallel construction (yet). bbhash – ExtraMojo
from ExtraMojo.collections.bbhash.bbhash import BBHash
alias keys = [
"fox",
"dog",
"cat",
"mouse",
"rat",
"frog",
"panda",
"horse",
]
alias bbset = BBHash(keys)
def main():
print(Bool(bbset.find(String("bat"))))
print(Bool(bbset.find(String("rat"))))
The other structure is a bitvec, with works exactly as you’d expected a growable heap allocated bitvec to work. bitvec – ExtraMojo
from ExtraMojo.collections.bitvec import BitVec
def main():
var bv = BitVec()
bv.append(False)
bv.resize(10, fill=True)
bv[1] = False
var bv2 = BitVec(length=10, fill=True)
print(bv & bv2) # 0011111111
print(bv - bv2) # 0000000000
print(bv | bv2) # 1111111111
bv -= bv2
print(bv) # 0000000000