1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/work/klao/iter_map_test.cc Sat Apr 17 01:57:48 2004 +0000
1.3 @@ -0,0 +1,117 @@
1.4 +#include <iter_map.h>
1.5 +#include <maps.h>
1.6 +
1.7 +#include <iostream>
1.8 +
1.9 +using namespace hugo;
1.10 +using namespace std;
1.11 +
1.12 +const int N = 3;
1.13 +
1.14 +typedef StdMap<int,int> BaseMap;
1.15 +typedef IterableMap<BaseMap, N> TestMap;
1.16 +
1.17 +
1.18 +void print(TestMap const& m) {
1.19 + cout << "Size of the map: " << m.size() << endl;
1.20 + for(int i=0; i<N; ++i) {
1.21 + cout << " Class " << i << ". (size=" << m.size(i) << "): " << flush;
1.22 + cout << " ";
1.23 + for(TestMap::iterator j = m.begin(i); j!=m.end(i); ++j) {
1.24 + cout << " " << *j;
1.25 + }
1.26 + cout << endl;
1.27 + }
1.28 +}
1.29 +
1.30 +
1.31 +
1.32 +int main() {
1.33 +
1.34 + BaseMap base(344);
1.35 + TestMap test(base);
1.36 +
1.37 +
1.38 + print(test);
1.39 +
1.40 + cout << "Inserting 12 to class 2...\n";
1.41 + test.insert(12,2);
1.42 + print(test);
1.43 +
1.44 +
1.45 + cout << "Inserting 22 to class 2...\n";
1.46 + test.insert(22,2);
1.47 + print(test);
1.48 +
1.49 + cout << "Testing some map values:\n";
1.50 + cout << " 12: " << int(test[12]) << endl;
1.51 +
1.52 + cout << "Inserting 10 to class 0...\n";
1.53 + test.insert(10,0);
1.54 + print(test);
1.55 +
1.56 + cout << "Testing some map values:\n";
1.57 + cout << " 12: " << int(test[12]) << endl;
1.58 +
1.59 + cout << "Inserting 11 to class 1...\n";
1.60 + test.insert(11,1);
1.61 + print(test);
1.62 +
1.63 + cout << "Testing some map values:\n";
1.64 + cout << " 12: " << int(test[12]) << endl;
1.65 + cout << " 22: " << int(test[22]) << endl;
1.66 + cout << " 10: " << int(test[10]) << endl;
1.67 + cout << " 11: " << int(test[11]) << endl;
1.68 + cout << " 42: " << int(test[42]) << endl;
1.69 +
1.70 + cout << "Inserting 21 to class 1...\n";
1.71 + test.insert(21,1);
1.72 + print(test);
1.73 +
1.74 + cout << "Inserting 20 to class 1...\n";
1.75 + test.insert(20,0);
1.76 + print(test);
1.77 +
1.78 + cout << "Testing some map values:\n";
1.79 + cout << " 12: " << int(test[12]) << endl;
1.80 + cout << " 22: " << int(test[22]) << endl;
1.81 + cout << " 10: " << int(test[10]) << endl;
1.82 + cout << " 20: " << int(test[20]) << endl;
1.83 + cout << " 11: " << int(test[11]) << endl;
1.84 + cout << " 21: " << int(test[21]) << endl;
1.85 + cout << " 42: " << int(test[42]) << endl;
1.86 +
1.87 + cout << "Setting 20 to class 2...\n";
1.88 + test.set(20,2);
1.89 + print(test);
1.90 +
1.91 + cout << "Setting 10 to class 1...\n";
1.92 + test.set(10,1);
1.93 + print(test);
1.94 +
1.95 + cout << "Setting 11 to class 1...\n";
1.96 + test.set(11,1);
1.97 + print(test);
1.98 +
1.99 + cout << "Setting 12 to class 1...\n";
1.100 + test.set(12,1);
1.101 + print(test);
1.102 +
1.103 + cout << "Setting 21 to class 2...\n";
1.104 + test.set(21,2);
1.105 + print(test);
1.106 +
1.107 + cout << "Setting 22 to class 2...\n";
1.108 + test.set(22,2);
1.109 + print(test);
1.110 +
1.111 + cout << "Testing some map values:\n";
1.112 + cout << " 12: " << int(test[12]) << endl;
1.113 + cout << " 22: " << int(test[22]) << endl;
1.114 + cout << " 10: " << int(test[10]) << endl;
1.115 + cout << " 20: " << int(test[20]) << endl;
1.116 + cout << " 11: " << int(test[11]) << endl;
1.117 + cout << " 21: " << int(test[21]) << endl;
1.118 + cout << " 42: " << int(test[42]) << endl;
1.119 +
1.120 +}