net.sf.jga.algorithms
Class Transform

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

public class Transform
extends java.lang.Object

Algorithms that process the elements of a collection, iteration, or iterable resource, and present the results.

Copyright © 2002-2006 David A. Hall

Author:
David A. Hall

Nested Class Summary
static class Transform.AdjacentIterable<T,R>
          Produces iterators that will process successive pairs of elements of an iterable resource and present the results.
static class Transform.AdjacentIterator<T,R>
          Iterator that applies a given BinaryFunctor to successive pairs of elements from a given iterator, returning the results as elements.
static class Transform.BinaryIterable<T1,T2,R>
          Produces iterators that applies a given BinaryFunctor to corresponding pairs of elements from a pair of iterators, returning the results.
static class Transform.BinaryIterator<T1,T2,R>
          Iterator that applies a given BinaryFunctor to corresponding pairs of elements from a pair of iterators, returning the results.
static class Transform.TransformIterable<T,R>
          Produces iterators that will process elements of an iterable resource and present the results.
static class Transform.TransformIterator<T,R>
           
 
Constructor Summary
Transform()
           
 
Method Summary
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
replace(java.lang.Iterable<? extends T> cin, T value, T repl, TCollection cout)
          Appends the contents of the input to the output, such that all instances of the given value are replaced with the given replacement value
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
replace(java.lang.Iterable<? extends T> cin, UnaryFunctor<T,java.lang.Boolean> test, T repl, TCollection cout)
          Appends the contents of the input to the output, such that all elements for which the given test returns TRUE are replaced with the given replacement value.
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
replace(java.lang.Iterable<? extends T> cin, UnaryFunctor<T,java.lang.Boolean> test, UnaryFunctor<T,T> fn, TCollection cout)
          Appends the contents of the input to the output, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.
static
<T> java.lang.Iterable<T>
replace(java.lang.Iterable<T> ts, T value, T replacement)
          Produces an iterable over the contents of the input, such that all instances of the given value are replaced with the given replacement value.
static
<T> java.lang.Iterable<T>
replace(java.lang.Iterable<T> ts, UnaryFunctor<T,java.lang.Boolean> test, T replacement)
          Produces an iterable over the contents of the input, such that all elements for which the given test returns TRUE are replaced with the given replacement value.
static
<T> java.lang.Iterable<T>
replace(java.lang.Iterable<T> ts, UnaryFunctor<T,java.lang.Boolean> test, UnaryFunctor<T,T> fn)
          Produces an iterable over the contents of the input, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.
static
<T> java.util.Iterator<T>
replace(java.util.Iterator<? extends T> ts, T value, T replacement)
          Produces an iterator over the contents of the given iterator, such that all instances of the given value are replaced with the given replacement value.
static
<T> java.util.Iterator<T>
replace(java.util.Iterator<? extends T> ts, UnaryFunctor<T,java.lang.Boolean> test, T replacement)
          Produces an iterator over the contents of the given iterator, such that all elements for which the given test returns TRUE are replaced with the given replacement value.
static
<T> java.util.Iterator<T>
replace(java.util.Iterator<? extends T> ts, UnaryFunctor<T,java.lang.Boolean> test, UnaryFunctor<T,T> fn)
          Produces an iterator over the contents of the given iterator, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.
static
<T> java.lang.Iterable<T>
replace(T[] ts, T value, T replacement)
          Produces an iterable over the contents of the array, such that all instances of the given value are replaced with the given replacement value.
static
<T> java.lang.Iterable<T>
replace(T[] ts, UnaryFunctor<T,java.lang.Boolean> test, T replacement)
          Produces an iterable over the contents of the array, such that all elements for which the given test returns TRUE are replaced with the given replacement value.
static
<T> java.lang.Iterable<T>
replace(T[] ts, UnaryFunctor<T,java.lang.Boolean> test, UnaryFunctor<T,T> fn)
          Produces an iterable over the contents of the array, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.
static
<T,R> java.lang.Iterable<R>
transform(java.lang.Iterable<? extends T> i, BinaryFunctor<T,T,R> fn)
          Passes successive pairs of elements in the iterable resource to the functor, iterating over the results
static
<T,RCollection extends java.util.Collection<? super R>,R>
RCollection
transform(java.lang.Iterable<? extends T> cin, BinaryFunctor<T,T,R> fn, RCollection cout)
          Appends the results of transforming successive pairs of elements from the input to the output.
