de.rwth.utils
Class AbstractIterator
java.lang.Object
|
+--de.rwth.utils.AbstractIterator
- All Implemented Interfaces:
- java.util.Iterator
- public abstract class AbstractIterator
- extends java.lang.Object
- implements java.util.Iterator
Provides a default implementation for the Iterator
interface. To get
a working implementation of Iterator
only the methods produceNext()
and externalView(Object o)
must be defined in a subclass.
This class allows to distinguish between internal (seen inside this class) and
external representation (seen by the user of the Iterator
).
- Version:
- $Id: AbstractIterator.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
- Author:
- Markus Mohnen
Method Summary |
abstract java.lang.Object |
externalView(java.lang.Object o)
The externalView method is supposed to convert internal to external
representation. |
boolean |
hasNext()
|
java.lang.Object |
next()
|
abstract java.lang.Object |
produceNext()
The produceNext method is supposed to produce the internal
representation of the next element of the Iterator . |
void |
remove()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractIterator
public AbstractIterator()
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator
next
public java.lang.Object next()
throws java.util.NoSuchElementException
- Specified by:
next
in interface java.util.Iterator
remove
public void remove()
- Specified by:
remove
in interface java.util.Iterator
produceNext
public abstract java.lang.Object produceNext()
- The
produceNext
method is supposed to produce the internal
representation of the next element of the Iterator
. If there are no
more elements, it should indicate this byte returning null
. This
method is guaranteed to be called exactly once to produce a new element,
independently on how often hasNext()
is called before a call
to next()
.
- Returns:
- a value of type
Object
externalView
public abstract java.lang.Object externalView(java.lang.Object o)
- The
externalView
method is supposed to convert internal to external
representation.
- Parameters:
o
- a value of type Object
- Returns:
- a value of type
Object