klao@347: #include klao@347: #include klao@347: klao@347: #include klao@347: klao@347: using namespace hugo; klao@347: using namespace std; klao@347: klao@347: const int N = 3; klao@347: klao@347: typedef StdMap BaseMap; klao@347: typedef IterableMap TestMap; klao@361: typedef IterableBoolMap TestBoolMap; klao@347: klao@347: klao@361: template klao@361: void print(TM const& m, int N = 3) { klao@347: cout << "Size of the map: " << m.size() << endl; klao@347: for(int i=0; i BaseMap2; klao@366: typedef IterableBoolMap TestBoolMap2; klao@366: klao@366: klao@347: int main() { klao@347: klao@361: { klao@361: BaseMap base(344); klao@361: TestMap test(base); klao@347: klao@347: klao@361: print(test); klao@347: klao@361: cout << "Inserting 12 to class 2...\n"; klao@361: test.insert(12,2); klao@361: print(test); klao@347: klao@347: klao@361: cout << "Inserting 22 to class 2...\n"; klao@361: test.insert(22,2); klao@361: print(test); klao@347: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << int(test[12]) << endl; klao@347: klao@361: cout << "Inserting 10 to class 0...\n"; klao@361: test.insert(10,0); klao@361: print(test); klao@347: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << int(test[12]) << endl; klao@347: klao@361: cout << "Inserting 11 to class 1...\n"; klao@361: test.insert(11,1); klao@361: print(test); klao@347: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << int(test[12]) << endl; klao@361: cout << " 22: " << int(test[22]) << endl; klao@361: cout << " 10: " << int(test[10]) << endl; klao@361: cout << " 11: " << int(test[11]) << endl; klao@361: cout << " 42: " << int(test[42]) << endl; klao@347: klao@361: cout << "Inserting 21 to class 1...\n"; klao@361: test.insert(21,1); klao@361: print(test); klao@347: klao@361: cout << "Inserting 20 to class 1...\n"; klao@361: test.insert(20,0); klao@361: print(test); klao@347: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << int(test[12]) << endl; klao@361: cout << " 22: " << int(test[22]) << endl; klao@361: cout << " 10: " << int(test[10]) << endl; klao@361: cout << " 20: " << int(test[20]) << endl; klao@361: cout << " 11: " << int(test[11]) << endl; klao@361: cout << " 21: " << int(test[21]) << endl; klao@361: cout << " 42: " << int(test[42]) << endl; klao@347: klao@361: cout << "Setting 20 to class 2...\n"; klao@361: test.set(20,2); klao@361: print(test); klao@347: klao@361: cout << "Setting 10 to class 1...\n"; klao@361: test.set(10,1); klao@361: print(test); klao@347: klao@361: cout << "Setting 11 to class 1...\n"; klao@361: test.set(11,1); klao@361: print(test); klao@347: klao@361: cout << "Setting 12 to class 1...\n"; klao@361: test.set(12,1); klao@361: print(test); klao@347: klao@361: cout << "Setting 21 to class 2...\n"; klao@361: test.set(21,2); klao@361: print(test); klao@347: klao@361: cout << "Setting 22 to class 2...\n"; klao@361: test.set(22,2); klao@361: print(test); klao@347: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << int(test[12]) << endl; klao@361: cout << " 22: " << int(test[22]) << endl; klao@361: cout << " 10: " << int(test[10]) << endl; klao@361: cout << " 20: " << int(test[20]) << endl; klao@361: cout << " 11: " << int(test[11]) << endl; klao@361: cout << " 21: " << int(test[21]) << endl; klao@361: cout << " 42: " << int(test[42]) << endl; klao@361: } klao@347: klao@361: { klao@362: cout << "\n\n\nTesting the IterableBoolMap...\n"; klao@361: klao@361: BaseMap base(344); klao@362: TestBoolMap test(base,true); klao@361: klao@361: klao@361: print(test,2); klao@361: klao@361: cout << "Inserting 12 to class true...\n"; klao@361: test.insert(12,true); klao@361: print(test,2); klao@361: klao@361: klao@361: cout << "Inserting 22 to class true...\n"; klao@361: test.insert(22,true); klao@361: print(test,2); klao@361: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << test[12] << endl; klao@361: klao@361: cout << "Inserting 10 to class false...\n"; klao@361: test.insert(10,false); klao@361: print(test,2); klao@361: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << test[12] << endl; klao@361: klao@361: cout << "Inserting 11 to class false...\n"; klao@361: test.insert(11,false); klao@361: print(test,2); klao@361: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << test[12] << endl; klao@361: cout << " 22: " << test[22] << endl; klao@361: cout << " 10: " << test[10] << endl; klao@361: cout << " 11: " << test[11] << endl; klao@361: cout << " 42: " << test[42] << endl; klao@361: klao@362: cout << "Setting 10 to class true...\n"; klao@362: test.set(10,true); klao@361: print(test,2); klao@361: klao@362: cout << "Setting 11 to class true...\n"; klao@361: test.set(11,1); klao@361: print(test,2); klao@361: klao@362: cout << "Setting 12 to class false...\n"; klao@362: test.set(12,false); klao@361: print(test,2); klao@361: klao@362: cout << "Setting 22 to class false...\n"; klao@362: test.set(22,false); klao@361: print(test,2); klao@361: klao@361: cout << "Testing some map values:\n"; klao@361: cout << " 12: " << test[12] << endl; klao@361: cout << " 22: " << test[22] << endl; klao@361: cout << " 10: " << test[10] << endl; klao@361: cout << " 11: " << test[11] << endl; klao@361: cout << " 42: " << test[42] << endl; klao@361: klao@361: } klao@366: klao@366: { klao@366: cout << "\n\n\nTest a masikfele iteralasra:\n"; klao@366: klao@366: BaseMap2 base(344); klao@366: TestBoolMap2 test(base,false); klao@366: klao@366: cout << "Inserting 12 to class true...\n"; klao@366: test.insert(12,true); klao@366: print(test,2); klao@366: klao@366: cout << "Inserting 22 to class true...\n"; klao@366: test.insert(22,true); klao@366: print(test,2); klao@366: klao@366: cout << "Inserting 10 to class false...\n"; klao@366: test.insert(10,false); klao@366: print(test,2); klao@366: klao@366: cout << "Testing some map values:\n"; klao@366: cout << " 12: " << test[12] << endl; klao@366: cout << " 22: " << test[22] << endl; klao@366: cout << " 10: " << test[10] << endl; klao@366: cout << " 42: " << test[42] << endl; klao@366: klao@366: cout << "The elements of the \"true\" class: "; klao@366: Int a; klao@366: for(test.first(a, true); a.valid(); test.next(a)) { klao@366: cout << " " << a; klao@366: } klao@366: cout << endl; klao@367: klao@367: cout << "Removing 10 from the map...\n"; klao@367: test.remove(10); klao@367: print(test,2); klao@366: } klao@347: }