|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.littleshoot.util.CollectionUtilsImpl
public class CollectionUtilsImpl
An implementation of the collection utilities interface.
| Constructor Summary | |
|---|---|
CollectionUtilsImpl()
|
|
| Method Summary | ||
|---|---|---|
|
foldl(F2<T2,T1,T2> f,
T2 initial,
Collection<? extends T1> collection)
Left-associative fold function. |
|
|
forAllDo(Collection<? extends T> collection,
Closure<T> closure)
Executes the specified Closure on all elements of the
Collection. |
|
|
forAllDoSynchronized(Collection<? extends T> collection,
Closure<T> closure)
Executes the specified Closure on all elements of the
Collection. |
|
|
map(Collection<? extends T1> collection,
F1<T1,T2> f)
Maps the items in a collection using a given function. |
|
|
matchesAll(Collection<? extends T> collection,
Predicate<T> pred)
Checks to see if all of the elements of the given Collection
matches the predicate. |
|
|
matchesAny(Collection<? extends T> collection,
Predicate<T> pred)
Checks to see if any of the elements of the given Collection
matches the predicate. |
|
|
select(Collection<? extends T> collection,
Predicate<T> predicate)
Returns a collection of all of the elements in a given collection that satisfy a given predicate. |
|
|
select(Collection<? extends T> collection,
Predicate<T> predicate,
Collection<T> result)
Adds all of the elements in a given collection that satisfy a given predicate to another given collection. |
|
|
selectFirst(Collection<? extends T> collection,
Predicate<T> pred)
Selects the first element matching the desired criteria, or null if no matching element exists. |
|
|
selectFirstSynchronized(Collection<? extends T> collection,
Predicate<T> pred)
Selects the first element matching the desired criteria, or null if no matching element exists. |
|
long |
sum(Collection<Long> c)
Returns the sum of a collection of long integers. |
|
|
synchronizedMatchesAny(Collection<? extends T> elements,
Predicate<T> pred)
Checks to see if any of the elements of the given Collection
matches the predicate. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CollectionUtilsImpl()
| Method Detail |
|---|
public <T> void select(Collection<? extends T> collection,
Predicate<T> predicate,
Collection<T> result)
select in interface CollectionUtilsT - The type of objects in the collection and expected by the predicate.collection - The collection.predicate - The predicate used to evaluate each element.result - The collection to which to add the elements that satisfy the
predicate.
public <T> Collection<T> select(Collection<? extends T> collection,
Predicate<T> predicate)
select in interface CollectionUtilsT - The type of objects in the collection and expected by the predicate.collection - The collection.predicate - The predicate used to evaluate each element.
public <T> void forAllDo(Collection<? extends T> collection,
Closure<T> closure)
Closure on all elements of the
Collection.
forAllDo in interface CollectionUtilsT - The type of elements in the Collection.collection - The Collection with elements to perform the
closure on.closure - The Closure to execute on each element.
public <T> void forAllDoSynchronized(Collection<? extends T> collection,
Closure<T> closure)
Closure on all elements of the
Collection. Also synchronizes on the Collection.
forAllDoSynchronized in interface CollectionUtilsT - The type of elements in the Collection.collection - The Collection with elements to perform the
closure on.closure - The Closure to execute on each element.
public <T1,T2> Collection<T2> map(Collection<? extends T1> collection,
F1<T1,T2> f)
map in interface CollectionUtilsT1 - The type of elements in the original collection.T2 - The type to which we are mapping.collection - The collection to map.f - The mapping function.
public <T1,T2> T2 foldl(F2<T2,T1,T2> f,
T2 initial,
Collection<? extends T1> collection)
foldl in interface CollectionUtilsT1 - The type of the collection over which to fold.T2 - The type returned by the folding function.f - The folding function.initial - The initial value for folding.collection - The collection.
public long sum(Collection<Long> c)
sum in interface CollectionUtilsc - The collection of long integers.
public <T> boolean matchesAny(Collection<? extends T> collection,
Predicate<T> pred)
CollectionUtilsCollection
matches the predicate.
matchesAny in interface CollectionUtilsT - The type of elements in the Collection.collection - The Collection to check.pred - The Predicate determining if an element matches.
true if there's any element in the
Collection matching the desired criteria.
public <T> boolean matchesAll(Collection<? extends T> collection,
Predicate<T> pred)
CollectionUtilsCollection
matches the predicate.
matchesAll in interface CollectionUtilsT - The type of elements in the Collection.collection - The Collection to check.pred - The Predicate determining if all elements match.
true if all elements in the
Collection match the desired criteria.
public <T> boolean synchronizedMatchesAny(Collection<? extends T> elements,
Predicate<T> pred)
CollectionUtilsCollection
matches the predicate. Synchronizes on the Collection.
synchronizedMatchesAny in interface CollectionUtilsT - The type of elements in the Collection.elements - The Collection to check.pred - The Predicate determining if an element matches.
true if there's any element in the
Collection matching the desired criteria.
public <T> T selectFirst(Collection<? extends T> collection,
Predicate<T> pred)
CollectionUtilsnull if no matching element exists. Synchronizes on the
Collection.
selectFirst in interface CollectionUtilsT - The type of elements in the Collection.collection - The Collection of elements to search.pred - The Predicate determining a match.
null if no
such element exists.
public <T> T selectFirstSynchronized(Collection<? extends T> collection,
Predicate<T> pred)
CollectionUtilsnull if no matching element exists. Synchronizes on the
Collection.
selectFirstSynchronized in interface CollectionUtilsT - The type of elements in the Collection.collection - The Collection of elements to search.pred - The Predicate determining a match.
null if no
such element exists.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||