bitset

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 3 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxBits = 64 * MaxBitsetWords

MaxBits is the number of distinct indexes a TinyBitset can hold.

View Source
const MaxBitsetWords = 16

MaxBitsetWords specifies the number of 64-bit words in the bitset.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitsTraverser

type BitsTraverser struct {
	// contains filtered or unexported fields
}

BitsTraverser is an iterator that allows to iterate over all bits set in the given 64-bit unsigned integer.

Iteration is performed from the least significant bit to the most significant one.

func NewBitsTraverser

func NewBitsTraverser(word uint64) BitsTraverser

NewBitsTraverser constructs a new bits traverser over given 64-bit word.

func (BitsTraverser) Iter

func (m BitsTraverser) Iter() iter.Seq[uint32]

Iter returns an iterator over the bits set in this word.

func (BitsTraverser) Traverse

func (m BitsTraverser) Traverse(fn func(uint32) bool) bool

Traverse traverses the bitset and calls the given function for each bit set.

type TinyBitset

type TinyBitset struct {
	// contains filtered or unexported fields
}

TinyBitset implements constant-length bitset.

This structure is designed to be used as a comparable key in maps.

func (*TinyBitset) AsSlice

func (m *TinyBitset) AsSlice() []uint32

AsSlice returns the bitset as a slice of indices, where each index is a position of the bit set.

func (*TinyBitset) Count

func (m *TinyBitset) Count() uint

Count returns the number of bits set in the bitset.

func (*TinyBitset) Insert

func (m *TinyBitset) Insert(idx uint32)

Insert inserts the given index into the bitset.

func (*TinyBitset) Iter

func (m *TinyBitset) Iter() iter.Seq[uint32]

func (*TinyBitset) Traverse

func (m *TinyBitset) Traverse(fn func(uint32) bool)

Traverse traverses the bitset and calls the given function for each bit set.

Iteration is performed from the least significant bit to the most significant one.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL