#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
using std::vector;
using std::list;
#ifdef BM_NO_STL
# undef BM_NO_STL
#endif
#include "bm.h"
#include "bmalgo.h"
#include "bmundef.h"
using namespace std;
inline
void Print(unsigned n)
{
cout << n << endl;;
}
template<class T> void PrintContainer(T first, T last)
{
if (first == last)
cout << "<EMPTY SET>";
else
for(;first != last; ++first)
cout << *first << ";";
cout << endl;
}
int main(void)
{
try
{
bm::bvector<> bv;
bv[10] = true;
bv[100] = true;
bv[10000] = true;
bm::bvector<>::size_type arr[] = {2, 10000, 5, 12, 255, 12, 300};
cout << "Source set 1:";
PrintContainer(bv.first(), bv.end());
cout << "Source set 2:";
PrintContainer(&arr[0], &arr[0] + (sizeof(arr)/sizeof(arr[0])));
bm::combine_and(bv, &arr[0], &arr[0] + (sizeof(arr)/sizeof(arr[0])));
cout << "Result 1(AND): ";
PrintContainer(bv.first(), bv.end());
bv.clear();
bv[10] = true;
bv[100] = true;
bv[10000] = true;
bm::combine_or(bv, &arr[0], &arr[0] + (sizeof(arr)/sizeof(arr[0])));
cout << "Result 2(OR): ";
PrintContainer(bv.first(), bv.end());
std::sort(&arr[0], &arr[0] + (sizeof(arr)/sizeof(arr[0])));
bm::combine_and_sorted(bv, &arr[0], &arr[0] + (sizeof(arr)/sizeof(arr[0])));
cout << "Result 3(AND): ";
PrintContainer(bv.first(), bv.end());
bm::combine_sub(bv, &arr[0], &arr[0] + (sizeof(arr)/sizeof(arr[0])));
cout << "Result 4(MINUS): ";
PrintContainer(bv.first(), bv.end());
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}