class HuffmanNode
extends java.lang.Object
The tag assignments in such a tree are computed from the paths taken from the root to the leaf nodes. Each leaf node represents the particular way one or more compression stream elements wound up being encoded with respect to various combinations of data lengths, shifts, and absolute/relative status.
Huffman's algorithm for constructing binary trees with minimal weighted path lengths can be used to optimize the bit lengths of the tags with respect to the frequency of occurrence of their associated data encodings in the compression stream. The weighted path length is the sum of the frequencies of all the leaf nodes times their path lengths to the root of the tree.
The length of the longest tag determines the size of the table mapping tags to data representations. The geometry compression specification limits the size of the table to 64 entries, so tags cannot be longer than 6 bits. The depth of the tree is reduced through a process of increasing the data lengths of less frequently occuring nodes so they can be merged with other more frequent nodes.
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
HuffmanNode.FrequencyComparator
Sorts nodes in ascending order by frequency.
|
(package private) static class |
HuffmanNode.TagLengthComparator
Sorts nodes in descending order by tag bit length.
|
| Modifier and Type | Field and Description |
|---|---|
(package private) boolean |
absolute |
private HuffmanNode |
child0 |
private HuffmanNode |
child1 |
private boolean |
cleared |
(package private) int |
dataLength |
private int |
frequency |
(package private) static HuffmanNode.FrequencyComparator |
frequencyComparator |
private boolean |
merged |
private HuffmanNode |
mergeNode |
(package private) int |
shift |
(package private) int |
tag |
(package private) int |
tagLength |
(package private) static HuffmanNode.TagLengthComparator |
tagLengthComparator |
private boolean |
unmergeable |
| Constructor and Description |
|---|
HuffmanNode() |
HuffmanNode(int length,
int shift,
boolean absolute) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addChildren(HuffmanNode child0,
HuffmanNode child1) |
(package private) void |
addCount() |
(package private) void |
clear() |
(package private) boolean |
cleared() |
(package private) void |
collectLeaves(int tag,
int tagLength,
java.util.Collection collection) |
(package private) HuffmanNode |
getMergeNode() |
(package private) boolean |
hasCount() |
(package private) int |
incrementLength() |
(package private) boolean |
merged() |
(package private) boolean |
mergeInto(HuffmanNode node) |
(package private) void |
set(int length,
int shift,
boolean absolute) |
(package private) void |
setUnmergeable() |
(package private) boolean |
tokenEquals(HuffmanNode node) |
java.lang.String |
toString() |
(package private) boolean |
unmergeable() |
int tag
int tagLength
int shift
int dataLength
boolean absolute
private int frequency
private HuffmanNode child0
private HuffmanNode child1
private HuffmanNode mergeNode
private boolean merged
private boolean unmergeable
private boolean cleared
static HuffmanNode.FrequencyComparator frequencyComparator
static HuffmanNode.TagLengthComparator tagLengthComparator
HuffmanNode()
HuffmanNode(int length,
int shift,
boolean absolute)
void clear()
final void set(int length,
int shift,
boolean absolute)
final boolean cleared()
final void addCount()
final boolean hasCount()
final boolean tokenEquals(HuffmanNode node)
void addChildren(HuffmanNode child0, HuffmanNode child1)
void collectLeaves(int tag,
int tagLength,
java.util.Collection collection)
boolean mergeInto(HuffmanNode node)
int incrementLength()
final boolean merged()
final HuffmanNode getMergeNode()
void setUnmergeable()
final boolean unmergeable()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.