#include <stdlib.h>
#include <iostream>
#include <vector>
#include <memory>
#include "bm.h"
#include "bmundef.h"
int main(void)
{
try
{
bm::bvector<> bv { 1, 20, 30, 31 };
std::unique_ptr<bm::bvector<>::rs_index_type>
rs_idx(new 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;
bm::bvector<>::size_type pos;
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;
}