static
<T,R> java.lang.Iterable<R>
transform(java.lang.Iterable<? extends T> i, UnaryFunctor<T,R> fn)
          Passes each element in the iterable resource to the functor, iterating over the results
static
<T,RCollection extends java.util.Collection<? super R>,R>
RCollection
transform(java.lang.Iterable<? extends T> cin, UnaryFunctor<T,R> fn, RCollection cout)
          Appends the transformed contents of the input to the output.
static
<T1,T2,R> java.lang.Iterable<R>
transform(java.lang.Iterable<? extends T1> i1, java.lang.Iterable<? extends T2> i2, BinaryFunctor<T1,T2,R> fn)
          Passes corresponding pairs of elements in the iterable resources to the functor, iterating over the results
static
<T1,T2,RCollection extends java.util.Collection<? super R>,R>
RCollection
transform(java.lang.Iterable<? extends T1> cin1, java.lang.Iterable<? extends T2> cin2, BinaryFunctor<T1,T2,R> fn, RCollection cout)
          Appends the results of transforming corresponding pairs of elements from the input sto the output.
static
<T,R> java.util.Iterator<R>
transform(java.util.Iterator<? extends T> iter, BinaryFunctor<T,T,R> fn)
          Passes successive pairs of elements in the iterator to the functor, iterating over the results
static
<T,R> java.util.Iterator<R>
transform(java.util.Iterator<? extends T> iter, UnaryFunctor<T,R> fn)
          Passes each element in the iterator to the functor, iterating over the results
static
<T1,T2,R> java.util.Iterator<R>
transform(java.util.Iterator<? extends T1> iter1, java.util.Iterator<? extends T2> iter2, BinaryFunctor<T1,T2,R> fn)
          Passes corresponding pairs of elements in the iterators to the functor, iterating over the results
static
<T,R> java.lang.Iterable<R>
transform(T[] ts, BinaryFunctor<T,T,R> fn)
          Passes successive pairs of elements in the array to the functor, iterating over the results
static
<T,R> java.lang.Iterable<R>
transform(T[] ts, UnaryFunctor<T,R> fn)
          Passes each element in the array to the functor, iterating over the results
static
<T1,T2,R> java.lang.Iterable<R>
transform(T1[] ts1, T2[] ts2, BinaryFunctor<T1,T2,R> fn)
          Passes corresponding pairs of elements in the arrays to the functor, iterating over the results
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transform

public Transform()
Method Detail

replace

public static <T> java.lang.Iterable<T> replace(T[] ts,
                                                T value,
                                                T replacement)
Produces an iterable over the contents of the array, such that all instances of the given value are replaced with the given replacement value.


replace

public static <T> java.lang.Iterable<T> replace(T[] ts,
                                                UnaryFunctor<T,java.lang.Boolean> test,
                                                T replacement)
Produces an iterable over the contents of the array, such that all elements for which the given test returns TRUE are replaced with the given replacement value.


replace

public static <T> java.lang.Iterable<T> replace(T[] ts,
                                                UnaryFunctor<T,java.lang.Boolean> test,
                                                UnaryFunctor<T,T> fn)
Produces an iterable over the contents of the array, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.


transform

public static <T,R> java.lang.Iterable<R> transform(T[] ts,
                                                    UnaryFunctor<T,R> fn)
Passes each element in the array to the functor, iterating over the results


transform

public static <T,R> java.lang.Iterable<R> transform(T[] ts,
                                                    BinaryFunctor<T,T,R> fn)
Passes successive pairs of elements in the array to the functor, iterating over the results


transform

public static <T1,T2,R> java.lang.Iterable<R> transform(T1[] ts1,
                                                        T2[] ts2,
                                                        BinaryFunctor<T1,T2,R> fn)
Passes corresponding pairs of elements in the arrays to the functor, iterating over the results


replace

public static <T> java.lang.Iterable<T> replace(java.lang.Iterable<T> ts,
                                                T value,
                                                T replacement)
Produces an iterable over the contents of the input, such that all instances of the given value are replaced with the given replacement value.


replace

public static <T> java.lang.Iterable<T> replace(java.lang.Iterable<T> ts,
                                                UnaryFunctor<T,java.lang.Boolean> test,
                                                T replacement)
Produces an iterable over the contents of the input, such that all elements for which the given test returns TRUE are replaced with the given replacement value.


replace

public static <T> java.lang.Iterable<T> replace(java.lang.Iterable<T> ts,
                                                UnaryFunctor<T,java.lang.Boolean> test,
                                                UnaryFunctor<T,T> fn)
Produces an iterable over the contents of the input, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.


