C++17 library that packed some of succinct data structures and algorithms supports.
Extended binary array structure supporting rank/select operations.
Supporting basic operation like std::vector<>
.
rank and select can calculate in $O(1)$ times.
Note This class is constant (immutable) structure. You must sample bits using BitVector or etc before construction.
template <bool UseSelect>
class SuccinctBitVector;
UseSelect
true
if you want to use select operations.SuccinctBitVector(sim_ds::BitVector&& bv)
std::vector<bool>(size)
bool operator[](size_t i)
size_t rank(size_t i)
size_t select(size_t i)
#include <iostream>
#include <vector>
#include "sim_ds/SuccinctBitVector.hpp"
int main() {
sim_ds::BitVector bv(std::vector<bool>{0,1,1,0,1,0,1,1});
sim_ds::SuccinctBitVector<true> sbv(std::move(bv));
// rank operation
for (int i = 0; i < 8; i++)
if (sbv[i])
std::cout << i << ':' << sbv.rank(i) << std::endl;
// 1:0
// 2:1
// 4:2
// 6:3
// 7:4
// select operation
for (int i = 0; i < 5; i++)
std::cout << i << ':' << sbv.select(i) << std::endl;
// 0:1
// 1:2
// 2:4
// 3:6
// 4:7
return 0;
}