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.
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <memory>
{
if (first == last)
std::cout << "<EMPTY SET>";
else
for (; first != last; ++first)
std::cout << *first << ";";
std::cout << std::endl;
}
{
try
{
std::cout << "AGRUMENT (GROUP 0) SETS:" << std::endl;
std::vector<std::unique_ptr<bm::bvector<> > > vect;
{
bv->set(i);
bv->set(i+1);
bv->set(10000);
bv->set(20000);
bv->optimize();
vect.push_back(std::move(bv));
}
std::cout << std::endl;
try
{
for (unsigned i = 0; i < vect.size(); ++i)
{
}
std::cout << "OR:" << std::endl;
std::cout << "AND:" << std::endl;
for (unsigned i = 0; i < vect.size(); ++i)
{
const unsigned group0 = 0;
agg.
add(vect[i].get(), group0);
}
std::cout << "AND-SUB(empty):" << std::endl;
std::cout << "AND-SUB:" << std::endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
throw;
}
}
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 fast aggregation of N bvectors.
pre-processor un-defines to avoid global space pollution (internal)
Algorithms for fast aggregation of a group of bit-vectors.
bool combine_and_sub(bvector_type &bv_target)
Aggregate added group of vectors using fused logical AND-SUB Operation does NOT perform an explicit r...
void reset()
Reset aggregate groups, forget all attached vectors.
void combine_or(bvector_type &bv_target)
Aggregate added group of vectors using logical OR Operation does NOT perform an explicit reset of arg...
void combine_and(bvector_type &bv_target)
Aggregate added group of vectors using logical AND Operation does NOT perform an explicit reset of ar...
size_t add(const bvector_type *bv, unsigned agr_group=0)
Attach source bit-vector to a argument group (0 or 1).
Bitvector Bit-vector container with runtime compression of bits.
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
enumerator end() const
Returns enumerator pointing on the next bit after the last.
void PrintContainer(T first, T last)
const unsigned max_vectors