Documentation
¶
Overview ¶
Package bitseq efficiently implements a general-purpose infinite sequence of bits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRange = errors.New("value out of range")
Functions ¶
func Read ¶
Read reads an opaque binary representation from r into the provided Store, replacing its existing contents iff successful.
Important: While relatively robust against corrupt data, care should be taken when parsing arbitrary input. A malicious actor could craft an input that would allocate a large amount of memory, or attempt to extract information by continuing to consume from the reader. io.LimitReader may be helpful here.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an "infinite" sequence of bits. Trailing zero bits do not necessarily consume any memory.
The zero-value Store is a useful value. The store is not suitable for concurrent use without additional synchronization.
func (*Store) Crop ¶ added in v2.12.0
func (s *Store) Crop()
Crop attempts to reclaim any surplus backing memory consumed by trailing zero bits.
func (*Store) Get ¶
Get looks up a bit at a given index, returning true iff it has been set. Panics if index is less than zero.
func (*Store) NextFalse ¶
NextFalse returns the index of the next false bit found after the given index. To start at the beginning, start with NextFalse(-1).
func (*Store) NextTrue ¶
NextTrue returns the index of the next true bit found after the given index. To start at the beginning, start with NextTrue(-1). If the second return value is false, then the search has finished, and the remaining sequence is an infinite sequence of false bits.