#include <stdlib.h>
#include <iostream>
#include <vector>
#include "bm.h"
#include "bmundef.h"
using namespace std;
const unsigned MAX_VALUE = 10000000;
static
void fill_bvector(bm::bvector<>* bv)
{
unsigned start = MAX_VALUE / (rand()%10);
for (unsigned i = start; i < MAX_VALUE; ++i)
{
if ((rand() % 10))
{
bv->set(i);
}
}
}
int main(void)
{
try
{
bm::bvector<> bv1;
bm::bvector<> bv2;
fill_bvector(&bv1);
fill_bvector(&bv2);
cout << "bv1 count = " << bv1.count() << endl;
cout << "bv2 count = " << bv2.count() << endl;
bool found;
bm::bvector<>::size_type first, last;
found = bv1.find(first);
if (found)
cout << "bv1 first = " << first << endl;
found = bv1.find_reverse(last);
if (found)
cout << "bv1 last = " << last << endl;
found = bv2.find(first);
if (found)
cout << "bv2 first = " << first << endl;
found = bv2.find_reverse(last);
if (found)
cout << "bv2 last = " << last << endl;
found = bv1.find_range(first, last);
if (found)
cout << "bv1 range = [" << first << ", " << last << "]" << endl;
found = bv2.find_range(first, last);
if (found)
cout << "bv2 range = [" << first << ", " << last << "]" << endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}