Skip to content

package bitmap

import "kaiju/bitmap"

Functions

Check

func Check(b Bitmap, index int) bool

Count

func Count(b Bitmap) int

Count returns the number of bits that are true.

CountASM

func CountASM(b Bitmap) int

CountASMUsingTable

func CountASMUsingTable(b Bitmap) int

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.Clear

func (b Bitmap) Clear()

Clear sets all bits to false.

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.