Coder Social home page Coder Social logo

-'s Introduction

一个多媒体压缩的小作业

一、结点的构造 struct TreeNode {
char name;
double weight;
TreeNode* left;
TreeNode* right;
TreeNode(char chara, double cweight) :name(chara), weight(cweight), left(NULL), right(NULL) {}
TreeNode() :name('0'), weight(0.0), left(NULL), right(NULL) {}
};
分别是字符名称,权重,左右孩子结点,以及两个构造函数

二、函数解释
1.pTree CreatHuffman(vector NodeSet);
通过此函数你可以生成一个哈夫曼树,返回树的头结点

2.void traceback(pTree root, string code, unordered_map<char, string>& CodeSet);
通过此函数回溯遍历哈夫曼树,得到字符相应的哈夫曼编码

3.pTree KeyboardIN(string s, unordered_map<char, int>& alph);
此函数将1号函数集成在其中,生成字母表权重表,和对应的哈夫曼树

4.unordered_map<char, string> GetHash(pTree root);
集成了traceback函数得到哈夫曼编码表

5.QString getRate(unordered_map<char, string> codeset, unordered_map<char, int> alph, int Sumweight);
得到压缩比率,返回QString给对话框传递提示信息

6.QString Compression(string s,unordered_map<char, string> codeset,QString fileName);
压缩函数,返回提示信息

7.QString Excute(string s,QString save_path);
整体执行函数,返回提示信息

8.QString s2q(const string& s);
将string转换为QString

9.string q2s(const QString& s);
将QString转换为string

10.string inttobinarystring(int value);
将int值转换为二进制字符串,用在解压缩

11.int binarystringtoint(string binarystring);
将二进制字符串转换为int值,用在压缩

12.QString decode(QString path,QString save_path);
解压缩函数

-'s People

Contributors

creatyy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.