CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.util
Class AbstractStableIterator

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.AbstractStableIterator
All Implemented Interfaces:
Iterator
Direct Known Subclasses:
AbstractKeySetBasedMap.KeyIterator, OverflowMap.EntrySet.EntrySetIterator, OverflowMap.InternalKeySet.InternalKeySetIterator, SafeHashMap.EntrySet.EntrySetIterator

public abstract class AbstractStableIterator
extends Base
implements Iterator

An abstract Iterator implementation that is stable between the hasNext() and next() methods, and between the next() and remove() methods.

Since:
Coherence 3.1
Author:
cp 2003.05.24

Constructor Summary
AbstractStableIterator()
          Default constructor.
 
Method Summary
protected abstract  void advance()
          Advance to the next object.
protected  Object getPrevious()
          Obtain the previous object provided by the Iterator.
 boolean hasNext()
          Returns true if the iteration has more elements.
 Object next()
          Returns the next element in the iteration.
 void remove()
          Removes from the underlying collection the last element returned by the iterator.
protected  void remove(Object oPrev)
          Remove the specified item.
protected  void setNext(Object oNext)
          Specify the next object to provide from the Iterator.
 

Constructor Detail

AbstractStableIterator

public AbstractStableIterator()
Default constructor.

Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in interface Iterator
Returns:
true if the iterator has more elements

next

public Object next()
Returns the next element in the iteration.

Specified by:
next in interface Iterator
Returns:
the next element in the iteration
Throws:
NoSuchElementException - if the Iterator has no more elements

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator.

Specified by:
remove in interface Iterator
Throws:
IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method

getPrevious

protected Object getPrevious()
Obtain the previous object provided by the Iterator.

Returns:
the object previously returned from a call to next()

setNext

protected void setNext(Object oNext)
Specify the next object to provide from the Iterator.

Parameters:
oNext - the next object to provide from the Iterator

advance

protected abstract void advance()
Advance to the next object.

This method must be implemented by the concrete sub-class by calling setNext(java.lang.Object) if there is a next object.


remove

protected void remove(Object oPrev)
Remove the specified item.

This is an optional operation. If the Iterator supports element removal, then it should implement this method, which is delegated to by the remove() method.

Parameters:
oPrev - the previously iterated object that should be removed
Throws:
UnsupportedOperationException - if removal is not supported

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation