Skip to main content
Module

x/structurae/bit-array.ts>BitArray

Data structures for high-performance JavaScript applications.
Latest
class BitArray
extends Uint32Array
import { BitArray } from "https://deno.land/x/structurae@4.0.1/bit-array.ts";

Uses Uint32Array as an array or vector of bits. It's a simpler version of BitField that only sets and checks individual bits.

Examples

const array = BitArray.create(10); array.getBit(0); //=> 0 array.setBit(0).getBit(0); //=> 1 array.size; //=> 10 array.length; //=> 1

Properties

lastPosition: BitPosition
readonly
size: number

The amount of bits in the array.

Methods

getBit(index: number): Bit

Returns the bit at a given index.

getBitPosition(index: number): BitPosition
setBit(index: number, value?: Bit): this

Sets the bit at a given index.

Static Properties

readonly
[Symbol.species]: Uint32ArrayConstructor

Static Methods

create<T extends BitArray>(this: T, size: number): InstanceType<T>

Creates a BitArray of the specified size.

getLength(size: number): number

Returns the length of the underlying TypedArray required to hold the given amount of bits.