net.sf.jga.algorithms
Class Filter

java.lang.Object
  extended by net.sf.jga.algorithms.Filter

public class Filter
extends java.lang.Object

Algorithms that return a subset of its input. The input may be an array, collection, or iteration. There are two general algorithms included: filter and remove. The filter methods return elements from the input that pass the selection criteria, while the remove methods removes elements from the input stream for which the selection criteria is true. Note that the actual input is not modified in any of these methods.

Copyright © 2006 David A. Hall


Nested Class Summary
static class Filter.FilterIterable<T>
          Produces Iterators that only return elements that meet a given condition.
static class Filter.FilterIterator<T>
          Iterator that only returns elements that meet the given selection criteria.
 
Constructor Summary
Filter()
           
 
Method Summary
static
<T> java.lang.Iterable<T>
filter(java.lang.Iterable<? extends T> i, UnaryFunctor<T,java.lang.Boolean> pred)
          Returns the contents of the input that meet the given selection criteria.
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
filter(java.lang.Iterable<? extends T> cin, UnaryFunctor<T,java.lang.Boolean> pred, TCollection cout)
          Appends the contents of the input that meet the given selection criteria to the output.
static
<T> java.util.Iterator<T>
filter(java.util.Iterator<? extends T> iter, UnaryFunctor<T,java.lang.Boolean> pred)
          Returns the contents of the iterator that meet the given selection criteria.
static
<T> java.lang.Iterable<T>
filter(T[] ts, UnaryFunctor<T,java.lang.Boolean> pred)
          Returns the elements of the array that meet the given selection criteria.
static
<T> java.lang.Iterable<T>
remove(java.lang.Iterable<? extends T> i, T value)
          Returns the elements of the input that are not equal to the given value, using the value's Object.equals(Object) method
static
<T> java.lang.Iterable<T>
remove(java.lang.Iterable<? extends T> i, T value, Equality<T> eq)
          Returns the elements of the input that are not equal to the given value, using the given functor to compare for equality
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
remove(java.lang.Iterable<? extends T> cin, T value, Equality<T> eq, TCollection cout)
          Returns the elements of the input that are not equal to the given value, using the given functor to compare for equality
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
remove(java.lang.Iterable<? extends T> cin, T value, TCollection cout)
          Returns the elements of the input that are not equal to the given value, using the value's Object.equals(Object) method
static
<T> java.lang.Iterable<T>
remove(java.lang.Iterable<? extends T> i, UnaryFunctor<T,java.lang.Boolean> pred)
          Returns the elements of the input that do not meet the given selection criteria
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
remove(java.lang.Iterable<? extends T> cin, UnaryFunctor<T,java.lang.Boolean> pred, TCollection cout)
          Returns the elements of the input that do not meet the given selection criteria
static
<T> java.util.Iterator<T>
remove(java.util.Iterator<? extends T> iter, T value)
          Returns the elements of the iterator that are not equal to the given value, using the value's Object.equals(Object) method
static
<T> java.util.Iterator<T>
remove(java.util.Iterator<? extends T> iter, T value, Equality<T> eq)
          Returns the elements of the iterator that are not equal to the given value, using the given functor to compare for equality
static
<T> java.util.Iterator<T>
remove(java.util.Iterator<? extends T> iter, UnaryFunctor<T,java.lang.Boolean> pred)
          Returns the elements of the iterator that do not meet the given selection criteria
static
<T> java.lang.Iterable<T>
remove(T[] ts, T value)
          Returns the elements of the array that are not equal to the given value, using the value's Object.equals(Object) method
static
<T> java.lang.Iterable<T>
remove(T[] ts, T value, Equality<T> eq)
          Returns the elements of the array that are not equal to the given value, using the given functor to compare for equality
static
<T> java.lang.Iterable<T>
remove(T[] ts, UnaryFunctor<T,java.lang.Boolean> pred)
          Returns the elements of the array that do not meet the given selection criteria
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Filter

