jds.collection
Class SkewHeap

java.lang.Object
  |
  +--jds.collection.SkewHeap

public class SkewHeap
extends java.lang.Object
implements FindMin, SortAlgorithm

SkewHeap - priority queue implemented using skew heap algorithms; for use with book Classic Data Structures in Java by Timothy A Budd, published by Addison-Wesley, 2001.

See Also:
Enumeration, Serializable, Serialized Form

Constructor Summary
SkewHeap(java.util.Comparator t)
          initialize newly created heap
 
Method Summary
 void addElement(java.lang.Object val)
          add a new value to the collection
 java.util.Enumeration elements()
          Yields enumerator for collection
 java.lang.Object getFirst()
          yields the smallest element in collection
 boolean isEmpty()
          Determines whether the collection is empty
 void mergeWith(SkewHeap right)
          merge this heap with another
 void removeFirst()
          removes the smallest element in collection
 int size()
          Determines number of elements in collection
 void sort(Indexed data)
          rearrange collection into asending order
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SkewHeap

public SkewHeap(java.util.Comparator t)
initialize newly created heap
Parameters:
t - comparator to be used to order values
Method Detail

isEmpty

public boolean isEmpty()
Determines whether the collection is empty
Returns:
true if the collection is empty

elements

public java.util.Enumeration elements()
Yields enumerator for collection
Returns:
an Enumeration that will yield the elements of the collection
See Also:
Enumeration

size

public int size()
Determines number of elements in collection
Returns:
number of elements in collection as integer

addElement

public void addElement(java.lang.Object val)
add a new value to the collection
Specified by:
addElement in interface FindMin
Parameters:
value - element to be inserted into collection

getFirst

public java.lang.Object getFirst()
yields the smallest element in collection
Specified by:
getFirst in interface FindMin
Returns:
the first (smallest) value in collection

removeFirst

public void removeFirst()
removes the smallest element in collection
Specified by:
removeFirst in interface FindMin

mergeWith

public void mergeWith(SkewHeap right)
merge this heap with another
Parameters:
right - heap to be combined with current heap

sort

public void sort(Indexed data)
rearrange collection into asending order
Specified by:
sort in interface SortAlgorithm
Parameters:
data - the values to be ordered