Class BitArray

Description

Bit array class

The BitArray class is for setting and extracting bits from a number. It can be used, for example, for compact storage array of boolean values.

Features:

  • compact storage array of boolean values

Example

import { BitArray } from '@biorate/bit-array';

const bits = new BitArray();

bits.set(0);
bits.set(1);
bits.set(2);

console.log(bits.value(0)); // 1
console.log(bits.value(0, 1)); // 3
console.log(bits.value(0, 1, 2)); // 7

bits.remove(1);

console.log(bits.value(0)); // 1
console.log(bits.value(0, 1)); // 1
console.log(bits.value(0, 1, 2)); // 5

Hierarchy

  • BitArray

Constructors

Properties

#value: number = 0

Description

inner value storage

#maxIndex: 30 = 30

Description

Max index value

Methods

Generated using TypeDoc