|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jaggregate.Iterables
public class Iterables
Functions that offer Collection-like functionality for Iterables.
Method Summary | ||
---|---|---|
static
|
allSatisfy(Iterable<? extends E> items,
UnaryCondition<? super E> discriminator)
Answers true if the given discriminator answers true for every
element yielded by the given iterable, or if the iterable yields no elements;
otherwise answers false . |
|
static
|
anySatisfy(Iterable<? extends E> items,
UnaryCondition<? super E> discriminator)
Answers true if the given discriminator answers true for any
element yielded by the given iterable; answers false otherwise, or if the
iterable yields no elements. |
|
static
|
collect(Iterable<? extends E> items,
UnaryFunctor<? super E,? extends R> transformer)
Wraps the given iterable with another iterable whose iterator will transform items using the given functor. |
|
static
|
detect(Iterable<? extends E> items,
UnaryCondition<? super E> discriminator)
Answers the first element yielded by the given iterable for which the given discriminator answers true when given that element as an argument. |
|
static
|
inject(Iterable<? extends E> items,
R initialValue,
BinaryFunctor<? super R,? super E,? extends R> operation)
Answers the final result of evaluating the given operation using each element of the given iterable and the previous evaluation result as the parameters. |
|
static
|
occurrencesOf(Iterable<? extends E> items,
E target)
Answers the number of elements yielded by the given iterable which are equivalent to the given target. |
|
static
|
removeIf(Iterable<? extends E> items,
UnaryCondition<? super E> discriminator)
Removes items from the given iterable which match the given predicate. |
|
static
|
retainIf(Iterable<? extends E> items,
UnaryCondition<? super E> discriminator)
Removes items from the given iterable which do not match the given predicate. |
|
static
|
select(Iterable<? extends E> items,
UnaryCondition<? super E> discriminator)
Wraps the given iterable with another iterable whose iterator will filter out items which do not match the given predicate. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <E> boolean allSatisfy(Iterable<? extends E> items, UnaryCondition<? super E> discriminator)
true
if the given discriminator answers true
for every
element yielded by the given iterable, or if the iterable yields no elements;
otherwise answers false
.
It is unspecified whether discriminator
will be evaluated with every
element that the iterable yields.
E
- type of the items to iterate overitems
- the items to iterate overdiscriminator
- the discriminator to evaluate
discriminator
is true
for every element
NullPointerException
- if items
or discriminator
is null
Collection.allSatisfy(UnaryCondition)
public static <E> boolean anySatisfy(Iterable<? extends E> items, UnaryCondition<? super E> discriminator)
true
if the given discriminator answers true
for any
element yielded by the given iterable; answers false
otherwise, or if the
iterable yields no elements.
It is unspecified whether discriminator
will be evaluated with every
element that the iterable yields.
E
- type of the items to iterate overitems
- the items to iterate overdiscriminator
- the discriminator to evaluate
discriminator
is true
for any element
NullPointerException
- if items
or discriminator
is null
Collection.anySatisfy(UnaryCondition)
public static <E,R> Iterable<R> collect(Iterable<? extends E> items, UnaryFunctor<? super E,? extends R> transformer)
E
- type of the items to iterate overR
- type of the transformed iterated itemsitems
- the iterable to wraptransformer
- functor used to transform elements
NullPointerException
- if items
or transformer
is
null
Collection.collect(UnaryFunctor)
public static <E> E detect(Iterable<? extends E> items, UnaryCondition<? super E> discriminator)
true
when given that element as an argument.
discriminator
will only be evaluated until such an object is found or
until the iterable yields no elements to use as arguments. That is, there may
be elements that the iterable yields that are never used as arguments to
discriminator
.
E
- type of the items to iterate overitems
- the items to iterate overdiscriminator
- the discriminator to evaluate
discriminator
NoSuchElementException
- if no item satisfies
discriminator
NullPointerException
- if items
or discriminator
is
null
public static <E> int occurrencesOf(Iterable<? extends E> items, E target)
E
- type of the items to iterate overitems
- the items to iterate overtarget
- the object to compare against
NullPointerException
- if items
is null
public static <E,R> R inject(Iterable<? extends E> items, R initialValue, BinaryFunctor<? super R,? super E,? extends R> operation)
operation
is performed with the given initial
value as the first parameter, and the first element of the iterable as the second
parameter. Subsequent evaluations are done with the result of the previous
evaluation as the first parameter, and the next element as the second parameter.
The result of the last evaluation is answered.
E
- type of the items to iterate overR
- type of the initial value, intermediate results, and final resultitems
- the items to iterate overinitialValue
- first parameter for the first evaluationoperation
- the operation to evaluate
NullPointerException
- if items
or operation
is null
Collection.inject(Object, BinaryFunctor)
public static <E> boolean removeIf(Iterable<? extends E> items, UnaryCondition<? super E> discriminator)
E
- type of the items to iterate overitems
- items to iterate overdiscriminator
- tells which items should be removed
true
if any removals occurred
NullPointerException
- if items
or discriminator
is null
UnsupportedOperationException
- if items
's iterator does not
support removalExtensibleCollection.removeIf(UnaryCondition)
public static <E> boolean retainIf(Iterable<? extends E> items, UnaryCondition<? super E> discriminator)
E
- type of the items to iterate overitems
- items to iterate overdiscriminator
- tells which items should be retained
true
if any removals occurred
NullPointerException
- if items
or discriminator
is null
UnsupportedOperationException
- if items
's iterator does not
support removalExtensibleCollection.retainIf(UnaryCondition)
public static <E> Iterable<E> select(Iterable<? extends E> items, UnaryCondition<? super E> discriminator)
E
- type of the items to iterate overitems
- the iterable to wrapdiscriminator
- predicate used to filter elements
NullPointerException
- if items
or discriminator
is
null
Collection.select(UnaryCondition)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |