class Huffman.Node extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Huffman.Node>
Modifier and Type | Field and Description |
---|---|
(package private) byte[] |
cde
code (variable length)
|
(package private) int |
codeLength
code length in bits
|
(package private) int |
frequency
frequency of the symbol in source data
|
(package private) Huffman.Node |
left
left child, 0 is appended to the code
|
(package private) Huffman.Node |
right
right child, 1 is appended to the code
|
static long |
serialVersionUID
serialization version id
|
(package private) byte |
symbol
byte to encode (for the leaf nodes)
|
Constructor and Description |
---|
Huffman.Node()
Default constructor.
|
Huffman.Node(byte sy,
int fr)
Constructor for leaves with byte data.
|
Huffman.Node(char ch,
int fr)
Constructor for leaves with char data.
|
Huffman.Node(Huffman.Node vs,
Huffman.Node pr,
int fr)
Constructor for intermediate nodes.
|
Huffman.Node(int fr,
Huffman.Node vs,
Huffman.Node pr)
Constructor for intermediate nodes.
|
Modifier and Type | Method and Description |
---|---|
(package private) int |
bitsCounted()
Length of source data in bits.
|
int |
compareTo(Huffman.Node tt)
Less frequent nodes come first.
|
(package private) void |
setCode(int lngth,
byte[] nodeCode)
Calculating codes for this tree starting from the root (recursive).
|
public static final long serialVersionUID
Huffman.Node left
Huffman.Node right
byte symbol
int frequency
int codeLength
byte[] cde
Huffman.Node()
Huffman.Node(byte sy, int fr)
Huffman.Node(char ch, int fr)
Huffman.Node(int fr, Huffman.Node vs, Huffman.Node pr)
Huffman.Node(Huffman.Node vs, Huffman.Node pr, int fr)
public int compareTo(Huffman.Node tt)
compareTo
in interface java.lang.Comparable<Huffman.Node>
void setCode(int lngth, byte[] nodeCode)
lngth
- length of the code for this node in bitsnodeCode
- code of this nodeint bitsCounted()