-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.cpp
61 lines (47 loc) · 852 Bytes
/
node.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
61
#include "node.h"
Node::Node(string k) {
key = k;
left = nullptr;
right = nullptr;
parent = nullptr;
parenttype = 0;
size = 1;
}
unsigned int Node::update_size() {
size = ((left == nullptr) ? 0 : left->size) + ((right == nullptr) ? 0 : right->size) + 1;
return size;
}
string Node::get_key() {
return key;
}
unsigned int Node::get_size() {
return size;
}
Node* Node::get_left() {
return left;
}
Node* Node::get_right() {
return right;
}
Node* Node::get_parent() {
return parent;
}
unsigned int Node::get_parenttype() {
return parenttype;
}
void Node::set_key(string k) {
key = k;
}
void Node::set_left(Node* l) {
left = l;
}
void Node::set_right(Node* r) {
right = r;
}
void Node::set_parent(Node* p, unsigned int pType) {
parent = p;
parenttype = pType;
}
void Node::inc_size() {
size++;
}