Skip to content

denseBitset(options?): Bitset

Defined in: packages/bitset/src/dense-bitset.ts:25

A bitset of unsigned 32-bit ids over one flat bitmap.

One bit per possible id up to the largest stored id, with no chunk directory, so it is the faster layout for a set whose ids fill a compact range — and the layout whose memory follows the span rather than the content. Choose it only when the largest id is known and per-id traffic dominates.

BitsetOptions

Optional items, added as if by add.

Bitset

With code INVALID_ID when an item is not in 0 … BITSET_MAX_ID.

With code MAX_CAPACITY_EXCEEDED when the bitmap the items span cannot be allocated.

const visited = denseBitset({ items: [0, 2, 4] })
visited.size // 3
visited.rank(2) // 2