bitset

package
v0.0.0-...-34bb4ad Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: GPL-3.0, LGPL-3.0 Imports: 1 Imported by: 0

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

View Source
const LimbLength = types.UintSize

Variables

This section is empty.

Functions

func Bit

func Bit(bitset []uint, idx uint) bool

Bit returns the bit value for specified index.

func Calculate

func Calculate(capacity uint) int

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 Insert

func Insert(bitset []uint, idx uint)

Insert sets the bit for specified index.

func InsertMany

func InsertMany(bitset []uint, idxs ...uint)

InsertMany inserts multiple indices into the bitset.

func Len

func Len(bitset []uint) int

Len returns the length of the set in number of (available) bits.

func Remove

func Remove(bitset []uint, idx uint)

Remove removes the bit for specified index.

func RemoveMany

func RemoveMany(bitset []uint, idxs ...uint)

RemoveMany removes multiple indices from the bitset.

Types

This section is empty.

Jump to

Keyboard shortcuts

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