home *** CD-ROM | disk | FTP | other *** search
- #include <LEDA/ab_tree.h>
- #include <LEDA/bb_tree.h>
- #include <LEDA/rb_tree.h>
- #include <LEDA/ch_hashing.h>
- #include <LEDA/dp_hashing.h>
-
- main()
-
- {
- ab_tree AB_TREE;
- bb_tree BB_TREE;
- rb_tree RB_TREE;
- dphash DP_HASH;
- ch_hashing CH_HASH;
-
- print_statistics();
- Yes("->");
-
- int N = read_int("# keys = ");
- void** RAND = new void*[N];
- int i;
-
- init_random();
-
- for(i=0; i<N; i++) RAND[i] = (void*)random(0,MAXINT-1);
-
- float T = used_time();
-
- print_statistics();
- Yes("->");
-
- newline;
- cout << " insert lookup delete";
- newline;
- newline;
- cout << "ab_tree: ";
- cout.flush();
- for(i=0; i<N; i++) AB_TREE.insert(RAND[i],0);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) AB_TREE.lookup(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) AB_TREE.del(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
- newline;
-
- print_statistics();
- Yes("->");
-
-
- cout << "bb_tree: ";
- cout.flush();
- for(i=0; i<N; i++) BB_TREE.insert(RAND[i],0);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) BB_TREE.lookup(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) BB_TREE.del(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
- newline;
-
-
- print_statistics();
- Yes("->");
-
-
- cout << "rb_tree: ";
- cout.flush();
- for(i=0; i<N; i++) RB_TREE.insert(RAND[i],0);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) RB_TREE.lookup(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) RB_TREE.del(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
- newline;
-
-
- print_statistics();
- Yes("->");
-
-
- cout << "ch_hash: ";
- cout.flush();
- for(i=0; i<N; i++) CH_HASH.insert(RAND[i],0);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) CH_HASH.lookup(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) CH_HASH.del(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
- newline;
-
-
- print_statistics();
- Yes("->");
-
- cout << "dp_hash: ";
- cout.flush();
- for(i=0; i<N; i++) DP_HASH.insert(RAND[i],0);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) DP_HASH.lookup(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
-
- for(i=0; i<N; i++) DP_HASH.del(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
- newline;
-
- print_statistics();
-
- }
-
-