godropbox: github.com/dropbox/godropbox/container/bitvector Index | Files

package bitvector

import "github.com/dropbox/godropbox/container/bitvector"

Package bitvector provides the implementation of a variable sized compact vector of bits which supports lookups, sets, appends, insertions, and deletions.

Index

Package Files

bitvector.go

type BitVector Uses

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

A BitVector is a variable sized vector of bits. It supports lookups, sets, appends, insertions, and deletions.

This class is not thread safe.

func NewBitVector Uses

func NewBitVector(data []byte, length int) *BitVector

NewBitVector creates and initializes a new bit vector with length elements, using data as its initial contents.

func (*BitVector) Append Uses

func (vector *BitVector) Append(bit byte)

Append adds a bit to the end of a bit vector.

func (*BitVector) Bytes Uses

func (vector *BitVector) Bytes() []byte

Bytes returns a slice of the contents of the bit vector. If the caller changes the returned slice, the contents of the bit vector may change.

func (*BitVector) Delete Uses

func (vector *BitVector) Delete(index int)

Delete removes the bit in the supplied index of the bit vector. All bits in positions greater than or equal to index before the call will be shifted down by one.

func (*BitVector) Element Uses

func (vector *BitVector) Element(i int) byte

Element returns the bit in the ith index of the bit vector. Returned value is either 1 or 0.

func (*BitVector) Insert Uses

func (vector *BitVector) Insert(bit byte, index int)

Insert inserts bit into the supplied index of the bit vector. All bits in positions greater than or equal to index before the call will be shifted up by one.

func (*BitVector) Length Uses

func (vector *BitVector) Length() int

Length returns the current number of elements in the bit vector.

func (*BitVector) Set Uses

func (vector *BitVector) Set(bit byte, index int)

Set changes the bit in the ith index of the bit vector to the value specified in bit.

Updated 2020-06-23. Refresh now. Tools for package owners.