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)
}
Setset a bit to trueUnsetset a bit to false (calledresetin LLVM)Testcheck whether a bit is trueTestAndSetset a bit to true and return true if it was changedClearset all bits to falseIteratereturns a channel that publishes all true bitsEqualscompare to another SparseBitVectorContainsreturns true if another SparseBitVector's bits are all trueUnionAndIntersectionSizereturn the size of the union and intersection with another SparseBitVectorUnionSizeIntersectionSizeUnionWithunion itself with another SparseBitVectorIntersectWithintersect itself with another SparseBitVectorIntersectWithComplementintersect itself with the bitwise inverse of another SparseBitVector
Unionreturning a new bit vectorIntersectionreturning a new bit vectorIntersectsreturning true if any bit is present in the intersection