Example for STL interoperability and set operations with iterators.
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
using std::vector;
using std::list;
#ifdef BM_NO_STL
# undef BM_NO_STL
#endif
using namespace std;
inline
{
cout << n << endl;;
}
{
if (first == last)
cout << "<EMPTY SET>";
else
for(;first != last; ++first)
cout << *first << ";";
cout << endl;
}
{
try
{
bv[10] = true;
bv[100] = true;
bv[10000] = true;
cout << "Source set:";
{
vector<bm_size_type> vect;
std::copy(bv.
first(), bv.
end(), vect.begin());
cout << "Vector:";
}
{
list<bm_size_type> lst;
std::copy(bv.
first(), bv.
end(), std::back_inserter(lst));
cout << "List:";
}
{
vector<bm_size_type> vect;
vector<bm_size_type> res1, res2, res3;
vect.push_back(100);
vect.push_back(15);
vect.push_back(150);
cout << "Argument vector for set operations:";
std::sort(vect.begin(), vect.end());
cout << endl;
vect.begin(), vect.end(),
std::back_inserter(res1));
cout << "Set union:" << endl;
std::set_intersection(bv.
first(), bv.
end(),
vect.begin(), vect.end(),
std::back_inserter(res2));
cout << "Set intersection:" << endl;
vector<bm_size_type>::const_iterator it1 = vect.begin();
vector<bm_size_type>::const_iterator it2 = vect.end();
std::set_difference(en, en2,
it1, it2,
std::back_inserter(res3));
cout << "Set diff:" << endl;
}
{
std::vector<bm_size_type> vect;
vect.push_back(300);
vect.push_back(200);
vect.push_back(275);
vect.push_back(200);
cout << endl << "Source vector:";
std::copy(vect.begin(), vect.end(), bv1.
inserter());
cout << "Bitset:";
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
pre-processor un-defines to avoid global space pollution (internal)
Constant iterator designed to enumerate "ON" bits.
Bitvector Bit-vector container with runtime compression of bits.
size_type count() const BMNOEXCEPT
population count (count of ON bits)
insert_iterator inserter()
bvector_size_type size_type
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.
bm::bvector ::size_type bm_size_type
void PrintContainer(T first, T last)
void Print(bm::bvector<>::size_type n)