-
Notifications
You must be signed in to change notification settings - Fork 0
/
huffman_tree_item.hpp
56 lines (44 loc) · 1.29 KB
/
huffman_tree_item.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _BINARYITEM_
#define _BINARYITEM_
#include <istream>
#include <ostream>
class HuffmanTreeItem
{
friend std::ostream& operator << (std::ostream& os,HuffmanTreeItem* item);
friend std::istream& operator >> (std::istream& is,HuffmanTreeItem* item);
public:
enum class NodeType{
LEAF,
MIDDLE,
DEFAULT
};
struct NodeContent
{
double percent;
char c;
NodeType type;
} ;
public:
HuffmanTreeItem();
HuffmanTreeItem(NodeContent content);
void SetParent(HuffmanTreeItem* parent);
void SetLeft(HuffmanTreeItem* left);
void SetRight(HuffmanTreeItem* right);
NodeContent GetContent() ;
HuffmanTreeItem* GetParent();
HuffmanTreeItem* GetLeft();
HuffmanTreeItem* GetRight();
private:
HuffmanTreeItem(HuffmanTreeItem& item);
private:
HuffmanTreeItem* _left;
HuffmanTreeItem* _right;
HuffmanTreeItem* _parent;
private:
NodeContent _content;
};
std::ostream& operator << (std::ostream& os,HuffmanTreeItem* const item);
std::istream& operator >> (std::istream& is,HuffmanTreeItem* const item);
std::ostream& operator << (std::ostream& os,HuffmanTreeItem::NodeContent& content);
std::istream& operator >> (std::istream& is,HuffmanTreeItem::NodeContent& content);
#endif //!_BINARYITEM_