Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

SparseBitvector_Test.cpp

Go to the documentation of this file.
00001 
00002 #include "eclat/SparseBitvector.hpp"
00003 #include "eclat/SparseBitvector_intersection.hpp"
00004 
00005 #include <iostream>
00006 using namespace std;
00007 
00008 int main(int argc, char** argv) {
00009 
00010   // intersection / case #1:
00011 
00012   int xval[] = { 1, 2, 4, 6 };
00013   int yval[] = { 1, 3, 5, 6 };
00014   int lenx = 4, leny = 4, lenres = 0;
00015   SparseBitvector x(xval, &lenx, 4), y(yval, &leny, 4), res(new int[10], &lenres, 10);
00016 
00017   cout << "before: "
00018        << "x = " << x 
00019        << ", y = " << y
00020        << ", res = " << res 
00021        << endl;
00022 
00023   bool complete = intersection<true,true>(res, x, y, 2);
00024 
00025   cout << "after : "
00026        << "x = " << x 
00027        << ", y = " << y
00028        << ", res = " << res 
00029        << ", complete = " << complete
00030        << ", lenx = " << lenx
00031        << ", leny = " << leny
00032        << ", lenres = " << lenres
00033        << endl;
00034 
00035   // intersection / case #2:
00036 
00037   int x2val[] = { 0, 2, 4, 7 };
00038   int y2val[] = { 1, 3, 5, 6 };
00039   int lenx2 = 4, leny2 = 4, lenres2 = 0;
00040   SparseBitvector x2(x2val, &lenx2, 4), y2(y2val, &leny2, 4), res2(new int[10], &lenres2, 10);
00041 
00042   cout << "before: "
00043        << "x2 = " << x2 
00044        << ", y2 = " << y2
00045        << ", res2 = " << res2 
00046        << endl;
00047 
00048   bool complete2 = intersection<true,true>(res2, x2, y2, 0);
00049 
00050   cout << "after : "
00051        << "x2 = " << x2 
00052        << ", y2 = " << y2
00053        << ", res2 = " << res2 
00054        << ", complete2 = " << complete2
00055        << ", lenx2 = " << lenx2
00056        << ", leny2 = " << leny2
00057        << ", lenres2 = " << lenres2
00058        << endl;
00059 
00060   
00061   // length reference sharing:
00062 
00063   y.set(xval, &lenx, 4);
00064   y.setLength(0); // as x and y share lenx by now, both should be empty.
00065 
00066   cout << "after2: "
00067        << "x = " << x 
00068        << ", y = " << y
00069        << ", res = " << res 
00070        << ", complete = " << complete
00071        << ", lenx = " << lenx
00072        << ", leny = " << leny
00073        << endl;
00074 
00075 
00076 }

Generated on Sun Sep 17 17:50:40 2006 for FIM environment by  doxygen 1.4.4