-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHuffmanTree.hpp
33 lines (25 loc) · 915 Bytes
/
HuffmanTree.hpp
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
#ifndef HUFFMANTREE_H
#define HUFFMANTREE_H
#include "HuffmanBase.hpp"
#include "HeapQueue.hpp"
#include <map>
#include <queue>
#include <functional>
#include <string>
#include <iostream>
// HuffmanTree class definition
class HuffmanTree : public HuffmanTreeBase {
private:
HuffmanNode* root;
std::map<char, std::string> huffmanCodes;
std::map<std::string, char> reverseHuffmanCodes;
//void printTree(const HuffmanNode* node, const std::string& prefix = "", bool isLeft = true) const;
public:
HuffmanTree() : root(nullptr) {}
~HuffmanTree();
std::string compress(const std::string inputStr) override;
std::string serializeTree() const override;
std::string decompress(const std::string inputCode, const std::string serializedTree) override;
bool isValidSerializedTree(const std::string& serializedTree);
};
#endif /* HUFFMANTREE_H */