bv

package module
v0.0.0-...-5cd5556 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 5 Imported by: 2

README

BV

GoDoc

bv is a basic bitvector implementation

Supports Set/Get of bit slices and serialization.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BV

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

BV is a bitvector

func New

func New(size int) *BV

New returns a bitvector containing size bits

func NewByteBacked

func NewByteBacked(buf []byte) (bitVector *BV, serializedLength uint64, err error)

NewByteBacked returns a bitvector backed by buf

func (*BV) Equals

func (bv *BV) Equals(bv2 *BV) bool

Equals returns true if the two bit vectors are equal.

func (*BV) Get

func (bv *BV) Get(i uint64) bool

Get returns true if the ith bit is set.

func (*BV) GetInt

func (bv *BV) GetInt(offset uint, bitLen uint8) uint64

GetInt returns an integer representation of bitLen bits at offset

func (*BV) Reset

func (bv *BV) Reset()

Reset clears the bit vector.

func (*BV) SerializedSize

func (bv *BV) SerializedSize() int

SerializedSize returns the size of the bv when serialized. i.e. WriteTo

func (*BV) Set

func (bv *BV) Set(i uint64, b bool)

Set sets or clears the ith bit.

func (*BV) SetInt

func (bv *BV) SetInt(offset int, bitLen uint8, v uint64)

SetInt sets bitLen bits at offset

func (*BV) Size

func (bv *BV) Size() int

Size returns the number of bits the vector represents.

func (*BV) SizeInBytes

func (bv *BV) SizeInBytes() uint64

SizeInBytes returns the size of the bit vector in bytes.

func (*BV) String

func (bv *BV) String() string

String returns a string representation of the bit vector.

func (*BV) WriteTo

func (bv *BV) WriteTo(w io.Writer) (n int, err error)

WriteTo serializes the bv to w. It returns the number of bits written.

Jump to

Keyboard shortcuts

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