Class HuffmanHeap

java.lang.Object
  extended by HuffmanHeap

public class HuffmanHeap
extends java.lang.Object

An HNode min-heap (priority queue) for generating Huffman codes. The HNode getFrequency() method is used for the key/priority.


Constructor Summary
HuffmanHeap()
           
 
Method Summary
 void insert(HNode node)
          Insert a node into the heap.
 boolean isEmpty()
          Predicate for empty heap.
 HNode remove()
          Remove the min-node (root) of this heap.
 int size()
          Return the number of nodes in this heap.
 java.lang.String toString()
          Printable string.
Format: <Heap: node0;node1; ...>
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HuffmanHeap

public HuffmanHeap()
Method Detail

isEmpty

public boolean isEmpty()
Predicate for empty heap.

Returns:
true if this heap has no nodes; false otherwise

size

public int size()
Return the number of nodes in this heap.

Returns:
number of nodes in this heap

insert

public void insert(HNode node)
Insert a node into the heap.

Parameters:
node - the node to be inserted

remove

public HNode remove()
Remove the min-node (root) of this heap.

Returns:
the min-node

toString

public java.lang.String toString()
Printable string.
Format: <Heap: node0;node1; ...>

Overrides:
toString in class java.lang.Object
Returns:
formatted representation of this heap