Example of how to use bm::rsc_sparse_vector<> pre-defined set construction1. Lets assume we know which elements of the vector are not NULL
- bm::rsc_sparse_vector<> can be constructed for this
- call to bm::rsc_sparse_vector<>::sync will re-calculate Rank-Select index to enable fast access to elements (usually read only mode)
- In this example we modify not NULL vector elements so it would use Rank-Select index without breaking its consistency
- See also
- bm::rsc_sparse_vector
-
bm::rsc_sparse_vector::sync
-
bm::rsc_sparse_vector::inc
-
rscsample02.cpp
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
template<
typename SV>
void PrintSV(
const SV& sv)
{
typename SV::const_iterator it = sv.begin();
typename SV::const_iterator it_end = sv.end();
for (size_t i = 0; it != it_end; ++it, ++i)
{
if (!it.is_null())
cout << i << ": " << *it << ", ";
}
cout << endl;
}
{
try
{
csv1.sync();
bv1.clear();
csv1.set(100, 1);
csv1.set(20, 1);
csv1.inc(10);
csv1.inc(65536, 1);
assert(csv1.in_sync());
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
Sparse constainer sparse_vector<> for integer types using bit-transposition transform.
Compressed sparse container rsc_sparse_vector<> for integer types.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
succinct sparse vector with runtime compression using bit-slicing / transposition method
bm::sparse_vector< unsigned, bm::bvector<> > sparse_vector_u32
bm::rsc_sparse_vector< unsigned, sparse_vector_u32 > rsc_sparse_vector_u32
void PrintSV(const SV &sv)
Print sparse vector not NULL elements.