org.locomotive.util.data
Class Heap.HeapIterator

java.lang.Object
  |
  +--org.locomotive.util.data.Heap.HeapIterator
Enclosing class:
Heap

public class Heap.HeapIterator
extends java.lang.Object
implements java.util.Enumeration

HeapIterator class creates a pointer to a node in a heap, thus allowing one to access any item in a heap, not just the first


Constructor Summary
Heap.HeapIterator()
          Construct a new iterator on the heap and make the first node to be the "current" node
 
Method Summary
 boolean hasMoreElements()
          The following two methods implement the enumeration interface Returns true if we have not yet reached the end of the heap false otherwise.
 java.lang.Object next()
          Move iterator to point to next node in heap and return the item Should throw a NoSuchElementException if already at end of heap
 java.lang.Object nextElement()
          Return the next item in the heap
 java.lang.Object peek()
          Return the object stored at the current node in the heap Should throw a NoSuchElementException if no current node.
 java.lang.Object pred()
          Move iterator to point to previous node in heap and return the item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Heap.HeapIterator

public Heap.HeapIterator()
Construct a new iterator on the heap and make the first node to be the "current" node
Method Detail

peek

public java.lang.Object peek()
Return the object stored at the current node in the heap Should throw a NoSuchElementException if no current node.

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Move iterator to point to next node in heap and return the item Should throw a NoSuchElementException if already at end of heap

pred

public java.lang.Object pred()
                      throws java.util.NoSuchElementException
Move iterator to point to previous node in heap and return the item. Should throw a NoSuchElementException if already at beginning of heap

hasMoreElements

public boolean hasMoreElements()
The following two methods implement the enumeration interface Returns true if we have not yet reached the end of the heap false otherwise.
Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
Return the next item in the heap
Specified by:
nextElement in interface java.util.Enumeration