// cse 373 // header file for adaptive huffman project // a number from 0 to MAXNODE-1, or NONE typedef int NodeIndex; // a number from 0 to NUMSYMBOLS-1 typedef int Symbol; typedef unsigned char Bit; // zero or one // a node in the Huffman tree struct _HuffNode { NodeIndex parent; // index of parent node NodeIndex self; // index of myself NodeIndex c0; // index of left child NodeIndex c1; // index of right child int weight; // count of occurrences Symbol value; // the symbol int isLeftChild; // 0 if left, 1 if right }; typedef struct _HuffNode HuffNode; const int NUMCHARS = 256; const int NUMSYMBOLS = NUMCHARS + 2; const int MAXNODE = NUMSYMBOLS*2-1; // the two special symbols: const int ENDOFFILE = 256; const int UNKNOWN = 257; // used to represent a nonexistent node const int NONE = 999; // the master Huffman structure struct _Huff { HuffNode nodes[NUMSYMBOLS * 2]; NodeIndex symbols[NUMSYMBOLS]; NodeIndex root; NodeIndex nextFree; }; typedef struct _Huff Huff, *PHuff; // an encoded symbol has 'bitcount' bits, stored in the right // side of 'code' struct _EncSymbol { unsigned int code; int bitcount; }; typedef struct _EncSymbol EncSymbol;