goldman.collection
Class AbstractCollection.AbstractLocator<T extends E>
java.lang.Object
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>
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 |
versionNumber
protected int versionNumber
AbstractCollection.AbstractLocator
protected AbstractCollection.AbstractLocator()
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.