⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 h1.h

📁 自己做的数据结构实验题(合并链表
💻 H
字号:
#include <vector>
#include <queue>
#include <iostream>
#include <string>



class huffman{
public:


class compare{
public:
	
	struct huffman_node;
typedef huffman_node *node_ptr;

struct huffman_node{
char id;
int freq;
string code;
node_ptr left,
         right,
		 parent;
};
	bool operator()(const node_ptr& c1,const node_ptr& c2)const{
	return (*c1).freq>(*c2).freq;
	}
};


	huffman(string in_file_name,string out_file_name);//根据路径初始化
	void create_pq();//创建优先队列 用于构建二叉树
	void create_huffman_tree();//创建huffman tree
	void calculate_huffman_codes();//编码
	void save_to_file();//保存编码
	static const int MAX_SIZE=256;
	node_ptr node_array[MAX_SIZE];
private:
	priority_queue<node_ptr,vector<node_ptr>,compare> pq;
	fstream in_file,
		    out_file;
	string in_file_name;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -