This library provides a SparseBitVector implementation in go based on the similarly named class provided by LLVM.
See:
- Documentation on GoDoc
- LLVM's SparseBitVector
go get github.com/neilisaac/sparsebitvector
import "github.com/neilisaac/sparsebitvector"
vec := sparsebitvector.New(1, 2, 1000000)
vec.Set(1000001)
vec.Unset(1)
vec.IntersectWith(sparsebitvector.New(1, 1000001))
for value := range vec.Iterate() {
fmt.Println("vec contains", value)
}
Set
set a bit to trueUnset
set a bit to false (calledreset
in LLVM)Test
check whether a bit is trueTestAndSet
set a bit to true and return true if it was changedClear
set all bits to falseIterate
returns a channel that publishes all true bitsEquals
compare to another SparseBitVectorContains
returns true if another SparseBitVector's bits are all trueUnionAndIntersectionSize
return the size of the union and intersection with another SparseBitVectorUnionSize
IntersectionSize
UnionWith
union itself with another SparseBitVectorIntersectWith
intersect itself with another SparseBitVectorIntersectWithComplement
intersect itself with the bitwise inverse of another SparseBitVector
Union
returning a new bit vectorIntersection
returning a new bit vectorIntersects
returning true if any bit is present in the intersection