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>
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;
}