#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
{
try
{
cout << "sparse vectors without NULL:" << endl;
{
sv2 = sv1;
if (found)
std::cout << "Mismatch found." << endl;
else
std::cout << "Mismatch not found" << endl;
sv2[2] = 0;
if (found)
{
std::cout << "Mismatch found at: " << pos << endl;
}
}
cout << endl << "sparse vectors with NULL:" << endl;
{
sv1[1] = 1;
sv1[2] = 2;
sv1[4] = 0;
sv2 = sv1;
if (found)
std::cout << "Mismatch found." << endl;
else
std::cout << "Mismatch not found" << endl;
sv2[4] = 10;
if (found)
{
std::cout << "Mismatch found at: " << pos << endl;
}
sv2[3] = 0;
if (found)
{
std::cout << "Mismatch found at: " << pos << 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.
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)
succinct sparse vector with runtime compression using bit-slicing / transposition method
bvector_type::size_type size_type
void set_null(size_type idx)
set specified element to unassigned value (NULL)
void push_back(value_type v)
push value back into vector
@ use_null
support "non-assigned" or "NULL" logic
bool sparse_vector_find_first_mismatch(const SV &sv1, const SV &sv2, typename SV::size_type &midx, bm::null_support null_proc=bm::use_null)
Find first mismatch (element which is different) between two sparse vectors (uses linear scan in bit-...
bm::sparse_vector< unsigned, bm::bvector<> > svector_u32