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

public Interface ListIterable<T>

extends ReversibleIterable<T>
Known Direct Subinterfaces
org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.list.ImmutableList
Imports
java.util.Collections, .Comparator, .List, .ListIterator, .Objects, java.util.concurrent.ExecutorService, org.eclipse.collections.api.annotation.Beta, org.eclipse.collections.api.block.HashingStrategy, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ObjectIntToObjectFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.predicate.primitive.ObjectIntPredicate, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.list.primitive.BooleanList, .ByteList, .CharList, .DoubleList, .FloatList, .IntList, .LongList, .ShortList, org.eclipse.collections.api.multimap.list.ListMultimap, org.eclipse.collections.api.ordered.ReversibleIterable, org.eclipse.collections.api.partition.list.PartitionList, org.eclipse.collections.api.tuple.Pair

An iterable whose items are ordered and may be accessed directly by index. A reverseForEach internal iterator is available iterating over the indexed iterable in reverse, starting from the end and going to the beginning. Additionally, internal iterators are available for batching style iteration which is useful for parallel processing.

Method Summary

Modifier and TypeMethod and Description
public ParallelListIterable<T>
asParallel(ExecutorService executorService, int batchSize)

Returns a parallel iterable of this ListIterable.

public default int
binarySearch(T key, Comparator<? super T> comparator)

Searches for the specified object using the binary search algorithm.

public default int
binarySearch(T key)

Searches for the specified object using the binary search algorithm.

public <V> ListIterable<V>
collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collect.

Returns a new collection with the results of applying the specified function on each element of the source collection.

public BooleanList
collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectBoolean.

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection.

public ByteList
collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectByte.

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection.

public CharList
collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectChar.

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection.

public DoubleList
collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectDouble.

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection.

public FloatList
collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectFloat.

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection.

public <V> ListIterable<V>
collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectIf.

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.

public IntList
collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectInt.

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection.

public LongList
collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectLong.

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection.

public ShortList
collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectShort.

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection.

public <P, V> ListIterable<V>
collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectWith.

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

public default <V> ListIterable<V>
collectWithIndex(ObjectIntToObjectFunction<? super T, ? extends V> function)

Overrides default org.eclipse.collections.api.ordered.ReversibleIterable.collectWithIndex.

Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.

public ListIterable<T>

Returns:

ListIterable of distinct elements
distinct
()

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

Returns a new ListIterable containing the distinct elements in this list.

public ListIterable<T>

Returns:

ListIterable of distinct elements
distinct
(HashingStrategy<? super T> hashingStrategy)

Returns a new ListIterable containing the distinct elements in this list.

public <V> ListIterable<T>
distinctBy(Function<? super T, ? extends V> function)

Returns a new ListIterable containing the distinct elements in this list.

public ListIterable<T>
drop(int count)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.drop.

Returns an iterable after skipping the first count elements or an empty iterable if the count is greater than the length of the iterable.

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

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

Returns the final elements that do not satisfy the Predicate.

public boolean
equals(Object o)

Follows the same general contract as List#equals(Object).

