Example for finding first and last bits in bit-vector (dynamic range).
Example for finding first and last bits in bit-vector (dynamic range).Ranges of bit-vectors can be used to find probability of intersection. For instance, in some corner cases AND product can be predicted empty if vectors belong to different ranges.
@sa bm::bvector<>::find()
@sa bm::bvector<>::find_reverse()
@sa bm::bvector<>::find_range()
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
static
{
{
if ((rand() % 10))
{
}
}
}
{
try
{
cout <<
"bv1 count = " << bv1.
count() << endl;
cout <<
"bv2 count = " << bv2.
count() << endl;
bool found;
if (found)
cout << "bv1 first = " << first << endl;
if (found)
cout << "bv1 last = " << last << endl;
if (found)
cout << "bv2 first = " << first << endl;
if (found)
cout << "bv2 last = " << last << endl;
if (found)
cout << "bv1 range = [" << first << ", " << last << "]" << endl;
if (found)
cout << "bv2 range = [" << first << ", " << last << "]" << 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.
Bitvector Bit-vector container with runtime compression of bits.
bool find(size_type &pos) const BMNOEXCEPT
Finds index of first 1 bit.
size_type count() const BMNOEXCEPT
population cout (count of ON bits)
bool find_range(size_type &first, size_type &last) const BMNOEXCEPT
Finds dynamic range of bit-vector [first, last].
bvector< Alloc > & set(size_type n, bool val=true)
Sets bit n if val is true, clears bit n if val is false.
bool find_reverse(size_type &pos) const BMNOEXCEPT
Finds last index of 1 bit.
static void fill_bvector(bm::bvector<> *bv1, bm::bvector<> *bv2)