Documentation ¶
Index ¶
- type Bitset256
- func (b *Bitset256) AsBytes() []byte
- func (b *Bitset256) AsHex() string
- func (b *Bitset256) Clear(ix byte) *Bitset256
- func (b *Bitset256) Clone() *Bitset256
- func (b *Bitset256) Count() int
- func (b *Bitset256) Equals(other *Bitset256) bool
- func (b *Bitset256) Get(ix byte) bool
- func (b *Bitset256) Indices() []byte
- func (b *Bitset256) Intersect(other *Bitset256) *Bitset256
- func (b *Bitset256) IsSubsetOf(other *Bitset256) bool
- func (b *Bitset256) Less(other *Bitset256) bool
- func (b *Bitset256) Set(ix byte) *Bitset256
- func (b *Bitset256) String() string
- func (b *Bitset256) Toggle(ix byte) *Bitset256
- func (b *Bitset256) Union(other *Bitset256) *Bitset256
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bitset256 ¶
type Bitset256 [4]uint64
Bitset256 is an efficient way to store individual bits corresponding to 256 values (i.e., using a byte as an index).
func FromBytes ¶
FromBytes takes a slice of 32 bytes and builds a Bitset256 from it, following the same rules as AsBytes (the last byte in the slice corresponds to the zeroth bits).
func (*Bitset256) AsBytes ¶
AsBytes returns the bitset as a slice of 32 bytes, where the 0 bits in the bitset are in the last element of the slice (basically, big-endian format). This is so that rendering the slice to a visual format will show the bits in an expected order.
func (*Bitset256) AsHex ¶
AsHex returns a string representation of the bitset as a 256-bit number in hex (64 characters). It follows the same rules as AsBytes.
func (*Bitset256) Clear ¶
Clear unconditionally forces a single bit to 0 and returns the pointer to the bitset.
func (*Bitset256) Indices ¶
Indices returns an []byte where the values are the indices of all the 1 bits that are set, in sorted order from 0. The length of the slice is equal to b.Count(). This is fairly heavily optimized.
func (*Bitset256) Intersect ¶
Intersect returns a pointer to a new Bitset256 that is the intersection of its two source bitsets (the only bits that are set are the ones where both source sets had a 1 bit).
func (*Bitset256) IsSubsetOf ¶
IsSubsetOf returns true if all of the bits in a bitset are also in the other bitset.
func (*Bitset256) Less ¶
Less returns true if, when expressed as a number, b would be strictly less than other.
func (*Bitset256) Set ¶
Set unconditionally forces a single bit at the index to 1 and returns the pointer to the bitset.