bitset

package
v0.0.0-...-c618287 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 3 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 struct {
	// contains filtered or unexported fields
}

Bitset stores an array of bits.

func Clone

func Clone(from *Bitset) *Bitset

Returns a copy

func New

func New(v ...bool) *Bitset

func NewFromBase2String

func NewFromBase2String(b2string string) *Bitset

Constructs and returns a Bitset from a string The string consists of '1', '0' or ' ' characters, e.g. "1010 0101". The '1' and '0' characters represent true/false bits respectively, and ' ' characters are ignored The function panics if the input string contains other characters

func (*Bitset) Append

func (b *Bitset) Append(other *Bitset)

Append bits copied from other. The new length is b.Len() + other.Len()

func (*Bitset) AppendBools

func (b *Bitset) AppendBools(bits ...bool)

Appends bits to the Bitset

func (*Bitset) AppendByte

func (b *Bitset) AppendByte(value byte, numBits int)

Append the numBits least significant bits from value

func (*Bitset) AppendBytes

func (b *Bitset) AppendBytes(data []byte)

Appends a list of whole bytes

func (*Bitset) AppendNumBools

func (b *Bitset) AppendNumBools(num int, value bool)

Appends num bits of value value

func (*Bitset) AppendUint32

func (b *Bitset) AppendUint32(value uint32, numBits int)

Append the numBits least significant bits from value

func (*Bitset) At

func (b *Bitset) At(index int) bool

Returns the value of the bit at index

func (*Bitset) Bits

func (b *Bitset) Bits() []bool

Returns the contents of the Bitset

func (*Bitset) ByteAt

func (b *Bitset) ByteAt(index int) byte

Returns a byte consisting of upto 8 bits starting at index

func (*Bitset) Equals

func (b *Bitset) Equals(other *Bitset) bool

Returns true if the Bitset equals other

func (*Bitset) Len

func (b *Bitset) Len() int

Returns the length of the Bitset in bits

func (*Bitset) String

func (b *Bitset) String() string

Returns a human readable representation of the Bitset's contents

func (*Bitset) Substr

func (b *Bitset) Substr(start int, end int) *Bitset

Returns a substring, consisting of the bits from indexes start to end

Jump to

Keyboard shortcuts

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