bitset

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package bitset provides a bit-packed set implementation for efficient null masks.

Package bitset provides a space-efficient bit array implementation.

BitSet uses 1 bit per value (packed into uint64 words) rather than 1 byte, providing an 8x memory savings compared to []bool.

Primary use case: null masks in Series where each bit indicates if a value is null. Target performance: <10ns per Set/Test operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSet

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

BitSet is a bit-packed array using uint64 words. Each bit represents a boolean value (1 = set/true, 0 = clear/false). Used primarily for null masks in Series where 1 = null.

func New

func New(n int) *BitSet

New creates a new BitSet with the specified length. All bits are initialized to 0 (cleared).

func (*BitSet) All

func (bs *BitSet) All() bool

All returns true if all bits are set.

func (*BitSet) Any

func (bs *BitSet) Any() bool

Any returns true if any bit is set.

func (*BitSet) Clear

func (bs *BitSet) Clear(i int)

Clear sets the bit at position i to 0. Panics if i is out of bounds.

func (*BitSet) ClearAll

func (bs *BitSet) ClearAll()

ClearAll sets all bits to 0.

func (*BitSet) Clone

func (bs *BitSet) Clone() *BitSet

Clone returns a deep copy of the BitSet.

func (*BitSet) Count

func (bs *BitSet) Count() int

Count returns the number of set bits (population count).

func (*BitSet) Len

func (bs *BitSet) Len() int

Len returns the number of bits in the set.

func (*BitSet) None

func (bs *BitSet) None() bool

None returns true if no bits are set.

func (*BitSet) Set

func (bs *BitSet) Set(i int)

Set sets the bit at position i to 1. Panics if i is out of bounds.

func (*BitSet) SetAll

func (bs *BitSet) SetAll()

SetAll sets all bits to 1.

func (*BitSet) Slice

func (bs *BitSet) Slice(start, end int) *BitSet

Slice returns a new BitSet containing bits from start (inclusive) to end (exclusive).

func (*BitSet) Test

func (bs *BitSet) Test(i int) bool

Test returns true if the bit at position i is set (1). Panics if i is out of bounds.

Jump to

Keyboard shortcuts

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