transform

public static <T,R> java.lang.Iterable<R> transform(java.lang.Iterable<? extends T> i,
                                                    UnaryFunctor<T,R> fn)
Passes each element in the iterable resource to the functor, iterating over the results


transform

public static <T,R> java.lang.Iterable<R> transform(java.lang.Iterable<? extends T> i,
                                                    BinaryFunctor<T,T,R> fn)
Passes successive pairs of elements in the iterable resource to the functor, iterating over the results


transform

public static <T1,T2,R> java.lang.Iterable<R> transform(java.lang.Iterable<? extends T1> i1,
                                                        java.lang.Iterable<? extends T2> i2,
                                                        BinaryFunctor<T1,T2,R> fn)
Passes corresponding pairs of elements in the iterable resources to the functor, iterating over the results


replace

public static <T> java.util.Iterator<T> replace(java.util.Iterator<? extends T> ts,
                                                T value,
                                                T replacement)
Produces an iterator over the contents of the given iterator, such that all instances of the given value are replaced with the given replacement value.


replace

public static <T> java.util.Iterator<T> replace(java.util.Iterator<? extends T> ts,
                                                UnaryFunctor<T,java.lang.Boolean> test,
                                                T replacement)
Produces an iterator over the contents of the given iterator, such that all elements for which the given test returns TRUE are replaced with the given replacement value.


replace

public static <T> java.util.Iterator<T> replace(java.util.Iterator<? extends T> ts,
                                                UnaryFunctor<T,java.lang.Boolean> test,
                                                UnaryFunctor<T,T> fn)
Produces an iterator over the contents of the given iterator, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.


transform

public static <T,R> java.util.Iterator<R> transform(java.util.Iterator<? extends T> iter,
                                                    UnaryFunctor<T,R> fn)
Passes each element in the iterator to the functor, iterating over the results


transform

public static <T,R> java.util.Iterator<R> transform(java.util.Iterator<? extends T> iter,
                                                    BinaryFunctor<T,T,R> fn)
Passes successive pairs of elements in the iterator to the functor, iterating over the results


transform

public static <T1,T2,R> java.util.Iterator<R> transform(java.util.Iterator<? extends T1> iter1,
                                                        java.util.Iterator<? extends T2> iter2,
                                                        BinaryFunctor<T1,T2,R> fn)
Passes corresponding pairs of elements in the iterators to the functor, iterating over the results


replace

public static <T,TCollection extends java.util.Collection<? super T>> TCollection replace(java.lang.Iterable<? extends T> cin,
                                                                                          T value,
                                                                                          T repl,
                                                                                          TCollection cout)
Appends the contents of the input to the output, such that all instances of the given value are replaced with the given replacement value


replace

public static <T,TCollection extends java.util.Collection<? super T>> TCollection replace(java.lang.Iterable<? extends T> cin,
                                                                                          UnaryFunctor<T,java.lang.Boolean> test,
                                                                                          T repl,
                                                                                          TCollection cout)
Appends the contents of the input to the output, such that all elements for which the given test returns TRUE are replaced with the given replacement value.


replace

public static <T,TCollection extends java.util.Collection<? super T>> TCollection replace(java.lang.Iterable<? extends T> cin,
                                                                                          UnaryFunctor<T,java.lang.Boolean> test,
                                                                                          UnaryFunctor<T,T> fn,
                                                                                          TCollection cout)
Appends the contents of the input to the output, such that all elements for which the given test returns TRUE are replaced with the results of passing that element to the given replacement functor.


transform

public static <T,RCollection extends java.util.Collection<? super R>,R> RCollection transform(java.lang.Iterable<? extends T> cin,
                                                                                              UnaryFunctor<T,R> fn,
                                                                                              RCollection cout)
Appends the transformed contents of the input to the output.


transform

public static <T,RCollection extends java.util.Collection<? super R>,R> RCollection transform(java.lang.Iterable<? extends T> cin,
                                                                                              BinaryFunctor<T,T,R> fn,
                                                                                              RCollection cout)
Appends the results of transforming successive pairs of elements from the input to the output.


transform

public static <T1,T2,RCollection extends java.util.Collection<? super R>,R> RCollection transform(java.lang.Iterable<? extends T1> cin1,
                                                                                                  java.lang.Iterable<? extends T2> cin2,
                                                                                                  BinaryFunctor<T1,T2,R> fn,
                                                                                                  RCollection cout)
Appends the results of transforming corresponding pairs of elements from the input sto the output.



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