T
- The type of the contained objects.public interface YieldsJavaCollection<T>
Modifier and Type | Method and Description |
---|---|
List<T> |
collect()
Get the elements as an immutable
List . |
<C extends Collection<T>> |
collectIn(C collection)
Collects the elements in this iterable in the given collection.
|
<P> Map<P,List<T>> |
groupBy(Fn<? super T,P> property)
|
<P> Map<P,T> |
mapBy(Fn<? super T,P> uniqueProperty)
|
List<T> |
sorted(Comparator<? super T> comparator)
Get a sorted immutable
List of the contents of this iterable. |
<P extends Comparable<P>> |
sortedBy(Fn<? super T,P> property)
Get a sorted immutable
List of the contents of this iterable. |
List<T> collect()
List
. This is the
most common way to obtain a regular implementation of a Java
collection.
If you need more control on the returned Collection
implementation, use collectIn(Collection)
, e.g. if
you need a mutable collection.<C extends Collection<T>> C collectIn(C collection)
sets
does not allow duplicates, and many implementations
also does not maintain the order of the elements. The collection must obviously
support the add(..)
operation. Unless you
have particular needs for the resulting collection, consider using
the collect()
method instead.collection
- The collection to add the elements to.<P extends Comparable<P>> List<T> sortedBy(Fn<? super T,P> property)
List
of the contents of this iterable.property
- The function to obtain the property to sort by of each element.List<T> sorted(Comparator<? super T> comparator)
List
of the contents of this iterable.comparator
- The comparator to use when sorting the elements.
Use Iterate.byOrderingOf(Class)
to use the
natural ordering of the contained elements.<P> Map<P,List<T>> groupBy(Fn<? super T,P> property)
Map
where the keys are derived by applying the given
Fn
on all elements. Each key points to the list of elements
which resolves to the key.property
- the function which resolves the key for elements.<P> Map<P,T> mapBy(Fn<? super T,P> uniqueProperty)
Map
where all keys are derived by applying the given
Fn
on all elements. This is a special case of groupBy(Fn)
where the Fn
will yield a unique key for each element.
In the event of multiple elements resolves to the same key, this method
will fail with an exception. If this uniqueness
cannot be guarantied, consider using groupBy(Fn)
instead.uniqueProperty
- the function which resolves the unique key for each elementCopyright © 2016. All Rights Reserved.