Module reader

Source
Expand description

A reader for efficient, repeated random access into an IntVec.

This module provides IntVecReader, a reusable reader that is designed to optimize random access performance.

§Performance

A standard call to get is convenient, but it creates and discards an internal bitstream reader for each call. When performing many random lookups, this can introduce significant overhead.

IntVecReader avoids this by maintaining a persistent, reusable reader instance. This amortizes the setup cost across multiple get operations, making it ideal for access patterns where lookup indices are not known in advance (e.g., graph traversals, pointer chasing).

For reading a predefined list of indices, get_many is generally more efficient, as it can pre-sort the indices for a single sequential scan.

Structs§

IntVecReader
A stateful reader for an IntVec that provides fast random access.