fr.ens_cachan.dptinfo.util
Class Iterators

java.lang.Object
  extended by fr.ens_cachan.dptinfo.util.Iterators

public class Iterators
extends java.lang.Object

A class for generic function calls on Iterable structures.

See Also:
Iterator, java.util.Iterable

Method Summary
static
<A> java.lang.Iterable<A>
filter(Function<? super A,java.lang.Boolean> f, java.lang.Iterable<A> c)
          Returns an Iterable structure that contains the elements of c for which f returns true.
static
<A extends java.lang.Comparable<? super A>,B extends java.lang.Comparable<? super B>,C extends A>
A
fold(Function<Pair<A,B>,A> f, C a, java.lang.Iterable<? extends B> c)
          Iterates through a collection and reduces it using a binary operator from begin to end.
static
<A,B> java.lang.Iterable<B>
map(Function<? super A,B> f, java.lang.Iterable<A> c)
          Returns an Iterable structure that contains the result of f applied to each element in the iteration of c.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

map

public static <A,B> java.lang.Iterable<B> map(Function<? super A,B> f,
                                              java.lang.Iterable<A> c)
Returns an Iterable structure that contains the result of f applied to each element in the iteration of c.

Parameters:
f - a function to be applied to the elements of c.
c - an iterable collection of objects.
Returns:
an iterable structure f(c).

filter

public static <A> java.lang.Iterable<A> filter(Function<? super A,java.lang.Boolean> f,
                                               java.lang.Iterable<A> c)
Returns an Iterable structure that contains the elements of c for which f returns true.

Parameters:
f - a filter to be applied to the elements of c.
c - an iterable collection of objects.
Returns:
an iterable structure with the elements e of c that verify f(e) == true.

fold

public static <A extends java.lang.Comparable<? super A>,B extends java.lang.Comparable<? super B>,C extends A> A fold(Function<Pair<A,B>,A> f,
                                                                                                                       C a,
                                                                                                                       java.lang.Iterable<? extends B> c)
Iterates through a collection and reduces it using a binary operator from begin to end.

Parameters:
f - a binary operator.
a - an initial value.
c - a collection.