edu.umd.cfar.lamp.viper.util
Class MappingIterator

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.MappingIterator
All Implemented Interfaces:
java.util.Iterator

public class MappingIterator
extends java.lang.Object
implements java.util.Iterator

Wraps an Iterator to return the given values after having been run through a 'map' function.


Nested Class Summary
static interface MappingIterator.MappingFunctor
          Function object for converting from the domain to range of the map relation.
 
Constructor Summary
MappingIterator(MappingIterator.MappingFunctor map, java.util.Iterator i)
          Creates a new instance of ExceptIterator.
 
Method Summary
 boolean hasNext()
          Tests to see if another element matching the criteria exists in the iterator.
 java.lang.Object next()
          Gets the next object corresponding to the next element of the wrapped iterator.
 void remove()
          This must be called directly after the call to next - calling hasNext may call next() on the underlying iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappingIterator

public MappingIterator(MappingIterator.MappingFunctor map,
                       java.util.Iterator i)
Creates a new instance of ExceptIterator.

Parameters:
i - the iterator to wrap
Method Detail

hasNext

public boolean hasNext()
Tests to see if another element matching the criteria exists in the iterator.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if hasNext will return an element

next

public java.lang.Object next()
Gets the next object corresponding to the next element of the wrapped iterator.

Specified by:
next in interface java.util.Iterator
Returns:
the next mapped element
Throws:
java.util.NoSuchElementException - if no element remains that matches

remove

public void remove()
This must be called directly after the call to next - calling hasNext may call next() on the underlying iterator.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - if the underlying iterator doesn't support removal
java.lang.IllegalStateException - when invoked after a call to hasNext(), before a call to next(), or after another call to remove