Example on intervals enumarator.BitMagic bvector<> implements high performance operation on RLE coded bit-vectors, transparently supporting all logical operations like intersections.Serialization uses compressive encoding (binary interpolative codes) to efficiently store collections of intervals.
This example illustrates use of inetrval_enumerator<> to interpret bit-vector as a sequence of 011110 ranges/intervals.
- See also
- bm::bvector::set_range
-
bm::interval_enumerator
-
sample22.cpp
-
Algorithms for bit intervals
#include <iostream>
#include <assert.h>
using namespace std;
{
try
{
{
{
do
{
cout <<
"[" << ien.
start() <<
".." << ien.
end() <<
"]";
cout << endl;
}
}
{
for (; ien != ien_end; ++ien)
{
cout << "[" << (*ien).first << ".." << (*ien).second << "]";
}
cout << endl;
}
{
for (; ien != ien_end; ++ien)
{
}
cout << endl;
for (; ien != ien_end; ++ien)
{
}
cout << endl;
for (; ien != ien_end; ++ien)
{
}
cout << endl;
for (; ien != ien_end; ++ien)
{
}
cout << endl;
ien.
go_to(1150000,
true);
{
assert(0);
}
else
{
cout << "EMPTY" << endl;
}
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
bvector< Alloc > & set_range(size_type left, size_type right, bool value=true)
Sets all bits in the specified closed interval [left,right] Interval must be inside the bvector's siz...
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.