I hope it works. The 'erase' functions hasn't been tested yet.
12 passed = passed && rc;
14 cout << "Test failed!" << endl;
19 class BaseMap : public StdMap<int,T> {};
21 typedef UnionFindEnum<int, BaseMap> UFE;
23 void print(UFE const &ufe) {
25 cout << "printing the classes of the structure:" << endl;
27 for (ufe.first(cit); ufe.valid(cit); ufe.next(cit)) {
28 cout << " " << i << " (" << cit << "):" << flush;
30 for (ufe.first(iit, cit); ufe.valid(iit); ufe.next(iit)) {
31 cout << " " << iit << flush;
36 cout << "done" << endl;
46 cout << "Inserting 1..." << endl;
50 cout << "Inserting 2..." << endl;
54 cout << "Joining 1 and 2..." << endl;
58 cout << "Inserting 3, 4, 5, 6, 7..." << endl;
66 cout << "Joining 1 - 4, 2 - 4 and 3 - 5 ..." << endl;
72 cout << "size of the class of 4: " << U.size(4) << endl;
73 check(U.size(4) == 3);
74 cout << "size of the class of 5: " << U.size(5) << endl;
75 check(U.size(5) == 2);
76 cout << "size of the class of 6: " << U.size(6) << endl;
77 check(U.size(6) == 1);
79 cout <<"erase 1: " << endl;
83 cout <<"erase 1: " << endl;
87 cout <<"erase 6: " << endl;
91 cout << "split the class of 5: " << endl;
95 cout << "Joining 3 - 4 and 2 - 4 ..." << endl;
100 cout << "eraseClass 4 ..." << endl;
104 cout << "eraseClass 7 ..." << endl;
108 cout << "done" << endl;
110 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
113 return passed ? 0 : 1;