#include <FelixCompress.hh>
Definition at line 29 of file FelixCompress.hh.
dune::HuffTree::~HuffTree |
( |
| ) |
|
|
inline |
void dune::HuffTree::generate_codes |
( |
Node * |
loc, |
|
|
size_t |
buff = 0 , |
|
|
uint8_t |
len = 0 |
|
) |
| |
|
inline |
Definition at line 114 of file FelixCompress.hh.
116 if (loc->
left == NULL) {
117 loc->huffcode = buff;
118 loc->hufflength = len;
std::unordered_map< uint16_t, Node * > nodes
void dune::HuffTree::generate_codes |
( |
| ) |
|
|
inline |
Definition at line 132 of file FelixCompress.hh.
134 std::sort(nodevec.begin(), nodevec.end());
136 const unsigned totlen = 2 * nodevec.size() - 1;
142 for (
unsigned i = 0; i < totlen - nodevec.size(); ++i) {
145 while (lowest->hasParent) {
148 Node* sec_lowest = lowest + 1;
149 while (sec_lowest->hasParent) {
157 if (
n->frequency < lowest->frequency) {
160 }
else if (
n->frequency < sec_lowest->frequency &&
n != lowest) {
166 if (lowest->frequency == sec_lowest->frequency &&
167 lowest->value > sec_lowest->value) {
175 newNode->
left = lowest;
176 newNode->
right = sec_lowest;
177 newNode->frequency = lowest->frequency + sec_lowest->frequency;
178 lowest->hasParent =
true;
179 sec_lowest->hasParent =
true;
std::unordered_map< uint16_t, Node * > nodes
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Node* dune::HuffTree::operator() |
( |
const uint16_t |
value | ) |
|
|
inline |
Definition at line 68 of file FelixCompress.hh.
std::unordered_map< uint16_t, Node * > nodes
void dune::HuffTree::print |
( |
Node * |
loc | ) |
|
|
inline |
Definition at line 71 of file FelixCompress.hh.
72 if (loc->
left == NULL) {
73 std::cout <<
"Node with value " << loc->value <<
", frequency " 74 << loc->frequency <<
" and huffcode " 75 << std::bitset<32>(loc->huffcode) <<
" length " 76 << (
unsigned)loc->hufflength << '\
n';
void dune::HuffTree::print |
( |
| ) |
|
|
inline |
void dune::HuffTree::printFile |
( |
std::string & |
filename | ) |
|
|
inline |
Definition at line 86 of file FelixCompress.hh.
89 ofile <<
"Value\tFrequency\tCode\tLength\n";
90 std::vector<Node*> local_nlist;
94 if(n->frequency == 0)
continue;
95 local_nlist.push_back(n);
98 std::sort(local_nlist.begin(), local_nlist.end());
100 for(
unsigned i = 0; i < local_nlist.size(); ++i) {
101 Node* n = local_nlist[i];
102 if(n->value > (1<<16)/2) {
103 ofile << (
int)n->value-(1<<16) <<
'\t' << n->frequency <<
'\t' << n->huffcode <<
'\t' << (unsigned)n->hufflength <<
'\n';
105 if(n->value > 1000)
continue;
106 ofile << n->value <<
'\t' << n->frequency <<
'\t' << n->huffcode <<
'\t' << (unsigned)n->hufflength <<
'\n';
std::unordered_map< uint16_t, Node * > nodes
bool dune::HuffTree::valuecomp |
( |
const Node & |
one, |
|
|
const Node & |
other |
|
) |
| const |
|
inline |
Node* dune::HuffTree::nodelist |
std::unordered_map<uint16_t, Node*> dune::HuffTree::nodes |
Node* dune::HuffTree::root |
The documentation for this struct was generated from the following file: