-
Notifications
You must be signed in to change notification settings - Fork 2
/
node.h
45 lines (38 loc) · 969 Bytes
/
node.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
class Node
{
public:
// Constructors.
Node();
Node(char symbol, int frequency);
Node(char symbol, int frequency, Node* prev, Node* next);
Node(int frequency, Node* left, Node* right);
Node(char symbol, int frequency, Node* prev, Node* next, Node* left, Node* right);
// Destructor.
~Node();
// Getters and Setters.
void setSymbol(char symbol);
char getSymbol();
void setFrequency(int frequency);
int getFrequency();
void setPrev(Node* prev);
Node* getPrev();
void setNext(Node* next);
Node* getNext();
void setLeft(Node* left);
Node* getLeft();
void setRight(Node* right);
Node* getRight();
// Methods.
void print();
bool isLeaf();
// Overloads.
friend std::ostream& operator<< (std::ostream& stream, Node& node);
private:
// Attributes.
char symbol;
int frequency;
Node* prev;
Node* next;
Node* left;
Node* right;
};