Example rank and select operations.
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <memory>
{
try
{
std::unique_ptr<bm::bvector<>::rs_index_type>
bv.build_rs_index(rs_idx.get());
auto r1 = bv.rank(20, *rs_idx);
std::cout << r1 << std::endl;
r1 = bv.rank(21, *rs_idx);
std::cout << r1 << std::endl;
r1 = bv.rank(30, *rs_idx);
std::cout << r1 << std::endl;
auto r1c = bv.rank_corrected(31, *rs_idx);
std::cout << r1c << std::endl;
r1c = bv.rank_corrected(32, *rs_idx);
std::cout << r1c << std::endl;
r1c = bv.rank_corrected(33, *rs_idx);
std::cout << r1c << std::endl;
bool found = bv.select(2, pos, *rs_idx);
if (found)
std::cout << pos << std::endl;
else
std::cout << "Rank not found." << std::endl;
found = bv.
select(2, pos, *rs_idx);
if (found)
std::cout << pos << std::endl;
else
std::cout << "Rank not found." << std::endl;
found = bv.
select(5, pos, *rs_idx);
if (found)
std::cout << pos << std::endl;
else
std::cout << "Rank not found." << std::endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
bool select(size_type rank, size_type &pos, const rs_index_type &rs_idx) const BMNOEXCEPT
select bit-vector position for the specified rank(bitcount)
bvector_size_type size_type
rs_index< allocator_type > rs_index_type