goldman.collection.set
Class SeparateChaining.Marker

java.lang.Object
  extended by goldman.collection.AbstractCollection.AbstractLocator<E>
      extended by goldman.collection.set.SeparateChaining.Marker
All Implemented Interfaces:
Locator<E>, Cloneable, Iterator<E>
Enclosing class:
SeparateChaining<E>

protected class SeparateChaining.Marker
extends AbstractCollection.AbstractLocator<E>
implements Locator<E>


Field Summary
 
Fields inherited from class goldman.collection.AbstractCollection.AbstractLocator
versionNumber
 
Method Summary
 boolean advance()
          Advances to the next element in the collection (if there is one) and returns true.
 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 item at the marker
 boolean retreat()
          Moves the marker to the previous location
 
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
 

Method Detail

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>
Returns:
true if and only if the marker 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.

Specified by:
get in interface Locator<E>
Returns:
the element stored at the marker location.
Throws:
NoSuchElementException - the marker is logically before the first element or after the last element in the set.

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>
Throws:
AtBoundaryException - the marker had already advanced past the end of the collection via an earlier call to either advance or next
AtBoundaryException - the locator is at AFT since there is no place to advance.

retreat

public boolean retreat()
Moves the marker to the previous location

Specified by:
retreat in interface Locator<E>
Returns:
true if and only if the updated value for slot is one that is in use. The user program can use this return value to recognize when a marker has moved before the start of the set.
Throws:
AtBoundaryException - the marker is at FORE because retreating from FORE is impossible.

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>

remove

public void remove()
Removes the item at the marker

Specified by:
remove in interface Iterator<E>
Throws:
NoSuchElementException - the marker is logically at FORE or AFT