-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.h
More file actions
46 lines (36 loc) · 1.05 KB
/
Copy pathNode.h
File metadata and controls
46 lines (36 loc) · 1.05 KB
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
#ifndef NODE_H
#define NODE_H
struct Node {
Node(char letter, int weight) {
this->letter = letter;
this->weight = weight;
this->zero = nullptr;
this->one = nullptr;
this->code = "";
}
Node(char letter, int weight, Node *zero, Node *one) {
this->letter = letter;
this->weight = weight;
this->zero = zero;
this->one = one;
this->code = "";
}
char letter; // letter character to be stored
Node* zero;
Node* one;
int weight; // count for how many times the character is used in the file
std::string code; // binary string code created from the huffman tree
};
#endif //NODE_H
#ifndef COMPARE_WEIGHTS
#define COMPARE_WEIGHTS
/**
* Class needed for the to compare Nodes in the priority queue
* @see https://www.geeksforgeeks.org/stl-priority-queue-for-structure-or-class/
*/
struct compareWeights{
bool operator()(Node* const& lhs, Node* const& rhs){
return lhs->weight > rhs->weight;
}
};
#endif // COMPARE_WEIGHTS