Example of how to search bm::sparse_vector_scanner<> with sparse vector scanner and inspect search results using bm::interval_enumerator<> to find special values: unique, co-locvated together in the results or dispersed.
#include <assert.h>
#include <iostream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <random>
#include <algorithm>
#include <stdexcept>
using namespace std;
{
try
{
{
bit = 0;
bit = 17;
bit = 17;
bit = 5;
bit = 18;
bit = 178;
bit = 178;
bit = 17;
bit = 0;
bit.flush();
}
{
cout << "Sparse vector:" << endl;
std::for_each(sv.
begin(), sv.
end(), [](
unsigned v) {
cout << v << ",";
});
cout << endl << endl;
}
bool id_max_seen(false);
for (;it != it_end; ++it)
{
auto v = *it;
{
if (id_max_seen)
continue;
id_max_seen = true;
}
else
{
continue;
}
{
if (range_cnt == 1)
{
cout << "Value = " << v << " is unique" << endl;
continue;
}
cout << "Value = " << v << " is colocated" << endl;
continue;
}
cout << "Value = " << v << " is not colocated" << 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.
Algorithms for bit ranges and intervals.
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.
bool test(size_type n) const BMNOEXCEPT
returns true if bit n is set and false is bit n is 0.
bvector< Alloc > & set(size_type n, bool val=true)
Sets bit n if val is true, clears bit n if val is false.
bvector_size_type size_type
forward iterator class to traverse bit-vector as ranges
size_type end() const BMNOEXCEPT
Return interval end/right as bit-vector coordinate 011110 [left..right].
bool valid() const BMNOEXCEPT
Returns true if enumerator is valid (false if traversal is done)
size_type start() const BMNOEXCEPT
Return interval start/left as bit-vector coordinate 011110 [left..right].
algorithms for sparse_vector scan/search
void find_eq(const SV &sv, value_type value, bvector_type &bv_out)
find all sparse vector elements EQ to search value
void bind(const SV &sv, bool sorted)
bind sparse vector for all searches
allocator_pool_type & get_bvector_alloc_pool() BMNOEXCEPT
Return allocator pool for blocks (Can be used to improve performance of repeated searches with the sa...
succinct sparse vector with runtime compression using bit-slicing / transposition method
const_iterator end() const BMNOEXCEPT
Provide const iterator access to the end
friend back_insert_iterator
const_iterator begin() const BMNOEXCEPT
Provide const iterator access to container content
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, typename sparse_vector< Val, BV >::statistics *stat=0)
run memory optimization for all vector planes
bm::alloc_pool_guard< allocator_pool_type, bvector< Alloc > > mem_pool_guard
@ BM_GAP
GAP compression is ON.
bm::sparse_vector< unsigned, bvector_type > sparse_vector_u32
bm::interval_enumerator< bvector_type > interval_enumerator_type