com.mhhe.clrs2e
Class Huffman.InternalNode

java.lang.Object
  |
  +--com.mhhe.clrs2e.Huffman.Node
        |
        +--com.mhhe.clrs2e.Huffman.InternalNode
All Implemented Interfaces:
java.lang.Comparable, DynamicSetElement
Enclosing class:
Huffman

private static class Huffman.InternalNode
extends Huffman.Node
implements DynamicSetElement

Inner class for an internal node in a Huffman tree.


Nested Class Summary
 
Nested classes inherited from class com.mhhe.clrs2e.DynamicSetElement
DynamicSetElement.Helper
 
Field Summary
private  Huffman.Node left
          This node's left child.
private  Huffman.Node right
          This node's right child.
 
Constructor Summary
Huffman.InternalNode(Huffman.Node left, Huffman.Node right)
          Creates a new internal node.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this node to another, based on their frequencies.
 java.lang.Comparable getKey()
          Returns the frequency as the key.
 void setKey(java.lang.Comparable key)
          Cannot set the key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.mhhe.clrs2e.DynamicSetElement
compareTo, getKey, setKey
 

Field Detail

left

private final Huffman.Node left
This node's left child.


right

private final Huffman.Node right
This node's right child.

Constructor Detail

Huffman.InternalNode

public Huffman.InternalNode(Huffman.Node left,
                            Huffman.Node right)
Creates a new internal node.

Parameters:
left - This node's left child.
right - This node's right child.
Method Detail

setKey

public void setKey(java.lang.Comparable key)
Cannot set the key.

Specified by:
setKey in interface DynamicSetElement
Parameters:
key - The key, but it cannot be set.
Throws:
java.lang.UnsupportedOperationException - always.

getKey

public java.lang.Comparable getKey()
Returns the frequency as the key.

Specified by:
getKey in interface DynamicSetElement

compareTo

public int compareTo(java.lang.Object o)
Compares this node to another, based on their frequencies.

Specified by:
compareTo in interface DynamicSetElement
Parameters:
o - The other node.
Returns:
A negative integer if this node's frequency is less, 0 if the nodes have equal frequencies, or a positive integer if this node's frequency is greater.
Throws:
java.lang.ClassCastException - if o does not reference a Node object.