public <V> ListIterable<V>
flatCollect(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.flatCollect.

flatCollect is a special case of collect(Function).

public default <P, V> ListIterable<V>
flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.ordered.ReversibleIterable.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

public default <T2> void
forEachInBoth(ListIterable<T2> other, Procedure2<? super T, ? super T2> procedure)

Iterates over this ListIterable and the other ListIterable together passing the elements of each list as parameters to the specified procedure.

public T
get(int index)

Returns the item at the specified position in this list iterable.

public T
getFirst()

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

Returns the item at index 0 of the container.

public T
getLast()

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

Returns the item at index (size() - 1) of the container.

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

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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> ListMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

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

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

public int
hashCode()

Follows the same general contract as List#hashCode().

public int
lastIndexOf(Object o)

Returns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.

public ListIterator<T>
public ListIterator<T>
listIterator(int index)

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

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

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

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

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

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

public <P> PartitionList<T>
partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.partitionWith.

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

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

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

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

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

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

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

public default ListIterable<T>
rejectWithIndex(ObjectIntPredicate<? super T> predicate)

Returns a new ListIterable with all elements of the collection that return false when evaluating the specified predicate which is supplied each element and its relative index.

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

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

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

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

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

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

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

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

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

public default ListIterable<T>
selectWithIndex(ObjectIntPredicate<? super T> predicate)

Returns a new ListIterable with all elements of the collection that return true when evaluating the specified predicate which is supplied each element and its relative index.

public ListIterable<T>
subList(int fromIndex, int toIndex)

public ListIterable<T>
take(int count)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.take.

Returns the first count elements of the iterable or all the elements in the iterable if count is greater than the length of the iterable.

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

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

Returns the initial elements that satisfy the Predicate.

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

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

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

public ImmutableList<T>
toImmutable()

Converts the ListIterable to an immutable implementation.

public ListIterable<T>
toReversed()

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.toReversed.

Returns a new ReversibleIterable in reverse order.

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

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

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

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

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

Zips this RichIterable with its indices.

Inherited from org.eclipse.collections.api.ordered.ReversibleIterable:
asReverseddetectLastIndexreverseForEachreverseForEachWithIndex

Method Detail

asParallelback to summary
public ParallelListIterable<T> asParallel(ExecutorService executorService, int batchSize)

Returns a parallel iterable of this ListIterable.

Annotations
@Beta
Since
6.0
binarySearchback to summary
public default int binarySearch(T key, Comparator<? super T> comparator)

Searches for the specified object using the binary search algorithm. The list must be sorted into ascending order according to the specified comparator.

See Also
Collections#binarySearch(List, Object, Comparator)
binarySearchback to summary
public default int binarySearch(T key)

Searches for the specified object using the binary search algorithm. The elements in this list must implement Comparable and the list must be sorted into ascending order.

See Also
Collections#binarySearch(List, Object)
collectback to summary
public <V> ListIterable<V> collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collect.

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

Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

RichIterable<String> names =
    people.collect(person -> person.getFirstName() + " " + person.getLastName());
Annotations
@Override
collectBooleanback to summary
public BooleanList collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectBoolean.

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

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

BooleanIterable licenses =
    people.collectBoolean(person -> person.hasDrivingLicense());
Annotations
@Override
collectByteback to summary
public ByteList collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectByte.

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

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

ByteIterable bytes =
    people.collectByte(person -> person.getCode());
Annotations
@Override
collectCharback to summary
public CharList collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectChar.

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

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

CharIterable chars =
    people.collectChar(person -> person.getMiddleInitial());
Annotations
@Override
collectDoubleback to summary
public DoubleList collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectDouble.

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

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

DoubleIterable doubles =
    people.collectDouble(person -> person.getMilesFromNorthPole());
Annotations
@Override
collectFloatback to summary
public FloatList collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectFloat.

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

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

FloatIterable floats =
    people.collectFloat(person -> person.getHeightInInches());
Annotations
@Override
collectIfback to summary
public <V> ListIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectIf.

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

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the optimized equivalent of calling iterable.select(predicate).collect(function).

Example using a Java 8 lambda and method reference:

RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString);

Example using Predicates factory:

RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
Annotations
@Override
collectIntback to summary
public IntList collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectInt.

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

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

IntIterable ints =
    people.collectInt(person -> person.getAge());
Annotations
@Override
collectLongback to summary
public LongList collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectLong.

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

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

LongIterable longs =
    people.collectLong(person -> person.getGuid());
Annotations
@Override
collectShortback to summary
public ShortList collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectShort.

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

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

ShortIterable shorts =
    people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth());
Annotations
@Override
collectWithback to summary
public <P, V> ListIterable<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.collectWith.

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

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

Example using a Java 8 lambda expression:

RichIterable<Integer> integers =
    Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));
Annotations
@Override
collectWithIndexback to summary
public default <V> ListIterable<V> collectWithIndex(ObjectIntToObjectFunction<? super T, ? extends V> function)

Overrides default org.eclipse.collections.api.ordered.ReversibleIterable.collectWithIndex.

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

Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.

Annotations
@Override
Since
9.1.
distinctback to summary
public ListIterable<T> distinct()

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

Returns a new ListIterable containing the distinct elements in this list.

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

Returns:ListIterable<T>

ListIterable of distinct elements

Annotations
@Override
Since
3.0
distinctback to summary
public ListIterable<T> distinct(HashingStrategy<? super T> hashingStrategy)

Returns a new ListIterable containing the distinct elements in this list. Takes a HashingStrategy.

Returns:ListIterable<T>

ListIterable of distinct elements

Since
7.0
distinctByback to summary
public <V> ListIterable<T> distinctBy(Function<? super T, ? extends V> function)

Returns a new ListIterable containing the distinct elements in this list. The specified function will be used to create a HashingStrategy to unique the elements.

Since
9.0
See Also
ListIterable#distinct(HashingStrategy)
dropback to summary
public ListIterable<T> drop(int count)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.drop.

Doc from org.eclipse.collections.api.ordered.ReversibleIterable.drop.

Returns an iterable after skipping the first count elements or an empty iterable if the count is greater than the length of the iterable.

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

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

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

Annotations
@Override
Since
3.0
equalsback to summary
public boolean equals(Object o)

Follows the same general contract as List#equals(Object).

Annotations
@Override
flatCollectback to summary
public <V> ListIterable<V> flatCollect(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.flatCollect.

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

flatCollect is a special case of collect(Function). With collect, when the Function returns a collection, the result is a collection of collections. flatCollect outputs a single "flattened" collection instead. This method is commonly called flatMap.

Consider the following example where we have a Person class, and each Person has a list of Address objects. Take the following Function:

Function<Person, List<Address>> addressFunction = Person::getAddresses;
RichIterable<Person> people = ...;
Using collect returns a collection of collections of addresses.
RichIterable<List<Address>> addresses = people.collect(addressFunction);
Using flatCollect returns a single flattened list of addresses.
RichIterable<Address> addresses = people.flatCollect(addressFunction);
Annotations
@Override
flatCollectWithback to summary
public default <P, V> ListIterable<V> flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.ordered.ReversibleIterable.flatCollectWith.

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

Same as flatCollect, only with a Function2 that is passed an extra parameter.

Annotations
@Override
Since
9.2
forEachInBothback to summary
public default <T2> void forEachInBoth(ListIterable<T2> other, Procedure2<? super T, ? super T2> procedure)

Iterates over this ListIterable and the other ListIterable together passing the elements of each list as parameters to the specified procedure.

Since
10.3
getback to summary
public T get(int index)

Returns the item at the specified position in this list iterable.

getFirstback to summary
public T getFirst()

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

Returns the item at index 0 of the container. If the container is empty, null is returned. If null is a valid item of the container, then a developer will need to check to see if the container is empty first.

Annotations
@Override
getLastback to summary
public T getLast()

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

Returns the item at index (size() - 1) of the container. If the container is empty, null is returned. If null is a valid item of the container, then a developer will need to check to see if the container is empty first.

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

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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> ListMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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
hashCodeback to summary
public int hashCode()

Follows the same general contract as List#hashCode().

Annotations
@Override
lastIndexOfback to summary
public int lastIndexOf(Object o)

Returns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.

listIteratorback to summary
public ListIterator<T> listIterator()
Since
1.0.
See Also
List#listIterator()
listIteratorback to summary
public ListIterator<T> listIterator(int index)
Since
1.0.
See Also
List#listIterator(int)
partitionback to summary
public PartitionList<T> partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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 PartitionList<T> partitionWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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
Since
3.0
partitionWithback to summary
public <P> PartitionList<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.partitionWith.

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

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

Example using a Java 8 lambda expression:

PartitionIterable<Person> newYorkersAndNonNewYorkers =
    people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
Annotations
@Override
rejectback to summary
public ListIterable<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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> ListIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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
rejectWithIndexback to summary
public default ListIterable<T> rejectWithIndex(ObjectIntPredicate<? super T> predicate)

Returns a new ListIterable with all elements of the collection that return false when evaluating the specified predicate which is supplied each element and its relative index.

Since
11.0
selectback to summary
public ListIterable<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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> ListIterable<S> selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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> ListIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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
selectWithIndexback to summary
public default ListIterable<T> selectWithIndex(ObjectIntPredicate<? super T> predicate)

Returns a new ListIterable with all elements of the collection that return true when evaluating the specified predicate which is supplied each element and its relative index.

Since
11.0
subListback to summary
public ListIterable<T> subList(int fromIndex, int toIndex)
Since
6.0
See Also
List#subList(int, int)
takeback to summary
public ListIterable<T> take(int count)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.take.

Doc from org.eclipse.collections.api.ordered.ReversibleIterable.take.

Returns the first count elements of the iterable or all the elements in the iterable if count is greater than the length of the iterable.

Annotations
@Override
takeWhileback to summary
public ListIterable<T> takeWhile(Predicate<? super T> predicate)

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

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

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

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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
toImmutableback to summary
public ImmutableList<T> toImmutable()

Converts the ListIterable to an immutable implementation. Returns this for immutable lists.

Since
5.0
toReversedback to summary
public ListIterable<T> toReversed()

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.toReversed.

Doc from org.eclipse.collections.api.ordered.ReversibleIterable.toReversed.

Returns a new ReversibleIterable in reverse order.

Annotations
@Override
zipback to summary
public <S> ListIterable<Pair<T, S>> zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.ordered.ReversibleIterable.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 ListIterable<Pair<T, Integer>> zipWithIndex()

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

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

Zips this RichIterable with its indices.

Annotations
@Override