bitmap

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBitSet = errors.New("bitmap: attempted to set a bit before the last written bit")

ErrInvalidBitSet is returned when there is an attempt to set a bit before the last written bit.

Functions

This section is empty.

Types

type Bitmap

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

Bitmap is an EWAH-encoded bitmap. See: https://github.com/lemire/javaewah

func FromBytes

func FromBytes(b []byte, order binary.ByteOrder) (*Bitmap, error)

FromBytes creates a Bitmap from the given bytes.

func FromReader

func FromReader(r io.Reader, order binary.ByteOrder) (*Bitmap, error)

FromReader creates a Bitmap from the given reader.

func New

func New() *Bitmap

New creates a new empty bitmap.

func (*Bitmap) Bits

func (b *Bitmap) Bits() uint32

Bits returns the number of uncompressed bits in the bitmap.

func (*Bitmap) Bytes

func (b *Bitmap) Bytes() int64

Bytes returns the number of bytes taken by the compressed bitmap.

func (*Bitmap) Get

func (b *Bitmap) Get(pos int64) bool

Get returns the bit at the given position, being true 1 and false 0.

func (*Bitmap) Reset

func (b *Bitmap) Reset()

Reset clears the bitmap and sets everything to unused empty zeroes.

func (*Bitmap) Set

func (b *Bitmap) Set(pos int64) error

Set sets to 1 the bit at the given position. Take into account that bits need to be set in ascending order. Setting the 4th bit will return an error if you already set the 5th bit, for example.

func (*Bitmap) Write

func (b *Bitmap) Write(w io.Writer, order binary.ByteOrder) (n int64, err error)

Write will write the Bitmap to a writer with the following format: https://github.com/git/git/blob/master/Documentation/technical/bitmap-format.txt#L92

Jump to

Keyboard shortcuts

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