# denseBitset

> **denseBitset**(`options?`): [`Bitset`](/reference/knotkit/bitset/interfaces/bitset/)

Defined in: [packages/bitset/src/dense-bitset.ts:25](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/bitset/src/dense-bitset.ts#L25)

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.

## Parameters

### options?

[`BitsetOptions`](/reference/knotkit/bitset/interfaces/bitsetoptions/)

Optional `items`, added as if by `add`.

## Returns

[`Bitset`](/reference/knotkit/bitset/interfaces/bitset/)

## Throws

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

## Throws

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

## Example

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