Documentation
¶
Overview ¶
Package bitset implements bitsets, a mapping between non-negative integers and boolean values.
Studied github.com/bits-and-blooms/bitset inside out and rewrote needed parts from scratch for this project.
This implementation is heavily optimized for this internal use case.
Index ¶
- type BitSet256
- func (b *BitSet256) All() []uint8
- func (b *BitSet256) AsSlice(buf *[256]uint8) []uint8
- func (b *BitSet256) Clear(bit uint8)
- func (b *BitSet256) FirstSet() (first uint8, ok bool)
- func (b *BitSet256) Intersection(c *BitSet256) (bs BitSet256)
- func (b *BitSet256) IntersectionCardinality(c *BitSet256) (cnt int)
- func (b *BitSet256) IntersectionTop(c *BitSet256) (top uint8, ok bool)
- func (b *BitSet256) IntersectsAny(c *BitSet256) bool
- func (b *BitSet256) IsEmpty() bool
- func (b *BitSet256) NextSet(bit uint8) (next uint8, iok bool)
- func (b *BitSet256) Rank(idx uint8) (rnk int)
- func (b *BitSet256) Set(bit uint8)
- func (b *BitSet256) Size() int
- func (b *BitSet256) String() string
- func (b *BitSet256) Test(bit uint8) (ok bool)
- func (b *BitSet256) Union(c *BitSet256) (bs BitSet256)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitSet256 ¶
type BitSet256 [4]uint64
BitSet256 represents a fixed size bitset from [0..255]
func (*BitSet256) All ¶
All returns all set bits. This has a simpler API but is slower than AsSlice.
func (*BitSet256) AsSlice ¶
AsSlice returns all set bits as slice of uint8 without heap allocations.
func (*BitSet256) Intersection ¶
Intersection computes the intersection of base set with the compare set. This is the BitSet equivalent of & (and).
func (*BitSet256) IntersectionCardinality ¶
IntersectionCardinality computes the popcount of the intersection.
func (*BitSet256) IntersectionTop ¶
IntersectionTop computes the intersection of base set with the compare set. If the result set isn't empty, it returns the top most set bit and true.
func (*BitSet256) IntersectsAny ¶
IntersectsAny returns true if the intersection of base set with the compare set is not the empty set.
func (*BitSet256) NextSet ¶
NextSet returns the next bit set from the specified start bit, including possibly the current bit along with an ok code.