|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgoldman.collection.AbstractCollection.AbstractLocator<E>
goldman.collection.positional.SinglyLinkedList.Tracker
protected class SinglyLinkedList.Tracker
Field Summary |
---|
Fields inherited from class goldman.collection.AbstractCollection.AbstractLocator |
---|
versionNumber |
Constructor Summary | |
---|---|
protected |
SinglyLinkedList.Tracker(SinglyLinkedList.ListItem<E> startLoc)
|
Method Summary | |
---|---|
PositionalCollectionLocator<E> |
addAfter(E value)
Adds the new element after the tracked element |
boolean |
advance()
Moves the tracker to the next location |
E |
get()
Returns the element associated with this locator. |
int |
getCurrentPosition()
This method takes constant time for an element not in the collection. |
E |
getNextElement()
|
boolean |
hasNext()
|
boolean |
inCollection()
Returns true if and only if the locator is at an element of the collection. |
void |
remove()
Removes the tracked element from the collection. |
void |
removeNextElement()
Removes the element that follows the tracked element |
boolean |
retreat()
Updates the tracker to the previous element in the collection |
E |
set(E value)
|
protected SinglyLinkedList.ListItem<E> |
skipRemovedElements(SinglyLinkedList.ListItem<E> ptr)
|
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 |
Constructor Detail |
---|
protected SinglyLinkedList.Tracker(SinglyLinkedList.ListItem<E> startLoc)
startLoc
- a reference to the list item holding the element to track.Method Detail |
---|
public boolean inCollection()
Locator
inCollection
in interface Locator<E>
public E get()
Locator
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.
get
in interface Locator<E>
NoSuchElementException
- the tracker is not at an element in
the collection.public E set(E value)
value
- the element to put at the current tracker location.
NoSuchElementException
- tracker is not at an element in
the collection.public int getCurrentPosition()
getCurrentPosition
in interface PositionalCollectionLocator<E>
NoSuchElementException
- the tracker is not at an element
in the collection.protected SinglyLinkedList.ListItem<E> skipRemovedElements(SinglyLinkedList.ListItem<E> ptr)
ptr
- a pointer to a list item
ptr
itself if it is reachable.public boolean advance() throws ConcurrentModificationException
advance
in interface Locator<E>
AtBoundaryException
- the tracker is already at
AFT since
there is no place to advance.
ConcurrentModificationException
public boolean retreat() throws ConcurrentModificationException
retreat
in interface Locator<E>
AtBoundaryException
- the tracker is
at FORE.
ConcurrentModificationException
public boolean hasNext() throws ConcurrentModificationException
hasNext
in interface Iterator<E>
ConcurrentModificationException
public PositionalCollectionLocator<E> addAfter(E value) throws ConcurrentModificationException
addAfter
in interface PositionalCollectionLocator<E>
value
- the element to add
ConcurrentModificationException
public void remove() throws ConcurrentModificationException
remove
in interface Iterator<E>
NoSuchElementException
- the tracked element has already been
removed.
ConcurrentModificationException
public E getNextElement() throws ConcurrentModificationException
NoSuchElementException
- the tracked element is not in the collection, or
if current element is at position
size
-1.
ConcurrentModificationException
public void removeNextElement() throws ConcurrentModificationException
NoSuchElementException
- the tracked element is not in the collection, or
if current element is at position
size
-1.
ConcurrentModificationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |