-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymbol.cpp
More file actions
78 lines (64 loc) · 1.07 KB
/
Symbol.cpp
File metadata and controls
78 lines (64 loc) · 1.07 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "Symbol.h"
Symbol::Symbol(int symbolAscii)
{
_symbolAscii = symbolAscii;
_leaf = new BinaryTree::Node();
_code = "";
}
void Symbol::IncrementFrequency()
{
_leaf->IncrementRank();
}
int Symbol::Frequency()
{
return _leaf->Rank();
}
int Symbol::AsciiCode()
{
return _symbolAscii;
}
BinaryTree::Node* Symbol::Leaf()
{
return _leaf;
}
void Symbol::CreateCode()
{
_code = _leaf->CreateCode();
}
std::string Symbol::Code()
{
return _code;
}
Symbol2Char::Symbol2Char(int symbolAscii1, int symbolAscii2)
{
_symbolsAscii = std::make_pair(symbolAscii1, symbolAscii2);
_leaf = new BinaryTree::Node();
_code = "";
}
void Symbol2Char::IncrementFrequency()
{
_leaf->IncrementRank();
}
int Symbol2Char::Frequency()
{
return _leaf->Rank();
}
std::string Symbol2Char::StringCode()
{
std::string retVal;
retVal = (char)_symbolsAscii.first;
retVal += (char)_symbolsAscii.second;
return retVal;
}
BinaryTree::Node* Symbol2Char::Leaf()
{
return _leaf;
}
void Symbol2Char::CreateCode()
{
_code = _leaf->CreateCode();
}
std::string Symbol2Char::Code()
{
return _code;
}