bitvec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package bitvec implements a mutable bit vector with insertion, deletion, and indexing operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitVector

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

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

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

func (*BitVector) Append

func (vector *BitVector) Append(bit byte)

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

func (*BitVector) Bytes

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

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

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

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

func (vector *BitVector) Length() int

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

func (*BitVector) Set

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.

Jump to

Keyboard shortcuts

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