Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/dataStructures/searchTrees/unit/testSaTreeMap.cpp
00001 #include "stdinc.h"
00002 #include "SaTreeMap.h"
00003 #include "Util.h"
00004 
00005 using namespace grafalgo;
00006 using namespace std;
00007 
00008 void basicTests() {
00009         int n = 13; string s;
00010         SaTreeMap map(n);
00011         int *perm = new int[n+1];
00012         Util::genPerm(n,perm);
00013         cout << "putting in key order\n";
00014         for (int i = 1; i <= n; i++) {
00015                 map.put(i,perm[i]);
00016                 cout << map.toString(s) << endl;
00017         }
00018         cout << "getting in key order\n";
00019         for (int i = 1; i <= n; i++) {
00020                 cout << map.get(i) << " ";
00021         }
00022         cout << endl;
00023         cout << "changing values in key order\n";
00024         for (int i = 1; i <= n; i++) {
00025                 map.put(i,Util::randint(n+1,5*n));
00026                 cout << map.toString(s) << endl;
00027         }
00028         cout << "getting in key order\n";
00029         for (int i = 1; i <= n; i++) {
00030                 cout << map.get(i) << " ";
00031         }
00032         cout << endl;
00033         cout << "removing in key order\n";
00034         for (int i = 1; i <= n; i++) {
00035                 map.remove(i);
00036                 cout << map.toString(s) << endl;
00037         }
00038         cout << endl;
00039 }
00040 
00041 
00042 int main() {
00043         basicTests();
00044 }
 All Classes Files Functions Variables Typedefs Friends