de.rwth.utils
Class IteratorMap
java.lang.Object
|
+--de.rwth.utils.IteratorMap
- All Implemented Interfaces:
- java.util.Iterator
- public class IteratorMap
- extends java.lang.Object
- implements java.util.Iterator
An iterator created by applying an function to all elements of a base iterator.
- Version:
- $Id: IteratorMap.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
- Author:
- Markus Mohnen
Inner Class Summary |
static interface |
IteratorMap.Function
The interface used to describe a function. |
Field Summary |
protected IteratorMap.Function |
f
The function to apply to the arguments. |
protected java.util.Iterator |
i
The base iterator. |
Method Summary |
boolean |
hasNext()
Checks if there is another element pending. |
static void |
main(java.lang.String[] args)
Mini test environment. |
java.lang.Object |
next()
Returns the next element of the base iterator, with the function applied to it. |
void |
remove()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
i
protected java.util.Iterator i
- The base iterator.
f
protected IteratorMap.Function f
- The function to apply to the arguments.
IteratorMap
public IteratorMap(java.util.Iterator i,
IteratorMap.Function f)
- Creates a new
IteratorMap
instance.
- Parameters:
i
- an Iterator
valuef
- a Function
value
next
public java.lang.Object next()
throws java.util.NoSuchElementException
- Returns the next element of the base iterator, with the function applied to it.
- Specified by:
next
in interface java.util.Iterator
- Returns:
- an
Object
value - Throws:
java.util.NoSuchElementException
- if there is no more element.
hasNext
public boolean hasNext()
- Checks if there is another element pending.
- Specified by:
hasNext
in interface java.util.Iterator
- Returns:
- a
boolean
value
remove
public void remove()
- Specified by:
remove
in interface java.util.Iterator
main
public static void main(java.lang.String[] args)
- Mini test environment.
- Parameters:
args
- a String[]
value