-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDo.cpp
60 lines (59 loc) · 1.62 KB
/
Do.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Tree.h"
#include "random_op.h"
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
Tree<int> tree;
int total_ops;
int seed;
int range;
char op;
int print_op;
cout << "Enter maximum range: " << endl;
cin >> range;
cout << "Number of operations: " << endl;
cin >> total_ops;
cout << "Enter seed: " << endl;
cin >> seed;
cout << "Enter print option (0 for no keys, 1 for keys): " << endl;
cin >> print_op;
cout << endl;
tree.MLH_set_print_option(print_op);
Random_operation random_op(seed, range);
for(int i = 1; i < total_ops; i++)
{
int* deleted;
int inserted;
int* obtained;
random_op.Randomize_next_op();
op = random_op.Get_op();
switch(op)
{
case 'G':
obtained = tree.MLH_Get(random_op.Get_key());
break;
case 'D':
deleted = tree.MLH_Delete(random_op.Get_key());
delete deleted;
break;
case 'I':
int* integer = new int(i);
inserted = tree.MLH_Insert(random_op.Get_key(), integer);
if(inserted == 0)
{
delete integer;
}
break;
};
if( i % (total_ops/10) == 0)
{
cout << "Printing after: " << i << " operations." << endl;
tree.print_tree();
}
}
cout << "Printing after: " << total_ops << " operations." << endl;
tree.print_tree();
}