haffman.h

来自「本程序使用C++编写」· C头文件 代码 · 共 57 行

H
57
字号
// 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 iMaxValue 2147483648
#define iBits 256
#include <iostream>
#include <fstream>
using namespace std;

struct rect
{
	int lenth;
	int wide;
};
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;//编码在数组中的开始端 - 1
	char Bit[255];//每个都设置为255个字符

};

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

#endif // !defined(AFX_HAFFMANCODE_H__97047FC5_4CFC_4C38_8B7A_C3247AC1478A__INCLUDED_)

⌨️ 快捷键说明

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