bitfield

package
v0.0.0-...-b9de96a Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorsBitlistSize return when comparing two bitlists and don't share the same size.
	ErrorsBitlistSize = errors.New("bitlists doesn't have the same size")
	// ErrorBitlistOverlap return when two bitlist are being merged and they overlap
	ErrorBitlistOverlaps = errors.New("bitlists overlaps, not possible to merge")
)

Functions

This section is empty.

Types

type Bitlist

type Bitlist []byte

func NewBitlist

func NewBitlist(n uint64) Bitlist

NewBitlist creates a new bitlist of size N.

func (Bitlist) BitIndices

func (b Bitlist) BitIndices() []int

BitIndices returns an slice of int with the indexes marked on the bitlist

func (Bitlist) Contains

func (b Bitlist) Contains(c Bitlist) (bool, error)

Contains returns true if the bitlist contains all of the bits from the provided argument bitlist.

func (Bitlist) Count

func (b Bitlist) Count() uint64

Count returns the number of 1s in the bitlist.

func (Bitlist) Get

func (b Bitlist) Get(i uint) bool

Get returns the specified bit

func (Bitlist) Intersect

func (b Bitlist) Intersect(c Bitlist) []int

Intersect returns the bit indices of intersection between two bitlists

func (Bitlist) Len

func (b Bitlist) Len() uint64

Len of the bitlist returns the number of bits available in the underlying byte array.

func (Bitlist) Merge

func (b Bitlist) Merge(c Bitlist) (Bitlist, error)

Merge merges two bitlists with the same size, returns error if the bitlists overlaps on any bit or has different sizes

func (Bitlist) Overlaps

func (b Bitlist) Overlaps(c Bitlist) (bool, error)

Overlaps returns true if the bitlist contains one of the bits from the provided argument bitlist.

func (Bitlist) Set

func (b Bitlist) Set(i uint)

Set marks the specified bit

Jump to

Keyboard shortcuts

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