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