Example of how to use bm::str_sparse_vector<> - succinct container for sorted bit-transposed collection of integers
- See also
- bm::sparse_vector
-
bm::sparse_vector_scanner<>::lower_bound
#include <iostream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <random>
#include <algorithm>
#include <stdexcept>
static
{
const unsigned max_coll = 50000;
vec.resize(0);
for (unsigned i = 10; i < max_coll; i += rand() % 3)
{
vec.emplace_back(i);
}
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(vec.begin(), vec.end(), g);
}
static
{
for (const unsigned u : vec)
{
(void)found;
}
}
{
try
{
vector<unsigned> vec;
std::sort(vec.begin(), vec.end());
{
vector<unsigned>::const_iterator vit = vec.begin();
for (; it != it_end; ++it, ++vit)
{
unsigned u = *it;
if (*vit != u)
{
cerr << "Mismatch at:" << u << "!=" << *vit << endl;
return 1;
}
}
}
cout << "Sort validation Ok." << endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}