39 std::size_t
size()
const {
return impl().size_impl(); }
56 return impl().bit_impl(position);
66 std::uint64_t
rank(std::size_t end_position)
const {
67 return impl().rank_impl(end_position);
78 std::uint64_t
rank0(std::size_t end_position)
const {
79 if constexpr (
requires { impl().rank0_impl(end_position); }) {
80 return impl().rank0_impl(end_position);
83 : end_position -
rank(end_position);
96 return impl().select_impl(
rank);
108 return impl().select0_impl(
rank);
136 requires requires(const Impl& concrete) {
138 concrete.memory_usage_bytes_impl()
139 } -> std::convertible_to<std::size_t>;
142 return impl().memory_usage_bytes_impl();
151 result.reserve(
size());
152 for (std::size_t i = 0; i <
size(); ++i) {
153 result.push_back((*
this)[i] ?
'1' :
'0');
160 const Impl& impl()
const {
return static_cast<const Impl&
>(*this); }
CRTP facade for immutable rank/select queries and bit access.
Definition rank_select.h:32
bool empty() const
Check whether the bit vector is empty.
Definition rank_select.h:45
std::uint64_t select(std::size_t rank) const
Return the position of the rank-th one bit.
Definition rank_select.h:95
std::size_t memory_usage_bytes() const
Return owned index memory usage when provided by the implementation.
Definition rank_select.h:135
std::uint64_t select0(std::size_t rank) const
Return the position of the rank-th zero bit.
Definition rank_select.h:107
bool supports_select1() const
Check whether select queries for one bits are enabled.
Definition rank_select.h:117
std::uint64_t rank0(std::size_t end_position) const
Count zero bits in the prefix [0, end_position).
Definition rank_select.h:78
std::size_t size() const
Return the number of valid bits.
Definition rank_select.h:39
std::string to_string() const
Convert the logical bits to a binary string.
Definition rank_select.h:149
bool supports_select0() const
Check whether select queries for zero bits are enabled.
Definition rank_select.h:125
int operator[](std::size_t position) const
Read a bit by zero-based position.
Definition rank_select.h:55
std::uint64_t rank(std::size_t end_position) const
Count one bits in the prefix [0, end_position).
Definition rank_select.h:66