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.
#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;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
Algorithms for bit ranges and intervals.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.
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...
forward iterator class to traverse bit-vector as ranges
size_type end() const BMNOEXCEPT
Return interval end/right as bit-vector coordinate 011110 [left..right].
bool valid() const BMNOEXCEPT
Returns true if enumerator is valid (false if traversal is done)
const pair_type & get() const BMNOEXCEPT
Get interval pair.
size_type start() const BMNOEXCEPT
Return interval start/left as bit-vector coordinate 011110 [left..right].
bool go_to(size_type pos, bool extend_start=true)
Go to inetrval at specified position Jump to position with interval. If interval is not available at ...
@ BM_GAP
GAP compression is ON.
bm::interval_enumerator< bm::bvector<> > interval_enumerator_type