SimpleDataStructure

C++17 library that packed some of succinct data structures and algorithms supports.

View the Project on GitHub MatsuTaku/SimpleDataStructure

SuccinctBitVector

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 parameters

template <bool UseSelect>
class SuccinctBitVector;

Constructions

Central Operations

Examples

#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;
}