goldman.collection.priority
Class LeftistHeap.Tracker

java.lang.Object
  extended by goldman.collection.AbstractCollection.AbstractLocator<E>
      extended by goldman.collection.priority.LeftistHeap.Tracker
All Implemented Interfaces:
Locator<E>, PriorityQueueLocator<E>, Cloneable, Iterator<E>
Enclosing class:
LeftistHeap<E>

protected class LeftistHeap.Tracker
extends AbstractCollection.AbstractLocator<E>
implements PriorityQueueLocator<E>


Field Summary
 
Fields inherited from class goldman.collection.AbstractCollection.AbstractLocator
versionNumber
 
Method Summary
 boolean advance()
          Advances to the next element in the collection (if there is one) and returns true.
 void decreasePriority(E element)
          Replaces the tracked element by element
REQUIRES: the given parameter is less than e, or that e is the parameter being passed and its value has been mutated to have a lower priority than it had previously.
 E get()
          Returns the element associated with this locator.
 boolean hasNext()
           
 boolean inCollection()
          Returns true if and only if the locator is at an element of the collection.
 void increasePriority(E element)
          Replaces the tracked element by element
REQUIRES: the given parameter is greater than e, or that e is the parameter being passed and its value has been mutated to have a higher priority than it had previously.
 void remove()
          Removes the tracked element from the collection
 boolean retreat()
          Retreats to the previous element in the collection (if there is one) and returns true.
 void update(E element)
          Replaces the tracked element by element
 
Methods inherited from class goldman.collection.AbstractCollection.AbstractLocator
checkValidity, ignoreConcurrentModifications, ignorePriorConcurrentModifications, next, updateVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface goldman.collection.Locator
ignoreConcurrentModifications, ignorePriorConcurrentModifications
 
Methods inherited from interface java.util.Iterator
next
 

Method Detail

inCollection

public boolean inCollection()
Description copied from interface: Locator
Returns true if and only if the locator is at an element of the collection.

Specified by:
inCollection in interface Locator<E>
Returns:
true if and only if the tracked element is currently in the collection.

get

public E get()
Description copied from interface: Locator
Returns the element associated with this locator. When a tracker is used, the element associated with the locator might no longer be in the collection. If desired, the inCollection method can be used to determine if a tracked element is currently in the collection. If the locator is at FORE or AFT then a NoSuchElementException is thrown.

Specified by:
get in interface Locator<E>
Returns:
the tracked element
Throws:
NoSuchElementException - the tracker is at FORE, at AFT, or is tracking an element that has been removed.

advance

public boolean advance()
Description copied from interface: Locator
Advances to the next element in the collection (if there is one) and returns true. If the locator is already at the last element of the collection then false is returned and the locator is moved to AFT. If a call to advance is made when the locator is at AFT, an AtBoundaryException is thrown. Starting with the locator at FORE and calling advance repeatedly until false is returned will reach each element in the collection exactly once.

Specified by:
advance in interface Locator<E>

retreat

public boolean retreat()
Description copied from interface: Locator
Retreats to the previous element in the collection (if there is one) and returns true. If the locator is already at the first element of the collection then false is returned and the locator is moved to FORE. If a call to retreat is made when the Locator is at FORE, an AtBoundaryException is thrown. Starting with the locator at AFT and calling retreat repeatedly until false is returned will reach each element in the underlying collection exactly once, in the reverse order.

Specified by:
retreat in interface Locator<E>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>

remove

public void remove()
Removes the tracked element from the collection

Specified by:
remove in interface Iterator<E>

update

public void update(E element)
Replaces the tracked element by element

Specified by:
update in interface PriorityQueueLocator<E>

increasePriority

public void increasePriority(E element)
Replaces the tracked element by element
REQUIRES: the given parameter is greater than e, or that e is the parameter being passed and its value has been mutated to have a higher priority than it had previously.

Specified by:
increasePriority in interface PriorityQueueLocator<E>

decreasePriority

public void decreasePriority(E element)
Replaces the tracked element by element
REQUIRES: the given parameter is less than e, or that e is the parameter being passed and its value has been mutated to have a lower priority than it had previously.

Specified by:
decreasePriority in interface PriorityQueueLocator<E>