-
Notifications
You must be signed in to change notification settings - Fork 0
/
Functions.h
37 lines (32 loc) · 1.04 KB
/
Functions.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
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <QtCore>
#include <iostream>
#include <fstream>
#include <vector>
#include <node.h>
#include <heap.h>
#include <huffmantree.h>
#include <cstdlib>
std::vector<int> freqList(std::string fileName);
void displayFreqList(std::vector<int> list);
float check(std::map<int,std::string> mapCode);
float compressionRatio(std::vector<int> freqList, std::map<int,std::string> mapCode);
std::string chooseFileName(std::string originalName, std::string extension);
void encodeFile(std::string fileName);
Node* constructHuffmanTree(std::vector<int> freqList);
void storeTree (Node* node,std::ofstream& file);
Node* decodeTree(std::ifstream& file);
void decodeFile(std::string fileName);
template<typename K, typename V>
std::map<V,K> inverseMap(std::map<K,V> &map)
{
std::map<V,K> inv;
std::for_each(map.begin(), map.end(),
[&inv] (const std::pair<K,V> &p)
{
inv.insert(std::make_pair(p.second, p.first));
});
return inv;
}
#endif // FUNCTIONS_H