-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompress.h
More file actions
54 lines (42 loc) · 1.31 KB
/
Compress.h
File metadata and controls
54 lines (42 loc) · 1.31 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
#ifndef COMPRESS_H
#define COMPRESS_H
#include <map>
#include <string>
#include <vector>
#include <memory>
#include <fstream>
using std::string, std::vector, std::map, std::shared_ptr;
class Compress
{
struct BinaryLine
{
string lineContent;
int lineFreq;
unsigned int srcPos;
static bool comp(const BinaryLine &a, const BinaryLine &other);
};
vector<string> srcLines;
vector<BinaryLine> mostFrequent;
// For testing purposes allow additional paths to files. Will be ./ in final
string filepathDirs;
string outfilePath;
std::ofstream outfile;
void initSrcLines();
vector<BinaryLine> getMostFrequentEntries(map<string, std::pair<int, int>>* frequencyDict, int max = 0);
// Returns index of val in *vec, -1 if not found
int valueInVec(string val, vector<BinaryLine>* vec);
unsigned int insertStringToStream(string toAdd, string* stream, unsigned int streamWidth = 32);
string bitmaskCompress(string line);
string mismatch1Bit(string line);
string mismatch2Bit(string line);
string mismatch4Bit(string line);
string mismatch2BitAnywhere(string line);
void mainCompLoop();
void printFreqDict();
void formatFile();
public:
Compress(string filepathDirs);
~Compress();
void run();
};
#endif // COMPRESS_H