-
Notifications
You must be signed in to change notification settings - Fork 0
/
crbtree.h
51 lines (36 loc) · 969 Bytes
/
crbtree.h
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
enum LR { LEFT, RIGHT };
enum COLOR { RED, BLACK, NONE };
class node {
COLOR color;
int value;
node* parent;
node* left;
node* right;
public:
node(int, COLOR);
COLOR getColor();
void setColor(COLOR);
int getValue();
node* getGrandparent();
node* getUncle();
node* get(LR);
void set(node*,LR);
node* getLeft();
void setLeft(node*);
node* getRight();
void setRight(node*);
node* getParent();
void detach();
bool operator==(const node&);
bool isRoot();
};
node leaf(0, BLACK);
// http://en.wikipedia.org/w/index.php?title=Red%E2%80%93black_tree&oldid=482155076#Operations
void BTInsert(node* n, node* root);
void insert(node* n, node* root);
void insert_case1(node* n);
void insert_case2(node* n);
void insert_case3(node* n);
void insert_case4(node* n);
void insert_case5(node* n);
void rotate(node*,LR);