net.sf.jga.fn.algorithm
Class RemoveAll<T>

java.lang.Object
  extended by net.sf.jga.fn.UnaryFunctor<java.util.Iterator<? extends T>,FilterIterator<T>>
      extended by net.sf.jga.fn.algorithm.RemoveAll<T>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class RemoveAll<T>
extends UnaryFunctor<java.util.Iterator<? extends T>,FilterIterator<T>>

Removes instances from an iteration. This functor returns an interator that skips specific values or values that meet a given condition. The underlying iterable is not modified.

Copyright © 2003 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface RemoveAll.Visitor
          Interface for classes that may interpret an RemoveAll functor.
 
Constructor Summary
RemoveAll(Equality<T> eq, T value)
          Builds an RemoveAll functor that will remove instances of the given value from an iteration, using the given Equality.
RemoveAll(T value)
          Builds an RemoveAll functor that will remove instances of the given value from an iteration.
RemoveAll(UnaryFunctor<T,java.lang.Boolean> test)
          Builds an RemoveAll functor that will remove elements from an iteration that pass the given test
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(RemoveAll) method, if it implements the nested Visitor interface.
 FilterIterator<T> fn(java.util.Iterator<? extends T> iterator)
          Apply the functor to each element in the iteration and return an iterator over the results
 UnaryFunctor<T,java.lang.Boolean> getFunction()
          Returns the functor used to process elements in an iteration.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, compose, compose, generate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoveAll

public RemoveAll(T value)
Builds an RemoveAll functor that will remove instances of the given value from an iteration.

Throws:
java.lang.IllegalArgumentException - if the test is null

RemoveAll

public RemoveAll(Equality<T> eq,
                 T value)
Builds an RemoveAll functor that will remove instances of the given value from an iteration, using the given Equality.

Throws:
java.lang.IllegalArgumentException - if the test is null

RemoveAll

public RemoveAll(UnaryFunctor<T,java.lang.Boolean> test)
Builds an RemoveAll functor that will remove elements from an iteration that pass the given test

Throws:
java.lang.IllegalArgumentException - if the test is null
Method Detail

getFunction

public UnaryFunctor<T,java.lang.Boolean> getFunction()
Returns the functor used to process elements in an iteration.


fn

public FilterIterator<T> fn(java.util.Iterator<? extends T> iterator)
Apply the functor to each element in the iteration and return an iterator over the results

Specified by:
fn in class UnaryFunctor<java.util.Iterator<? extends T>,FilterIterator<T>>
Returns:
an iterator over the results of the transformation

accept

public void accept(Visitor v)
Calls the Visitor's visit(RemoveAll) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class UnaryFunctor<java.util.Iterator<? extends T>,FilterIterator<T>>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2005 David A. Hall. All Rights Reserved.