Documentation ¶
Overview ¶
bitset is a package that provides a bit-wise set implementation for indexes/positions. Essentially, a bit is 1 if present, or 0 if absent. These implementation can be used to efficiently store the minimal information of 1 bit to keep track of e.g. presence for large numbers.
Index ¶
- Constants
- func Bit(bitset []uint, idx uint) bool
- func Calculate(capacity uint) int
- func Clear(bitset []uint)
- func Insert(bitset []uint, idx uint)
- func InsertMany(bitset []uint, idxs ...uint)
- func Len(bitset []uint) int
- func Remove(bitset []uint, idx uint)
- func RemoveMany(bitset []uint, idxs ...uint)
Constants ¶
const LimbLength = types.UintSize
Variables ¶
This section is empty.
Functions ¶
func Calculate ¶
Calculate calculates the size of a backing array such that it can store at least the specified capacity. (Rounded up to the next full limb. See `LimbLength`)
func Clear ¶
func Clear(bitset []uint)
Clear sets all bits to 0. This implementation is not ideal as it has to operate on a slice of arbitrary length. It assigns 0 to each individual cell in the slice. If `bitset` is backed by an array that is directly accessible, consider assigning it an empty array of same (total) size. This approach enjoys better compile-time support.
var mybitset [40]uint mybitset = [40]uint{}
func InsertMany ¶
InsertMany inserts multiple indices into the bitset.
func RemoveMany ¶
RemoveMany removes multiple indices from the bitset.
Types ¶
This section is empty.