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

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

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

Wraps an Iterator to only return those elements that meet the requirements specified by the given ExceptFunctor function object.

Author:
davidm

Nested Class Summary
static interface ExceptIterator.ExceptFunctor
          Function object for testing to see if the ExceptIterator should return them.
 
Constructor Summary
ExceptIterator(ExceptIterator.ExceptFunctor ex, 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 valid 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

ExceptIterator

public ExceptIterator(ExceptIterator.ExceptFunctor ex,
                      java.util.Iterator i)
Creates a new instance of ExceptIterator.

Parameters:
ex - the function object to use for determining which elements to skip.
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 valid element of the wrapped iterator.

Specified by:
next in interface java.util.Iterator
Returns:
the next element that matches the criteria
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