goldman.collection
Class AbstractCollection.VisitingIterator

java.lang.Object
  extended by goldman.collection.AbstractCollection.AbstractLocator<E>
      extended by goldman.collection.AbstractCollection.VisitingIterator
All Implemented Interfaces:
Locator<E>, Visitor<E>, Cloneable, Runnable, Iterator<E>
Enclosing class:
AbstractCollection<E>

public class AbstractCollection.VisitingIterator
extends AbstractCollection.AbstractLocator<E>
implements Visitor<E>, Locator<E>, Runnable


Field Summary
 
Fields inherited from class goldman.collection.AbstractCollection.AbstractLocator
versionNumber
 
Constructor Summary
AbstractCollection.VisitingIterator()
           
 
Method Summary
 boolean advance()
          Advances to the next element in the collection (if there is one) and returns true.
 void cancel()
          Aborts iteration to terminate the visiting iterator thread when iteration to completion is not required.
 E get()
          Returns the element associated with this locator.
 boolean hasNext()
           
 void ignoreConcurrentModifications(boolean ignore)
          Sets the version number of the locator to MAX_VALUE when ignore is true, preventing concurrent modification exceptions from occurring.
 void ignorePriorConcurrentModifications()
          Resets the version number of the locator to the current modification count for the data structure object.
 boolean inCollection()
          Returns true if and only if the locator is at an element of the collection.
 E next()
          Moves the locator forward to the next element in the collection.
 void remove()
           
 boolean retreat()
          Retreats to the previous element in the collection (if there is one) and returns true.
 void run()
          Calls the accept method on the collection provided to the constructor
 void visit(E item)
          Called during traversal with each element of the collection being passed as the parameter.
 
Methods inherited from class goldman.collection.AbstractCollection.AbstractLocator
checkValidity, updateVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCollection.VisitingIterator

public AbstractCollection.VisitingIterator()
Method Detail

run

public void run()
Calls the accept method on the collection provided to the constructor

Specified by:
run in interface Runnable

cancel

public void cancel()
Aborts iteration to terminate the visiting iterator thread when iteration to completion is not required. Subsequent calls to hasNext will return false.


visit

public void visit(E item)
           throws Exception
Description copied from interface: Visitor
Called during traversal with each element of the collection being passed as the parameter.

Specified by:
visit in interface Visitor<E>
Parameters:
item - the element to visit
Throws:
Exception

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>
Returns:
true if and only if iteration has not reached the last element

next

public E next()
Description copied from class: AbstractCollection.AbstractLocator
Moves the locator forward to the next element in the collection.

Specified by:
next in interface Iterator<E>
Overrides:
next in class AbstractCollection.AbstractLocator<E>
Returns:
the next element in the iteration order, and advances the locator

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>

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>

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>

remove

public void remove()
Specified by:
remove in interface Iterator<E>

ignoreConcurrentModifications

public void ignoreConcurrentModifications(boolean ignore)
Description copied from class: AbstractCollection.AbstractLocator
Sets the version number of the locator to MAX_VALUE when ignore is true, preventing concurrent modification exceptions from occurring. When ignore is false, it restores the version number to the smaller of the locator's version number and the current modification count for the data structure object

Specified by:
ignoreConcurrentModifications in interface Locator<E>
Overrides:
ignoreConcurrentModifications in class AbstractCollection.AbstractLocator<E>
Parameters:
ignore - a boolean flag indicating if concurrent modification exceptions should be disabled

ignorePriorConcurrentModifications

public void ignorePriorConcurrentModifications()
Description copied from class: AbstractCollection.AbstractLocator
Resets the version number of the locator to the current modification count for the data structure object.

Specified by:
ignorePriorConcurrentModifications in interface Locator<E>
Overrides:
ignorePriorConcurrentModifications in class AbstractCollection.AbstractLocator<E>