edu.cmu.cs.crystal.util
Interface ExtendedIterator<T>

Type Parameters:
T -
All Superinterfaces:
Iterator<T>

public interface ExtendedIterator<T>
extends Iterator<T>

This interface extends regular iterators with the ability to replace the last element seen, using replace(Object).

Author:
Kevin Bierhoff

Method Summary
 void replace(T newValue)
          Replaces in the underlying collection the last element returned by the iterator with the given value.
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Method Detail

replace

void replace(T newValue)
Replaces in the underlying collection the last element returned by the iterator with the given value. This method can be called only once per call to Iterator.next(), and only if Iterator.remove() was not called since the last call to next. Calling remove after calling this method is also not permitted. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method or remove.

Parameters:
newValue -
Throws:
IllegalStateException - If the next method has not yet been called, or remove or replace has already been called after the last call to the next method.
See Also:
Iterator.remove()