Example demonstrates using enumerators - the fastest way to retrieve indexes of 1 bits from the bitvector. This approach works faster than get_first()/get_next() functions.
- See also
- bm::bvector<>::enumerator
-
bm::bvector<>::first()
-
bm::bvector<>::end()
-
bm::bvector<>::get_enumerator()
#include <iostream>
#include <algorithm>
using namespace std;
inline
{
cout << n << endl;;
}
{
try
{
bv[10] = true;
bv[100] = true;
bv[10000] = true;
bv[65536] = true;
bv[65537] = true;
bv[65538] = true;
bv[65540] = true;
while (en < en_end)
{
cout << *en << ", ";
++en;
}
cout << endl;
std::for_each(en, en_end,
Print);
cout << endl;
{
cout << *en << ", ";
}
cout << 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.
pre-processor un-defines to avoid global space pollution (internal)
Constant iterator designed to enumerate "ON" bits.
bool go_to(size_type pos) BMNOEXCEPT
go to a specific position in the bit-vector (or next)
bool valid() const BMNOEXCEPT
Checks if iterator is still valid.
Bitvector Bit-vector container with runtime compression of bits.
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.
void Print(bm::bvector<>::size_type n)