📄 tree.h
字号:
#ifndef __TREE_H__
#define __TREE_H__
typedef unsigned long int weight_t;
typedef unsigned char label_t;//here label_t must be unsigned !;
typedef unsigned long int weight_t,key_t;
typedef struct _T_node node_t, *node_p;
struct _T_node {
key_t Key;
weight_t Weight;
node_p Left;
union {
label_t Label;
node_p Right;
}U;
};
typedef struct _T_label_weight label_weight_t, *label_weight_p;
struct _T_label_weight {
label_t Label;
weight_t Weight;
};
/*******************************************************************************************
*Statist() do second things first statist many bitys the file fp has second find out how *
*many times each code appears in the file and save the information to OutWeightArray *
*
*ConstructTree() also do to things first it construct a huffman tree from the *
*WeightInKeyOutArray and return it Second it out put the key of any code to *
*WeightInKeyOutArray if every elemt of WeightInKeyOutArray is 0 then return 0 *
*TreeSto() store a tree end with the liftest node and store the edges end with external *
*1 *
*LeafNumber() return how many number of the tree root has *
*GetLeft(root) return the Left tree's head address *
*GetRight(root) return the right tree's head address *
*IsLeaf(root) if root is Leaf return 1 else return 0; *
*FreeTree() just free the tree which constructed by ConstructTree***************************/
unsigned int Statist(weight_t OutWeightArray[256],FILE *fp);
node_p ConstructTree(weight_t WeightInKeyOutArray[256]);
void FreeTree(node_p Root);
void TreeSto(node_p const root,FILE *fp);
int LeafNumber(node_p root);
node_p GetRight(node_p root);
node_p GetLeft(node_p root);
int IsLeaf(node_p root);
key_t GetKey(node_p root);
label_t GetLabel(node_p root);
weight_t GetWeight(node_p root);
#endif /* __ERROR_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -