Top Description Methods
org.eclipse.collections.api.ordered

public Interface SortedIterable<T>

extends OrderedIterable<T>
Known Direct Subinterfaces
org.eclipse.collections.api.set.sorted.SortedSetIterable, org.eclipse.collections.api.bag.sorted.SortedBag
Imports
java.util.Comparator, .NoSuchElementException, org.eclipse.collections.api.block.function.Function, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.list.ListIterable, org.eclipse.collections.api.multimap.ordered.SortedIterableMultimap, org.eclipse.collections.api.partition.ordered.PartitionSortedIterable, org.eclipse.collections.api.tuple.Pair

A SortedIterable is an ordered iterable where the elements are stored in sorted order defined by a non-strict partial order relation. The sort order is determined by the Comparator returned by 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 toSortedList() takes O(n) time.
Since
5.0

Method Summary

Modifier and TypeMethod and Description
public 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.

public SortedIterable<T>

Returns:

SortedIterable of distinct elements
distinct
()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.distinct.

Returns a new SortedIterable containing the distinct elements in this iterable.

public SortedIterable<T>
dropWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.dropWhile.

Returns the final elements that do not satisfy the Predicate.

public <V> SortedIterableMultimap<V, T>
groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.groupBy.

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.

public <V> SortedIterableMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

public T
max()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.max.

Returns the maximum element out of this container based on the natural order, not the order of this container.

public T
min()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.min.

Returns the minimum element out of this container based on the natural order, not the order of this container.

public PartitionSortedIterable<T>
partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.partition.

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

public PartitionSortedIterable<T>
partitionWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.partitionWhile.

Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.

public SortedIterable<T>
reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.reject.

Returns all elements of the source collection that return false when evaluating of the predicate.

public <P> SortedIterable<T>
rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public SortedIterable<T>
select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.select.

Returns all elements of the source collection that return true when evaluating the predicate.

public <S> SortedIterable<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

public <P> SortedIterable<T>
selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public SortedIterable<T>
takeWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.takeWhile.

Returns the initial elements that satisfy the Predicate.

public SortedIterable<T>
tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

public <S> ListIterable<Pair<T, S>>
zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.zip.

Returns a OrderedIterable formed from this OrderedIterable and another Iterable by combining corresponding elements in pairs.

public SortedIterable<Pair<T, Integer>>
zipWithIndex()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.zipWithIndex.

Zips this RichIterable with its indices.

Inherited from org.eclipse.collections.api.ordered.OrderedIterable:
collectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcollectWithIndexcollectWithIndexcorrespondsdetectIndexflatCollectflatCollectWithforEachforEachWithIndexforEachWithIndexgetFirstgetFirstOptionalgetLastgetLastOptionalindexOfpartitionWithrejectWithIndexselectWithIndextoStackzipzipWithIndex

Method Detail

comparatorback to summary
public 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.

distinctback to summary
public SortedIterable<T> distinct()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.distinct.

Returns a new SortedIterable containing the distinct elements in this iterable.

Conceptually similar to toSet().toList() but retains the original order. If an element appears multiple times in this iterable, the first one will be copied into the result.

Returns:SortedIterable<T>

SortedIterable of distinct elements

Annotations
@Override
dropWhileback to summary
public SortedIterable<T> dropWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.dropWhile.

Returns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.

Annotations
@Override
groupByback to summary
public <V> SortedIterableMultimap<V, T> groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.groupBy.

Doc from org.eclipse.collections.api.RichIterable.groupBy.

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.

Example using a Java 8 method reference:

Multimap<String, Person> peopleByLastName =
    people.groupBy(Person::getLastName);
Annotations
@Override
groupByEachback to summary
public <V> SortedIterableMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.groupByEach.

Doc from org.eclipse.collections.api.RichIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

Annotations
@Override
maxback to summary
public T max()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.max.

Returns the maximum element out of this container based on the natural order, not the order of this container. If you want the maximum element based on the order of this container, use getLast().

Annotations
@Override
Exceptions
ClassCastException:
if the elements are not Comparable
NoSuchElementException:
if the SortedIterable is empty
minback to summary
public T min()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.min.

Returns the minimum element out of this container based on the natural order, not the order of this container. If you want the minimum element based on the order of this container, use getFirst().

Annotations
@Override
Exceptions
ClassCastException:
if the elements are not Comparable
NoSuchElementException:
if the SortedIterable is empty
partitionback to summary
public PartitionSortedIterable<T> partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.partition.

Doc from org.eclipse.collections.api.RichIterable.partition.

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

Example using a Java 8 lambda expression:

PartitionIterable<Person> newYorkersAndNonNewYorkers =
    people.partition(person -> person.getAddress().getState().getName().equals("New York"));
Annotations
@Override
partitionWhileback to summary
public PartitionSortedIterable<T> partitionWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.partitionWhile.

Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements. Short circuits at the first element which does satisfy the Predicate.

Annotations
@Override
rejectback to summary
public SortedIterable<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.reject.

Doc from org.eclipse.collections.api.RichIterable.reject.

Returns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).

Example using a Java 8 lambda expression:

RichIterable<Person> rejected =
    people.reject(person -> person.person.getLastName().equals("Smith"));
Annotations
@Override
rejectWithback to summary
public <P> SortedIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.rejectWith.

Doc from org.eclipse.collections.api.RichIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> rejected =
    people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
Annotations
@Override
selectback to summary
public SortedIterable<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.select.

Doc from org.eclipse.collections.api.RichIterable.select.

Returns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.

Example using a Java 8 lambda expression:

RichIterable<Person> selected =
    people.select(person -> person.getAddress().getCity().equals("London"));
Annotations
@Override
selectInstancesOfback to summary
public <S> SortedIterable<S> selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.selectInstancesOf.

Doc from org.eclipse.collections.api.RichIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

RichIterable<Integer> integers =
    List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
Annotations
@Override
selectWithback to summary
public <P> SortedIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.selectWith.

Doc from org.eclipse.collections.api.RichIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> selected =
    people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
Annotations
@Override
takeWhileback to summary
public SortedIterable<T> takeWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.takeWhile.

Returns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.

Annotations
@Override
tapback to summary
public SortedIterable<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.tap.

Doc from org.eclipse.collections.api.RichIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

Example using a Java 8 lambda expression:

RichIterable<Person> tapped =
    people.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
zipback to summary
public <S> ListIterable<Pair<T, S>> zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.zip.

Doc from org.eclipse.collections.api.ordered.OrderedIterable.zip.

Returns a OrderedIterable formed from this OrderedIterable and another Iterable by combining corresponding elements in pairs. The second Iterable should also be ordered. If one of the two Iterables is longer than the other, its remaining elements are ignored.

Annotations
@Override
zipWithIndexback to summary
public SortedIterable<Pair<T, Integer>> zipWithIndex()

Redeclares org.eclipse.collections.api.ordered.OrderedIterable.zipWithIndex.

Doc from org.eclipse.collections.api.RichIterable.zipWithIndex.

Zips this RichIterable with its indices.

Annotations
@Override