bitset

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 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

Clone returns a copy.

func New

func New(v ...bool) *Bitset

New returns an initialised Bitset with optional initial bits v.

func NewFromBase2String

func NewFromBase2String(b2string string) *Bitset

NewFromBase2String 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)

AppendBools appends bits to the Bitset.

func (*Bitset) AppendByte

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

AppendByte appends the numBits least significant bits from value.

func (*Bitset) AppendBytes

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

AppendBytes appends a list of whole bytes.

func (*Bitset) AppendNumBools

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

AppendNumBools appends num bits of value value.

func (*Bitset) AppendUint32

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

AppendUint32 appends the numBits least significant bits from value.

func (*Bitset) At

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

At returns the value of the bit at |index|.

func (*Bitset) Bits

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

Bits returns the contents of the Bitset.

func (*Bitset) ByteAt

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

ByteAt returns a byte consisting of upto 8 bits starting at index.

func (*Bitset) Equals

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

Equals returns true if the Bitset equals other.

func (*Bitset) Len

func (b *Bitset) Len() int

Len returns the length of the Bitset in bits.

func (*Bitset) String

func (b *Bitset) String() string

String returns a human readable representation of the Bitset's contents.

func (*Bitset) Substr

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

Substr 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