#include <iostream>
#include <assert.h>
#include "bm.h"
#include "bmintervals.h"
#include "bmundef.h"
using namespace std;
typedef bm::interval_enumerator<bm::bvector<> > interval_enumerator_type;
int main(void)
{
try
{
bm::bvector<> bv(bm::BM_GAP);
bv.set_range(10, 10);
bv.set_range(100, 110); bv.set_range(777, 888);
bv.set_range(65536, 65536);
bv.optimize();
{
interval_enumerator_type ien(bv);
if (ien.valid())
{
do
{
cout << "[" << ien.start() << ".." << ien.end() << "]";
} while (ien.advance());
cout << endl;
}
}
{
interval_enumerator_type ien(bv);
interval_enumerator_type ien_end;
for (; ien != ien_end; ++ien)
{
cout << "[" << (*ien).first << ".." << (*ien).second << "]";
}
cout << endl;
}
{
interval_enumerator_type ien(bv, 102, true);
interval_enumerator_type ien_end;
for (; ien != ien_end; ++ien)
{
cout << "[" << ien.get().first << ".." << ien.get().second << "]";
}
cout << endl;
ien.go_to(105, false); for (; ien != ien_end; ++ien)
{
cout << "[" << ien.get().first << ".." << ien.get().second << "]";
}
cout << endl;
ien.go_to(105, false);
for (; ien != ien_end; ++ien)
{
cout << "[" << ien.get().first << ".." << ien.get().second << "]";
}
cout << endl;
ien.go_to(115, true); for (; ien != ien_end; ++ien)
{
cout << "[" << ien.get().first << ".." << ien.get().second << "]";
}
cout << endl;
ien.go_to(1150000, true);
if (ien.valid())
{
assert(0);
}
else
{
cout << "EMPTY" << endl;
}
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}