Skip to main content
Module

x/structurae/ranked-bit-array.ts>RankedBitArray

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

A bit array that supports constant time rank and O(logN) time select operations.

Examples

const array = RankedBitArray.create(10); array.setBit(1).setBit(3).setBit(7); array.rank(2); //=> 1 array.rank(7); //=> 2 array.select(2); //=> 3

Properties

readonly
size: number

The amount of bits in the array.

Methods

rank(index: number): number

Returns the rank of a bit at a given index.

select(index: number): number

Returns the select of a bit at a given index.

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

Sets the bit at a given index.

Static Methods

getLength(size: number): number

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