-
Notifications
You must be signed in to change notification settings - Fork 1
/
verbose.h
101 lines (90 loc) · 1.62 KB
/
verbose.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// verbose.h
/* Debug mode */
/******************/
#ifndef VERBOSE
#define VERBOSE 0
#include <iostream>
#include <iomanip> /* setw() */
using std::setw;
using std::cout;
using std::endl;
/******************/
#include "node.h"
void
printTree(Node const * curr,
int level)
{
if (VERBOSE)
if (curr)
{
printTree(curr->right, level + 1);
cout << setw(level * 5)
<< curr->c
<< ": "
<< curr->frequency
<< ": "
<< level
<< endl;
printTree(curr->left, level + 1);
}
}
void
printCodeLength(vector<BYTE> &length)
{
if (VERBOSE)
{
cout << "Code length: " << endl;
for (int c = 0; c < MAX_SYMBOLS; ++c)
if (length[c])
cout << c
<< ": "
<< length[c]
<< endl;
}
}
void
printFrequences(vector<Size_t> &freq)
{
if (VERBOSE)
{
cout << "Frequencies:" << endl;
for (int c = 0; c < MAX_SYMBOLS; ++c)
if (freq[c])
cout << c
<< ": "
<< freq[c]
<< endl;
}
}
void
printStartCode(vector<BYTE> &startCode,
BYTE max_length)
{
if (VERBOSE)
{
cout << "Start code: " << endl;
for (Size_t c = 1; c <= max_length; ++c)
cout << c
<< ": "
<< startCode[c]
<< endl;
}
}
void
printReversedCode(vector<vector<bool> > &table)
{
if (VERBOSE)
{
cout << "Reversed code: " << endl;
for (int c = 0; c < MAX_SYMBOLS; ++c)
if (table[c].size())
{
cout << (char) c
<< ": ";
for (Size_t n = 0; n < table[c].size(); ++n)
cout << table[c][n];
cout << endl;
}
}
}
#endif /* VERBOSE */