-
Notifications
You must be signed in to change notification settings - Fork 0
/
RBTest.cpp
46 lines (45 loc) · 969 Bytes
/
RBTest.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 <random>
#include <functional>
#include "RBTree.h"
using std::cout;
using std::endl;
using structure::Node;
using structure::printNode;
int main() {
int num;
num = 4;
structure::RBTree <int> tree1(num);
tree1.insert(num);
num = 6;
tree1.insert(num);
num = 2;
tree1.insert(num);
num = 1;
tree1.insert(num);
num = 7;
tree1.insert(num);
num = 3;
tree1.insert(num);
num = 5;
tree1.insert(num);
printNode(tree1.getRoot());
/*tree1.getRoot().rotateLeft();
printNode(tree1.getRoot());
num = 4;
tree1.remove(num);
printNode(tree1.getRoot());
num = 5;
tree1.remove(num);
printNode(tree1.getRoot());
num = 6;
tree1.remove(num);
printNode(tree1.getRoot());
Node<int>* node = tree1.minimum();
while(node != nullptr){
cout << node->getKey() << " ";
node = node->successor();
}
cout << endl;*/
return 0;
}