forked from patricksheehan/Huffman-Compression
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhuff.h
32 lines (28 loc) · 756 Bytes
/
huff.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
// Patrick Sheehan
#include <cstdlib>
#include <string>
using namespace std;
class Node{
unsigned char data;
unsigned int frequency;
unsigned char min;
Node * leftC;
Node * rightC;
public:
Node(){}
Node(const Node &n){data = n.data; frequency = n.frequency; leftC = n.leftC; rightC = n.rightC;}
Node(unsigned char d, unsigned int f): data(d), frequency(f), min(d){}
Node(Node *, Node *);
void fillCodebook(string *, string &);
bool operator> (const Node &);
};
class Heap{
Node **minHeap;
int heapSize;
public:
Heap(){heapSize = 0; minHeap = new Node*[257];} // max of 255 characters
void push(Node *);
int size(){return heapSize;}
void pop();
Node * top(){return minHeap[1];}
};