![]() |
Pixie
|
CRTP facade for immutable rank/select queries and bit access. More...
#include <rank_select.h>
Public Member Functions | |
| std::size_t | size () const |
| Return the number of valid bits. | |
| bool | empty () const |
| Check whether the bit vector is empty. | |
| int | operator[] (std::size_t position) const |
| Read a bit by zero-based position. | |
| std::uint64_t | rank (std::size_t end_position) const |
Count one bits in the prefix [0, end_position). | |
| std::uint64_t | rank0 (std::size_t end_position) const |
Count zero bits in the prefix [0, end_position). | |
| std::uint64_t | select (std::size_t rank) const |
| Return the position of the rank-th one bit. | |
| std::uint64_t | select0 (std::size_t rank) const |
| Return the position of the rank-th zero bit. | |
| bool | supports_select1 () const |
| Check whether select queries for one bits are enabled. | |
| bool | supports_select0 () const |
| Check whether select queries for zero bits are enabled. | |
| std::size_t | memory_usage_bytes () const |
| Return owned index memory usage when provided by the implementation. | |
| std::string | to_string () const |
| Convert the logical bits to a binary string. | |
CRTP facade for immutable rank/select queries and bit access.
| Impl | Concrete type implementing the const *_impl() operations documented on the facade methods. No virtual dispatch is used. |
Source representation, ownership, and lifetime are defined by the concrete implementation. Borrowed data must remain alive and immutable while queries use it. Rank counts half-open prefixes; select takes a one-based occurrence rank and returns a zero-based bit position.
<pixie/rank_select/implementations.h> for the available concrete implementations.
|
inline |
Check whether the bit vector is empty.
true when size() == 0.
|
inline |
Return owned index memory usage when provided by the implementation.
The optional Impl::memory_usage_bytes_impl() returns a value convertible to std::size_t. Include owned source copies when present; exclude borrowed storage. This reports allocation size, not resident memory or allocator bookkeeping.
|
inline |
|
inline |
Count one bits in the prefix [0, end_position).
| end_position | Prefix boundary, clamped to size(). |
Requires Impl::rank_impl(end_position) to count ones in [0, min(end_position, size())), including zero for an empty prefix.
|
inline |
Count zero bits in the prefix [0, end_position).
| end_position | Prefix boundary, clamped to size(). |
An optional Impl::rank0_impl(end_position) may compute this prefix directly. It must clamp boundaries at or beyond size() to the total zero count. Otherwise the facade derives zeros from one rank.
|
inline |
Return the position of the rank-th one bit.
| rank | One-based occurrence rank. Rank zero returns zero. |
size() if unavailable or absent.Requires Impl::select_impl(rank) to return zero for rank zero, size() when one-select is disabled or rank exceeds the one population, and otherwise the unique position of that occurrence.
|
inline |
Return the position of the rank-th zero bit.
| rank | One-based occurrence rank. Rank zero returns zero. |
size() if unavailable or absent.Requires Impl::select0_impl(rank) to return zero for rank zero, size() when zero-select is disabled or rank exceeds the zero population, and otherwise the unique position of that occurrence.
|
inline |
Return the number of valid bits.
Requires Impl::size_impl() to return the logical length.
|
inline |
Check whether select queries for zero bits are enabled.
true when select0() is supported by this instance.Requires Impl::supports_select0_impl() to report whether this instance enables zero-select, independently of its zero population.
|
inline |
Check whether select queries for one bits are enabled.
true when select() is supported by this instance.Requires Impl::supports_select1_impl() to report whether this instance enables one-select, independently of its one population.
|
inline |
Convert the logical bits to a binary string.
size() characters containing only 0 and 1.