00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __MXCPC_HUFFMANTREE_H__
00018 #define __MXCPC_HUFFMANTREE_H__
00019
00020
00021
00022
00025
00028 class mxcpcHuffmanTree {
00029
00030 public:
00031 struct Node {
00032 Node *Child0, *Child1;
00033 bool IsLeaf;
00034 unsigned char Value;
00035 };
00036
00037 private:
00038 Node *RootNode;
00039 Node *GroundNode;
00040
00041 public:
00042 mxcpcHuffmanTree();
00043 ~mxcpcHuffmanTree();
00044
00045 public:
00047 const Node *getRoot(void);
00048
00050 void clear(void);
00051
00054
00058 bool configureFromTable(const unsigned char *table, int max_path_len = 16);
00059
00062
00066 bool addLeaf(int path_len, unsigned char value);
00067
00069 int countLeaves(void);
00070
00071 private:
00073 void deleteSubTree(Node *subtree_root);
00076
00080 bool addLeaf(Node *subtree_root, int path_len, Node *leaf);
00083
00089 void groundUnusedPaths(Node *subtree);
00091 int countLeaves(Node *subtree);
00092 };
00093
00094
00095
00096 #endif // __MXCPC_HUFFMANTREE_H__