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

📄 haffmancode.h

📁 哈夫曼编码在文件压缩中有其独特一点
💻 H
字号:
// HaffmanCode.h: interface for the CHaffmanCode class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_HAFFMANCODE_H__97047FC5_4CFC_4C38_8B7A_C3247AC1478A__INCLUDED_)
#define AFX_HAFFMANCODE_H__97047FC5_4CFC_4C38_8B7A_C3247AC1478A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define iMax 1024
#define iNumofCode 511
#define iMaxValue 2147483647
#define iBits 256
#include <iostream>
#include <fstream>
using namespace std;

struct HaffNode
{
	unsigned int iWeight;	
	int iLeftChild;
	int iRightChild;
	int iParent;
	int iFlag;
	HaffNode()
	{iWeight = 0;iLeftChild = -1; iRightChild = -1; iParent = -1; iFlag = 0; }
};

struct Code //用于存每个叶子节点的编码
{
	int iStart;//编码在数组中的开始端
	int Bit[24];//每个都设置为24位的整数

};

class CHaffmanCode
{
private:
	HaffNode *hArray ; 
	Code *codes;
	char Temp[iMax];
    int iNumofBits;
public:
	void CreateHaffmanTree(HaffNode *p);//建立哈夫曼树 
	void EnHaffmanCode(HaffNode *p,Code *cd);//对哈夫曼树的每个节点编码
	float OpenandCloseFile(char *OpenFile,char *CloseFile);//打开文件,调用函数进行编码压缩
	float ChangtoCode(char *OpenFile,char *CloseFile);//使用已有的编码,对文件压缩
	void TranslateCodes(char *OpenFile, char *CloseFile);//译码,解压缩
	CHaffmanCode();
	virtual ~CHaffmanCode();
};

#endif // !defined(AFX_HAFFMANCODE_H__97047FC5_4CFC_4C38_8B7A_C3247AC1478A__INCLUDED_)

⌨️ 快捷键说明

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