heap
Class HeapAscending

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by heap.HeapAscending
All Implemented Interfaces:
HeapImpl, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

public class HeapAscending
extends java.util.Vector
implements HeapImpl

An implementation of a priority queue according to Cormen, Leiserson and Rivest. Sorts in ascending order.

Version:
1.0 2/23/96
Author:
Michael J. Radwin
See Also:
Serialized Form

Constructor Summary
HeapAscending()
          Constructs a heap with no elements.
HeapAscending(Heapable[] anArray)
          Constructs the heap in O(N) time, using a technique similar to bottom-up construction.
 
Method Summary
 Heapable extract()
          Removes the minimum (top) element from the Heap, decreases the size of the heap by one, and returns the minimum element.
 long getPriority()
           
 void insert(Heapable key)
          Inserts key into the heap, and then upheaps that key to a position where the heap property is satisfied.
 Heapable remove()
          Removes an element from the heap.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface heap.HeapImpl
isEmpty, removeAllElements, size
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

HeapAscending

public HeapAscending(Heapable[] anArray)
Constructs the heap in O(N) time, using a technique similar to bottom-up construction.


HeapAscending

public HeapAscending()
Constructs a heap with no elements.

Method Detail

extract

public Heapable extract()
                 throws java.util.NoSuchElementException
Removes the minimum (top) element from the Heap, decreases the size of the heap by one, and returns the minimum element.

Specified by:
extract in interface HeapImpl
Throws:
java.util.NoSuchElementException

remove

public Heapable remove()
                throws java.util.NoSuchElementException
Removes an element from the heap.

Specified by:
remove in interface HeapImpl
Throws:
java.util.NoSuchElementException

insert

public void insert(Heapable key)
Inserts key into the heap, and then upheaps that key to a position where the heap property is satisfied.

Specified by:
insert in interface HeapImpl

getPriority

public long getPriority()
Specified by:
getPriority in interface HeapImpl