public interface SortedIterable<T> extends RichIterable<T>
comparator()
or is the natural
ordering if comparator()
returns null
. Operations that would sort the collection can be faster than
O(n log n). For example RichIterable.toSortedList()
takes O(n) time.Modifier and Type | Method and Description |
---|---|
Comparator<? super T> |
comparator()
Returns the comparator used to order the elements in this container, or null if this container uses the natural
ordering of its elements.
|
SortedIterable<T> |
distinct()
Returns a new
SortedIterable containing the distinct elements in this iterable. |
SortedIterable<T> |
dropWhile(Predicate<? super T> predicate)
Returns the final elements that do not satisfy the Predicate.
|
<V> SortedIterableMultimap<V,T> |
groupBy(Function<? super T,? extends V> function)
For each element of the iterable, the function is evaluated and the results of these evaluations are collected
into a new multimap, where the transformed value is the key and the original values are added to the same (or similar)
species of collection as the source iterable.
|
<V> SortedIterableMultimap<V,T> |
groupByEach(Function<? super T,? extends Iterable<V>> function)
Similar to
RichIterable.groupBy(Function) , except the result of evaluating function will return a collection of keys
for each value. |
T |
max()
Returns the maximum element out of this container based on the natural order, not the order of this container.
|
T |
min()
Returns the minimum element out of this container based on the natural order, not the order of this container.
|
PartitionSortedIterable<T> |
partition(Predicate<? super T> predicate)
Filters a collection into a PartitionedIterable based on the evaluation of the predicate.
|
PartitionSortedIterable<T> |
partitionWhile(Predicate<? super T> predicate)
Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.
|
SortedIterable<T> |
reject(Predicate<? super T> predicate)
Returns all elements of the source collection that return false when evaluating of the predicate.
|
<P> SortedIterable<T> |
rejectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.reject(Predicate) , except with an evaluation parameter for the second generic argument in Predicate2 . |
SortedIterable<T> |
select(Predicate<? super T> predicate)
Returns all elements of the source collection that return true when evaluating the predicate.
|
<S> SortedIterable<S> |
selectInstancesOf(Class<S> clazz)
Returns all elements of the source collection that are instances of the Class
clazz . |
<P> SortedIterable<T> |
selectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.select(Predicate) , except with an evaluation parameter for the second generic argument in Predicate2 . |
SortedIterable<T> |
takeWhile(Predicate<? super T> predicate)
Returns the initial elements that satisfy the Predicate.
|
MutableStack<T> |
toStack()
Converts the SortedIterable to a mutable MutableStack implementation.
|
<S> ListIterable<Pair<T,S>> |
zip(Iterable<S> that)
Returns a
RichIterable formed from this RichIterable and another RichIterable by
combining corresponding elements in pairs. |
SortedIterable<Pair<T,Integer>> |
zipWithIndex()
Zips this
RichIterable with its indices. |
aggregateBy, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collect, collectBoolean, collectBoolean, collectByte, collectByte, collectChar, collectChar, collectDouble, collectDouble, collectFloat, collectFloat, collectIf, collectIf, collectInt, collectInt, collectLong, collectLong, collectShort, collectShort, collectWith, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, flatCollect, flatCollect, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, maxBy, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, partitionWith, reject, rejectWith, select, selectWith, size, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
forEach, forEachWith, forEachWithIndex
forEach, iterator, spliterator
Comparator<? super T> comparator()
SortedIterable<T> takeWhile(Predicate<? super T> predicate)
SortedIterable<T> dropWhile(Predicate<? super T> predicate)
PartitionSortedIterable<T> partitionWhile(Predicate<? super T> predicate)
SortedIterable<T> distinct()
SortedIterable
containing the distinct elements in this iterable.
Conceptually similar to RichIterable.toSet()
.RichIterable.toList()
but retains the original order. If an element appears
multiple times in this iterable, the first one will be copied into the result.SortedIterable
of distinct elementsMutableStack<T> toStack()
T min()
RichIterable.getFirst()
.min
in interface RichIterable<T>
ClassCastException
- if the elements are not Comparable
NoSuchElementException
- if the SortedIterable is emptyT max()
RichIterable.getLast()
.max
in interface RichIterable<T>
ClassCastException
- if the elements are not Comparable
NoSuchElementException
- if the SortedIterable is emptySortedIterable<T> select(Predicate<? super T> predicate)
RichIterable
e.g. return people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getCity().equals("Metuchen"); } });
select
in interface RichIterable<T>
<P> SortedIterable<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
RichIterable.select(Predicate)
, except with an evaluation parameter for the second generic argument in Predicate2
.selectWith
in interface RichIterable<T>
predicate
- a Predicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
RichIterable.select(Predicate)
SortedIterable<T> reject(Predicate<? super T> predicate)
RichIterable
e.g. return people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } });
e.g. return people.reject(Predicates.attributeEqual("lastName", "Smith"));
reject
in interface RichIterable<T>
predicate
- a Predicate
to use as the reject criteriaPredicate.accept(Object)
method to evaluate to false<P> SortedIterable<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
RichIterable.reject(Predicate)
, except with an evaluation parameter for the second generic argument in Predicate2
.rejectWith
in interface RichIterable<T>
predicate
- a Predicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
RichIterable.select(Predicate)
PartitionSortedIterable<T> partition(Predicate<? super T> predicate)
RichIterable
e.g. return people.partition(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });
partition
in interface RichIterable<T>
<S> SortedIterable<S> selectInstancesOf(Class<S> clazz)
RichIterable
clazz
.selectInstancesOf
in interface RichIterable<T>
<V> SortedIterableMultimap<V,T> groupBy(Function<? super T,? extends V> function)
RichIterable
e.g. return people.groupBy(new Function<Person, String>() { public String value(Person person) { return person.getFirstName() + " " + person.getLastName(); } });
groupBy
in interface RichIterable<T>
<V> SortedIterableMultimap<V,T> groupByEach(Function<? super T,? extends Iterable<V>> function)
RichIterable
RichIterable.groupBy(Function)
, except the result of evaluating function will return a collection of keys
for each value.groupByEach
in interface RichIterable<T>
<S> ListIterable<Pair<T,S>> zip(Iterable<S> that)
RichIterable
RichIterable
formed from this RichIterable
and another RichIterable
by
combining corresponding elements in pairs. If one of the two RichIterable
s is longer than the other, its
remaining elements are ignored.zip
in interface RichIterable<T>
S
- the type of the second half of the returned pairsthat
- The RichIterable
providing the second half of each result pairRichIterable
containing pairs consisting of corresponding elements of this RichIterable
and that. The length of the returned RichIterable
is the minimum of the lengths of
this RichIterable
and that.SortedIterable<Pair<T,Integer>> zipWithIndex()
RichIterable
RichIterable
with its indices.zipWithIndex
in interface RichIterable<T>
RichIterable
containing pairs consisting of all elements of this RichIterable
paired with their index. Indices start at 0.RichIterable.zip(Iterable)
Copyright © 2004–2017. All rights reserved.