-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (27 loc) · 921 Bytes
/
main.cpp
File metadata and controls
32 lines (27 loc) · 921 Bytes
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
#include "huffman.h"
#include <fmt/core.h>
#include <string>
int main() {
std::map<std::string, int> logMessageFrequencies = {
{"INFO", 20},
{"DEBUG", 10},
{"WARNING", 5},
{"ERROR", 2},
{"CRITICAL", 1},
{"FATAL", 1},
{"SUCCESS", 15},
{"VALIDATION", 7},
{"AUTHENTICATION", 8},
{"USER_ACTION", 10},
{"DATABASE", 5}
};
huffman huffman;
huffman.buildHuffmanTable(logMessageFrequencies);
huffman.printHuffmanTable();
std::string testString = "SUCCESS";
std::string encoded_str = huffman.compress(testString);
fmt::print("Encoded string: {}, encoding ratio {}\n", encoded_str, (float) encoded_str.size() / testString.size());
std::string decoded_str = huffman.decompress(encoded_str);
fmt::print("Decoded string: {}\n", decoded_str);
return 0;
}