|
void | append (leaf_type *leaf) |
| Add leaf reference to the support structure. More...
|
|
void | finalize () |
| Prepare the structure for querying. More...
|
|
dtype | size () const |
| Number of bits stored in the bit vector. More...
|
|
dtype | p_sum () const |
| Number of 1-bits stored in the bit vector. More...
|
|
bool | at (dtype i) const |
| Return value of bit at index \(i\) in the underlying bit vector. More...
|
|
dtype | rank (dtype i) const |
| Number of 1-bits up to position \(i\) in the underlying bit vector. More...
|
|
dtype | select (dtype i) const |
| Index of the \(i\)th 1-bit in the data structure. More...
|
|
uint64_t | bit_size () const |
| Number of bits allocated for the support structure. More...
|
|
void | print (bool internal_only) const |
| Outputs json representation of the support structure. More...
|
|
template<class dtype, class leaf_type, dtype block_size>
class bv::query_support< dtype, leaf_type, block_size >
Support structure for bv::bit_vector to enable fast queries.
Precalculates results for rank, select and access queries along with leaf pointers to enable faster queries while the bit vector remains unmodified.
Leaves should be appended in natural order. After all leaves have been added, the structure should be finalized to ensure properly precalculated select blocks.
If the underlying structure changes, querying the support structure may lead to undefined behaviour. The support structure should be discarded (delete(q)
) as it becomes outdated.
- Template Parameters
-
dtype | Integer type to use for indexing (uint32_t or uint64_t). |
leaf_type | Leaf type used by the relevant bv::bit_vector. |
template<class dtype , class leaf_type , dtype block_size>
Prepare the structure for querying.
Precalculates and stores results for some select queries to speed up subsequent select queries.
For sparse bit vectors where p_sum < size / block_size, locations for all 1-bits are precalculated, to allow constant time select queries.
template<class dtype , class leaf_type , dtype block_size>
Number of 1-bits up to position \(i\) in the underlying bit vector.
Precalculated results are used to locate the the leaf containing the \(i\)th bit in constant time. at most \(\mathrm{block\_size}\) are read from the leaf, to calculate the result for the rank query based on precalculated block results.
- Parameters
-
i | Number of elements to include in the "summation". |
- Returns
- \(\sum_{i = 0}^{i - 1} \mathrm{bv}[i]\).
template<class dtype , class leaf_type , dtype block_size>
Index of the \(i\)th 1-bit in the data structure.
For fairly dense approximately uniformly distributed bit vectors, the block containing the \(i\)th 1-bit can be located in constant time. For less dense or non-uniformly distributed bit vectors the block containing the \(i\)th 1-bit can be located either in constant time or logarithmic time depending on the local bit distribution in the vicinity of the \(i\)th bit.
After the correct block is located, at most block_size
bits are scanned for a single leaf.
For sparse bit vectors where p_sum < size / block_size, locations for all 1-bits have been precalculated, allowing constant time select queries.
- Parameters
-
- Returns
- \(\underset{j \in [0..n)}{\mathrm{arg min}}\left(\sum_{k = 0}^j \mathrm{bv}[k]\right) = i\).