goldman.collection
Class AbstractCollection.AbstractLocator<T extends E>

java.lang.Object
  extended by goldman.collection.AbstractCollection.AbstractLocator<T>
All Implemented Interfaces:
Locator<E>, Cloneable, Iterator<E>
Direct Known Subclasses:
AbstractCollection.VisitingIterator, Array.BasicMarker, BinaryHeap.BinaryHeapLocator, BinarySearchTree.Tracker, BTree.Marker, DirectAddressing.Marker, LeftistHeap.Tracker, PairingHeap.Tracker, SeparateChaining.Marker, SinglyLinkedList.Tracker, SkipList.Tracker, TrackedArray.Tracker, Trie.Tracker
Enclosing class:
AbstractCollection<E>

public abstract class AbstractCollection.AbstractLocator<T extends E>
extends Object
implements Locator<E>


Field Summary
protected  int versionNumber
           
 
Constructor Summary
protected AbstractCollection.AbstractLocator()
           
 
Method Summary
protected  void checkValidity()
          Compares the version number held by the locator with the current version number of the data structure object.
 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.
 E next()
          Moves the locator forward to the next element in the collection.
protected  void updateVersion()
          Updates the version number for the locator to be the current modification count for the data structure object.
 
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
advance, get, inCollection, retreat
 
Methods inherited from interface java.util.Iterator
hasNext, remove
 

Field Detail

versionNumber

protected int versionNumber
Constructor Detail

AbstractCollection.AbstractLocator

protected AbstractCollection.AbstractLocator()
Method Detail

checkValidity

protected void checkValidity()
Compares the version number held by the locator with the current version number of the data structure object.

Throws:
ConcurrentModificationException - the locator version number is less than the modification count for the data structure object.

updateVersion

protected final void updateVersion()
Updates the version number for the locator to be the current modification count for the data structure object.


ignoreConcurrentModifications

public void ignoreConcurrentModifications(boolean ignore)
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>
Parameters:
ignore - a boolean flag indicating if concurrent modification exceptions should be disabled

ignorePriorConcurrentModifications

public void ignorePriorConcurrentModifications()
Resets the version number of the locator to the current modification count for the data structure object.

Specified by:
ignorePriorConcurrentModifications in interface Locator<E>

next

public E next()
Moves the locator forward to the next element in the collection.

Specified by:
next in interface Iterator<E>
Returns:
the element stored at the position to which the locator is moved
Throws:
AtBoundaryException - the locator is already at AFT
NoSuchElementException - the locator is at the last element in the collection.