Java Reference
In-Depth Information
1 // Huffman tree class interface: manipulate Huffman coding tree.
2 //
3 // CONSTRUCTION: with no parameters or a CharCounter object.
4 //
5 // ******************PUBLIC OPERATIONS***********************
6 // int [ ] getCode( ch ) --> Return code given character
7 // int getChar( code ) --> Return character given code
8 // void writeEncodingTable( out ) --> Write coding table to out
9 // void readEncodingTable( in ) --> Read encoding table from in
10 // ******************ERRORS**********************************
11 // Error check for illegal code.
12
13 class HuffmanTree
14 {
15 public HuffmanTree( )
16 { /* Figure 12.19 */ }
17 public HuffmanTree( CharCounter cc )
18 { /* Figure 12.19 */ }
19
20 public static final int ERROR = -3;
21 public static final int INCOMPLETE_CODE = -2;
22 public static final int END = BitUtils.DIFF_BYTES;
23
24 public int [ ] getCode( int ch )
25 { /* Figure 12.19 */ }
26 public int getChar( String code )
27 { /* Figure 12.20 */ }
28
29 // Write the encoding table using character counts
30 public void writeEncodingTable( DataOutputStream out ) throws IOException
31 { /* Figure 12.21 */ }
32 public void readEncodingTable( DataInputStream in ) throws IOException
33 { /* Figure 12.21 */ }
34
35 private CharCounter theCounts;
36 private HuffNode [ ] theNodes = new HuffNode[ BitUtils.DIFF_BYTES + 1 ];
37 private HuffNode root;
38
39 private void createTree( )
40 { /* Figure 12.22 */ }
41 }
figure 12.18
The HuffmanTree class skeleton
Search WWH ::




Custom Search