-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.cpp
79 lines (64 loc) · 1.29 KB
/
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "node.h"
Node::Node(){
frequency = 0;
byte = 0;
left = 0;
right = 0;
position = 0;
}
bool Node::isSingle(){
bool answer = true;
if(this->left != 0 && this->right != 0){
answer = false;
}
return answer;
}
bool Node::isLeaf(){
bool answer = false;
if(this->left == 0 && this->right == 0){
answer = true;
}
return answer;
}
void Node::incFrequency(int increase){
this->frequency += increase;
}
int Node::getFrequency() const{
return this->frequency;
}
void Node::setFrequency(int frequency){
this->frequency = frequency;
}
unsigned char Node::getByte() const{
return byte;
}
void Node::setByte(unsigned char byte){
this->byte = byte;
}
Node *Node::getLeft()const{
return left;
}
bool Node::isLeft(){
if(position == 1){
return true;
}
return false;
}
void Node::setLeft(const Node *left){
this->left = (Node*)left;
}
Node *Node::getRight()const{
return right;
}
bool Node::isRight(){
if(position == 2){
return true;
}
return false;
}
void Node::setRight(const Node *right){
this->right = (Node*)right;
}
void Node::setPosition(int position){
this->position = position;
}