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);
78 cout << "size of the class of 2: " << U.size(2) << endl;
79 check(U.size(2) == 3);
81 cout <<"erase 1: " << endl;
85 cout << "size of the class of 4: " << U.size(4) << endl;
86 check(U.size(4) == 2);
87 cout << "size of the class of 2: " << U.size(2) << endl;
88 check(U.size(2) == 2);
91 cout <<"erase 1: " << endl;
95 cout <<"erase 6: " << endl;
99 cout << "split the class of 5: " << endl;
104 cout << "size of the class of 4: " << U.size(4) << endl;
105 check(U.size(4) == 2);
106 cout << "size of the class of 3: " << U.size(3) << endl;
107 check(U.size(3) == 1);
108 cout << "size of the class of 2: " << U.size(2) << endl;
109 check(U.size(2) == 2);
112 cout << "Joining 3 - 4 and 2 - 4 ..." << endl;
118 cout << "size of the class of 4: " << U.size(4) << endl;
119 check(U.size(4) == 3);
120 cout << "size of the class of 3: " << U.size(3) << endl;
121 check(U.size(3) == 3);
122 cout << "size of the class of 2: " << U.size(2) << endl;
123 check(U.size(2) == 3);
125 cout << "makeRep(4)" << endl;
128 cout << "makeRep(3)" << endl;
131 cout << "makeRep(2)" << endl;
135 cout << "size of the class of 4: " << U.size(4) << endl;
136 check(U.size(4) == 3);
137 cout << "size of the class of 3: " << U.size(3) << endl;
138 check(U.size(3) == 3);
139 cout << "size of the class of 2: " << U.size(2) << endl;
140 check(U.size(2) == 3);
143 cout << "eraseClass 4 ..." << endl;
147 cout << "eraseClass 7 ..." << endl;
151 cout << "done" << endl;
153 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
156 return passed ? 0 : 1;