-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHuffmanTreeNode.h
65 lines (50 loc) · 1.68 KB
/
HuffmanTreeNode.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* File: HuffmanTreeNode.h
* Author: Anas
*
* Created on December 30, 2012, 4:35 AM
*/
#ifndef HUFFMANTREENODE_H
#define HUFFMANTREENODE_H
#include <iostream>
#include "PQueueNode.h"
using namespace std;
class HuffmanTreeNode {
public:
int count;
char character;
PQueueNode<HuffmanTreeNode> * leftHuffmanTree;
PQueueNode<HuffmanTreeNode> * rightHuffmanTree;
HuffmanTreeNode(int x = 0, char c = '\0') {
count = x;
character = c;
leftHuffmanTree = 0;
rightHuffmanTree = 0;
}
bool operator>(const HuffmanTreeNode& toCompare) {
return (this->count > toCompare.count);
}
bool operator<(const HuffmanTreeNode& toCompare) {
return (this->count < toCompare.count);
}
bool operator>=(const HuffmanTreeNode& toCompare) {
return (this->count >= toCompare.count);
}
bool operator<=(const HuffmanTreeNode& toCompare) {
return (this->count <= toCompare.count);
}
bool operator!=(const HuffmanTreeNode& toCompare) {
return (this->count != toCompare.count && this->character != toCompare.character);
}
HuffmanTreeNode operator=(const HuffmanTreeNode& toCompare) {
this->count = toCompare.count;
this->character = toCompare.character;
this->leftHuffmanTree = toCompare.leftHuffmanTree;
this->rightHuffmanTree = toCompare.rightHuffmanTree;
return *this;
}
friend ostream &operator<<(ostream &out, HuffmanTreeNode node) {
return ( out << "Frequency = " << node.count << ", character = \'" << node.character << "\'");
}
};
#endif /* HUFFMANTREENODE_H */