bitset

package
v0.0.0-...-0b5b9fe Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSet

type BitSet interface {
	Get(i uint) bool
	Set(i uint)
	Unset(i uint)
	SetBool(i uint, b bool)
}

BitSet the bitset interface

type Bytes

type Bytes []byte

Bytes the bitset []byte

func NewBytes

func NewBytes(numBits uint) Bytes

NewBytes returns a new bitset that is capable of holding numBits number of binary values. All bytes in the bitset are zeroed and each bit is therefore considered unset.

func (Bytes) Get

func (s Bytes) Get(i uint) bool

Get returns whether the bit at index i is set or not. This method will panic if the index results in a byte index that exceeds the number of bytes held by the bitset.

func (*Bytes) Grow

func (s *Bytes) Grow(numBits uint)

Grow ensures that the bitset s is large enough to hold numBits number of bits, potentially appending to and/or reallocating the slice if the current length is not sufficient.

func (Bytes) Set

func (s Bytes) Set(i uint)

Set sets the bit at index i. This method will panic if the index results in a byte index that exceeds the number of a bytes held by the bitset.

func (Bytes) SetBool

func (s Bytes) SetBool(i uint, b bool)

SetBool sets or unsets the bit at index i depending on the value of b. This method will panic if the index results in a byte index that exceeds the nubmer of bytes held by the bitset.

func (Bytes) String

func (s Bytes) String() string

String eq: `[4 0] bit(00100000 00000000)`

func (Bytes) Unset

func (s Bytes) Unset(i uint)

Unset unsets the bit at index i. This method will panc if the index results in a byte index that exceeds the number of bytes held by the bitset.

Jump to

Keyboard shortcuts

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