Example demonstrates using set operations AND, OR, XOR, etc.
#include <iostream>
using namespace std;
static
{
do
{
cout << value;
if (value)
{
cout << ",";
}
else
{
break;
}
} while(1);
cout << endl;
}
{
try
{
bv3 = bv1 & bv2;
bv2 &= bv1;
bv3 = bv1 | bv2;
bv2 |= bv1;
bv3 = bv2 - bv1;
bv2 -= bv1;
bv3 = bv2 ^ bv1;
{
if (f)
{
cout << "XOR mismatch position = " << pos << endl;
}
if (f)
{
cout << "search mismatch position = " << pos << endl;
}
}
bv2 ^= bv1;
if (bv2 == bv3)
{
cerr << "Equivalent. Comparison result = "
<< bv2.compare(bv3) << endl;
}
else
{
cout << "Error." << endl;
return 1;
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
bool find(size_type &pos) const BMNOEXCEPT
Finds index of first 1 bit.
size_type get_next(size_type prev) const BMNOEXCEPT
Finds the number of the next bit ON.
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
bool find_first_mismatch(const bvector< Alloc > &bvect, size_type &pos, size_type search_to=bm::id_max) const BMNOEXCEPT
Find index of first bit different between this and the agr vector.
size_type get_first() const BMNOEXCEPT
find first 1 bit in vector. Function may return 0 and this requires an extra check if bit 0 is actual...
static void print_bvector(const bm::bvector<> &bv)