-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (40 loc) · 1.12 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include "tree.h"
#include <iostream>
#include <ctime>
#include <set>
int main(int argc, const char * argv[]) {
RBTree<int> tree;
std::set<int> t;
clock_t start1, start2,start3, stop1, stop2, stop3;
double time1, time2, time3;
start2 = clock();
for(int i = 1; i <= 1000000; i++) {
t.insert(i);
}
stop2 = clock();
time2 = (stop2 - start2)/(double)CLOCKS_PER_SEC;
std::cout << "Insertion for std::set t took " <<
time2 << " seconds.\n\n";
start1 = clock();
for(int i = 1; i <= 1000000; i++) {
tree.insert(i);
}
stop1 = clock();
time1 = (stop1 - start1)/(double)CLOCKS_PER_SEC;
std::cout << "Insertion for RBTree<T> tree took " <<
time1 << " seconds.\n\n";
tree.find(500000);
tree.find(1000001);
start3 = clock();
for(int i = 1; i <= 1000000; i++) {
if(i % 2 == 1)
tree.remove(i);
}
stop3 = clock();
time3 = (stop3 - start3)/(double)CLOCKS_PER_SEC;
std::cout << "Deleting odd intergers took " << time3
<< " seconds.\n\n";
//tree.print();
return 0;
}