public Filter()
Method Detail

filter

public static <T> java.lang.Iterable<T> filter(T[] ts,
                                               UnaryFunctor<T,java.lang.Boolean> pred)
Returns the elements of the array that meet the given selection criteria.


remove

public static <T> java.lang.Iterable<T> remove(T[] ts,
                                               T value)
Returns the elements of the array that are not equal to the given value, using the value's Object.equals(Object) method


remove

public static <T> java.lang.Iterable<T> remove(T[] ts,
                                               T value,
                                               Equality<T> eq)
Returns the elements of the array that are not equal to the given value, using the given functor to compare for equality


remove

public static <T> java.lang.Iterable<T> remove(T[] ts,
                                               UnaryFunctor<T,java.lang.Boolean> pred)
Returns the elements of the array that do not meet the given selection criteria


filter

public static <T> java.lang.Iterable<T> filter(java.lang.Iterable<? extends T> i,
                                               UnaryFunctor<T,java.lang.Boolean> pred)
Returns the contents of the input that meet the given selection criteria.


remove

public static <T> java.lang.Iterable<T> remove(java.lang.Iterable<? extends T> i,
                                               T value)
Returns the elements of the input that are not equal to the given value, using the value's Object.equals(Object) method


remove

public static <T> java.lang.Iterable<T> remove(java.lang.Iterable<? extends T> i,
                                               T value,
                                               Equality<T> eq)
Returns the elements of the input that are not equal to the given value, using the given functor to compare for equality


remove

public static <T> java.lang.Iterable<T> remove(java.lang.Iterable<? extends T> i,
                                               UnaryFunctor<T,java.lang.Boolean> pred)
Returns the elements of the input that do not meet the given selection criteria


filter

public static <T> java.util.Iterator<T> filter(java.util.Iterator<? extends T> iter,
                                               UnaryFunctor<T,java.lang.Boolean> pred)
Returns the contents of the iterator that meet the given selection criteria.


remove

public static <T> java.util.Iterator<T> remove(java.util.Iterator<? extends T> iter,
                                               T value)
Returns the elements of the iterator that are not equal to the given value, using the value's Object.equals(Object) method


remove

public static <T> java.util.Iterator<T> remove(java.util.Iterator<? extends T> iter,
                                               T value,
                                               Equality<T> eq)
Returns the elements of the iterator that are not equal to the given value, using the given functor to compare for equality


remove

public static <T> java.util.Iterator<T> remove(java.util.Iterator<? extends T> iter,
                                               UnaryFunctor<T,java.lang.Boolean> pred)
Returns the elements of the iterator that do not meet the given selection criteria


filter

public static <T,TCollection extends java.util.Collection<? super T>> TCollection filter(java.lang.Iterable<? extends T> cin,
                                                                                         UnaryFunctor<T,java.lang.Boolean> pred,
                                                                                         TCollection cout)
Appends the contents of the input that meet the given selection criteria to the output.


remove

public static <T,TCollection extends java.util.Collection<? super T>> TCollection remove(java.lang.Iterable<? extends T> cin,
                                                                                         T value,
                                                                                         TCollection cout)
Returns the elements of the input that are not equal to the given value, using the value's Object.equals(Object) method


remove

public static <T,TCollection extends java.util.Collection<? super T>> TCollection remove(java.lang.Iterable<? extends T> cin,
                                                                                         T value,
                                                                                         Equality<T> eq,
                                                                                         TCollection cout)
Returns the elements of the input that are not equal to the given value, using the given functor to compare for equality


remove

public static <T,TCollection extends java.util.Collection<? super T>> TCollection remove(java.lang.Iterable<? extends T> cin,
                                                                                         UnaryFunctor<T,java.lang.Boolean> pred,
                                                                                         TCollection cout)
Returns the elements of the input that do not meet the given selection criteria



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