Skip to content

package bitmap

import "kaiju/bitmap"

Functions

LengthFor

func LengthFor(byteCount int) int

LengthFor returns the number of bytes needed to represent the specified number of bits.

Types

Bitmap

[]byte

type Bitmap []byte

New

func New(length int) Bitmap

New creates a new bitmap of the specified length. A bitmap is a slice of bytes where each bit represents a boolean value. The length is the number of bits that the bitmap will represent. The length is rounded up to the nearest byte.

NewTrue

func NewTrue(length int) Bitmap

NewTrue creates a new bitmap of the specified length with all bits true

Bitmap.Assign

func (b Bitmap) Assign(index int, value bool)

Assign sets the bit at the specified index to the specified value.

Bitmap.Check

func (b Bitmap) Check(index int) bool

Check returns the value of the bit at the specified index.

Bitmap.Clear

func (b Bitmap) Clear()

Clear sets all bits to false.

Bitmap.Count

func (b Bitmap) Count() int

Count returns the number of bits that are true.

Bitmap.CountInverse

func (b Bitmap) CountInverse() int

CountInverse returns the number of bits that are false.

Bitmap.Reset

func (b Bitmap) Reset(index int)

Reset sets the bit at the specified index to false.

Bitmap.Set

func (b Bitmap) Set(index int)

Set sets the bit at the specified index to true.

Bitmap.Toggle

func (b Bitmap) Toggle(index int)

Toggle flips the value of the bit at the specified index.