-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHCNode.cpp
More file actions
41 lines (32 loc) · 904 Bytes
/
Copy pathHCNode.cpp
File metadata and controls
41 lines (32 loc) · 904 Bytes
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
#ifndef HCNODE_H
#define HCNODE_H
#include <iostream>
typedef unsigned char byte;
using namespace std;
/** A class, instances of which are nodes in an HCTree.
*/
class HCNode {
public:
int count;
byte symbol; // byte in the file we're keeping track of
HCNode* c0; // pointer to '0' child
HCNode* c1; // pointer to '1' child
HCNode* p; // pointer to parent
HCNode(int count,
byte symbol,
HCNode* c0 = 0,
HCNode* c1 = 0,
HCNode* p = 0)
: count(count), symbol(symbol), c0(c0), c1(c1), p(p) { }
/** Less-than comparison, so HCNodes will work in std::priority_queue
* We want small counts to have high priority.
* And we want to break ties deterministically.
*/
bool operator<(const HCNode& other){
if(this->count < other.count){
return true;
}
else return false;
};
};
#endif // HCNODE_H