#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
template<typename SV, typename BV>
{
auto en = bv.get_enumerator(0);
if (!en.valid())
{
cout << "<EMPTY>" << endl;
return;
}
auto cnt = bv.count();
cout << "size=" << cnt << " ";
for (; en.valid(); ++en)
{
auto idx = *en;
auto v = sv.get(idx);
cout << idx << ":" << v << ", ";
}
cout << endl;
}
{
try
{
{
bit = 1;
bit = 2;
bit = 20;
bit = 0;
bit.flush();
}
{
auto bit = sv2.get_back_inserter();
bit = 1;
bit = -2;
bit = 0;
bit.add_null();
bit = 30;
bit.flush();
}
{
scanner_u32.
find_gt(sv1, 1, bv_res);
}
{
scanner_u32.
find_lt(sv1, 0, bv_res);
}
{
scanner_i32.
find_ge(sv2, -1, bv_res);
}
{
scanner_i32.
find_le(sv2, 30, bv_res);
}
{
}
{
scanner_i32.
find_gt(sv2, 10, bv_res_gt);
scanner_i32.
find_le(sv2, -1, bv_res_le);
bv_res.
bit_or(bv_res_gt, bv_res_le);
bv_res.
bit_and(bv_res_gt, bv_res_le);
}
}
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.
Algorithms for bm::sparse_vector.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
bm::bvector< Alloc > & bit_or(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand OR : this := bv1 OR bv2
bm::bvector< Alloc > & bit_and(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand AND : this := bv1 AND bv2
algorithms for sparse_vector scan/search
void find_lt(const SV &sv, value_type val, bvector_type &bv_out)
find all elements sparse vector element less (<) than value
void find_ge(const SV &sv, value_type val, bvector_type &bv_out)
find all elements sparse vector element greater or equal (>=) than value
void find_le(const SV &sv, value_type val, bvector_type &bv_out)
find all elements sparse vector element less or equal (<=) than value
void find_gt(const SV &sv, value_type val, bvector_type &bv_out)
find all elements sparse vector element greater (>) than value
void find_range(const SV &sv, value_type from, value_type to, bvector_type &bv_out)
find all elements sparse vector element in closed range [left..right] interval
succinct sparse vector with runtime compression using bit-slicing / transposition method
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster,...
@ use_null
support "non-assigned" or "NULL" logic
bm::sparse_vector< unsigned, bm::bvector<> > svector_u32
bm::sparse_vector< int, bm::bvector<> > svector_i32
void PrintResults(const SV &sv, const BV &bv)