set

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: GPL-3.0, LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bits

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

Bits is a bit-set backed by a big.Int Holds values ranging from [0, INT_MAX] (arch-dependent) Trying to use negative values will result in a panic. This implementation is NOT thread-safe.

func BitsFromBytes

func BitsFromBytes(bytes []byte) Bits

BitsFromBytes returns a Bits from bytes representation

func NewBits

func NewBits(bits ...int) Bits

NewBits returns a new instance of Bits with [bits] set to 1.

Invariants: 1. Negative bits will cause a panic. 2. Duplicate bits are allowed but will cause a no-op.

func (Bits) Add

func (b Bits) Add(i int)

Add sets the [i]'th bit to 1

func (Bits) Bytes

func (b Bits) Bytes() []byte

Bytes returns the byte representation of this bitset

func (Bits) Clear

func (b Bits) Clear()

Clear empties the bitset

func (Bits) Contains

func (b Bits) Contains(i int) bool

Contains returns true if the [i]'th bit is 1, false otherwise

func (Bits) Len

func (b Bits) Len() int

Len returns the number of bits set to 1

func (Bits) Remove

func (b Bits) Remove(i int)

Remove sets the [i]'th bit to 0

func (Bits) String

func (b Bits) String() string

String returns the hex representation of this bitset

Jump to

Keyboard shortcuts

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