Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

proovethetruth/Huffmans-Algorithm

Repository files navigation

Haffmans-Algorithm

Huffman's Algorithm implementation on C++. Uses priority_queue for storing nodes. Involves bitwise operations for compressing and decompressing files. At this point, works fine with some types of files

Contents of HeaderFile:

#include <string>
#include <unordered_map>

Classes

struct Node
Структура узла дерева Хаффмана Узел дерева Хаффмана содержит символ, частоту его появления, а также указатель на сопряжённые ветви. More...
struct comp
Структура, описывающая операцию сравнения элементов для приоритетной очереди More...

Functions

int check_task (char *argv[])
Функция для определения задачи (сжатие / разархивация) More...
std::string gen_en_filename (std::string original)
Функция для генерации имени сжатого файла More...
std::string gen_de_filename (std::string original)
Функция для генерации имени разархивированного файла More...
void insert_zeros_counter (std::ofstream &outfile, int bits)
Функция для записи кол-ва дополнительных нулей в бинарный файл More...
void writeBinaryString (std::ofstream &outfile, std::string &str)
Функция для записи битовой строки в бинарный файл More...
void writeBinaryTree (Node *node, std::string &result)
Функция для генерации строковой репрезентации бинарного дерева Хаффмана More...
Node * readBinaryTree (std::string &str, int &index)
Функция для генерации бинарного дерева Хаффмана на основе его строковой репрезентации More...
int parse_file (std::string &name, std::string &text)
Функция для считывания исходного текста More...
int parse_tree (std::ifstream &infile, std::string &text)
Функция для считывания строковой репрезентации дерева из бинарного файла More...
void parse_binary_text (std::ifstream &infile, std::string &text, int tree_size, int zeros)
Функция для считывания байтов текста из бинарного файла More...
Node * addNode (char ch, int freq, Node *left, Node *right)
Функция для создания узла More...
int pack (std::string &name)
Функция для архивации текста More...
void encode (Node *root, std::string str, std::unordered_map< char, std::string > &huffmanCode)
Функция для определения кодов символов More...
std::unordered_map< char, int > find_frequency (std::string &text)
Функция для определения частоты употребления символов в исходном тексте More...
Node * build_tree (std::unordered_map< char, int > freq)
Функция для генерации дерева Хаффмана More...
int unpack (std::string &name)
Функция для разархивации текста More...
void decode (Node *root, std::string &str, std::ofstream &outfile)
Функция для декодирования битовой последовательности More...

About

Huffman's Algorithm implementation on C++

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /