goldman.collection.positional
Class Array.BasicMarker
java.lang.Object
goldman.collection.AbstractCollection.AbstractLocator<E>
goldman.collection.positional.Array.BasicMarker
- All Implemented Interfaces:
- Locator<E>, Cloneable, Iterator<E>
- Direct Known Subclasses:
- Array.Marker
- Enclosing class:
- Array<E>
public class Array.BasicMarker
- extends AbstractCollection.AbstractLocator<E>
Method Summary |
boolean |
advance()
Moves the locator forward by one position |
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 |
remove()
Removes the element at the locator and updates the locator to be
at the element in the collection preceding the one deleted. |
boolean |
retreat()
Moves the locator to the previous position |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Array.BasicMarker
public Array.BasicMarker(int p)
- Parameters:
p
- the position to store within the marker.
- Throws:
IllegalArgumentException
- the property MarkerLoc would be violated
inCollection
public boolean inCollection()
- Description copied from interface:
Locator
- Returns true if and only if the locator is at an element of
the collection.
- Returns:
- true if and only if the locator is at an element of 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.
- Returns:
- the element stored at the current locator position.
- Throws:
NoSuchElementException
- the locator is
at FORE or AFT
advance
public boolean advance()
throws ConcurrentModificationException
- Moves the locator forward by one position
- Returns:
- true if and only if after the update the locator is
still at a position in the collection.
- Throws:
AtBoundaryException
- the locator is at AFT since there is
no place to advance.
ConcurrentModificationException
retreat
public boolean retreat()
throws ConcurrentModificationException
- Moves the locator to the previous position
- Returns:
- true if and only if after the update the locator is still at a
valid position.
The user program can use this return value to
recognize when the locater has reached FORE.
- Throws:
AtBoundaryException
- the locator is at FORE since then there is
no place to retreat.
ConcurrentModificationException
hasNext
public boolean hasNext()
throws ConcurrentModificationException
- Returns:
- true if there is some element after the current locator position.
- Throws:
ConcurrentModificationException
remove
public void remove()
throws ConcurrentModificationException
- Removes the element at the locator and updates the locator to be
at the element in the collection preceding the one deleted.
- Throws:
NoSuchElementException
- the locator is at FORE or AFT
ConcurrentModificationException