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

public Interface MutableList<T>

extends MutableCollection<T>, List<T>, Cloneable, ListIterable<T>
Known Direct Subinterfaces
org.eclipse.collections.api.list.FixedSizeList, org.eclipse.collections.api.list.MultiReaderList
Imports
java.util.Collections, .Comparator, .List, .Random, org.eclipse.collections.api.block.HashingStrategy, org.eclipse.collections.api.block.factory.SerializableComparators, 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, org.eclipse.collections.api.collection.MutableCollection, org.eclipse.collections.api.factory.Lists, org.eclipse.collections.api.factory.primitive.BooleanLists, .ByteLists, .CharLists, .DoubleLists, .FloatLists, .IntLists, .LongLists, .ShortLists, org.eclipse.collections.api.list.primitive.MutableBooleanList, .MutableByteList, .MutableCharList, .MutableDoubleList, .MutableFloatList, .MutableIntList, .MutableLongList, .MutableShortList, org.eclipse.collections.api.multimap.list.MutableListMultimap, org.eclipse.collections.api.partition.list.PartitionMutableList, org.eclipse.collections.api.tuple.Pair

A MutableList is an extension of java.util.List which provides methods matching the Smalltalk Collection protocol.

Method Summary

Modifier and TypeMethod and Description
public MutableList<T>
asSynchronized()

Redeclares org.eclipse.collections.api.collection.MutableCollection.asSynchronized.

Returns a synchronized wrapper backed by this collection.

public MutableList<T>

Returns:

an unmodifiable view of this list
asUnmodifiable
()

Redeclares org.eclipse.collections.api.collection.MutableCollection.asUnmodifiable.

Returns an unmodifiable view of the list.

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

Implements org.eclipse.collections.api.collection.MutableCollection.collect, org.eclipse.collections.api.list.ListIterable.collect.

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

public default MutableBooleanList
collectBoolean(BooleanFunction<? super T> booleanFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectBoolean.

Implements org.eclipse.collections.api.list.ListIterable.collectBoolean.

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

public default MutableByteList
collectByte(ByteFunction<? super T> byteFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectByte.

Implements org.eclipse.collections.api.list.ListIterable.collectByte.

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

public default MutableCharList
collectChar(CharFunction<? super T> charFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectChar.

Implements org.eclipse.collections.api.list.ListIterable.collectChar.

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

public default MutableDoubleList
collectDouble(DoubleFunction<? super T> doubleFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectDouble.

Implements org.eclipse.collections.api.list.ListIterable.collectDouble.

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

public default MutableFloatList
collectFloat(FloatFunction<? super T> floatFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectFloat.

Implements org.eclipse.collections.api.list.ListIterable.collectFloat.

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

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

Implements org.eclipse.collections.api.collection.MutableCollection.collectIf, org.eclipse.collections.api.list.ListIterable.collectIf.

Returns a new MutableCollection with the results of applying the specified function to each element of the source collection, but only for elements that evaluate to true for the specified predicate.

public default MutableIntList
collectInt(IntFunction<? super T> intFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectInt.

Implements org.eclipse.collections.api.list.ListIterable.collectInt.

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

public default MutableLongList
collectLong(LongFunction<? super T> longFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectLong.

Implements org.eclipse.collections.api.list.ListIterable.collectLong.

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

public default MutableShortList
collectShort(ShortFunction<? super T> shortFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectShort.

Implements org.eclipse.collections.api.list.ListIterable.collectShort.

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

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

Implements org.eclipse.collections.api.collection.MutableCollection.collectWith, org.eclipse.collections.api.list.ListIterable.collectWith.

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

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

Overrides default org.eclipse.collections.api.list.ListIterable.collectWithIndex.

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

public MutableList<T>
distinct()

Redeclares org.eclipse.collections.api.list.ListIterable.distinct.

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

public MutableList<T>
distinct(HashingStrategy<? super T> hashingStrategy)

Redeclares org.eclipse.collections.api.list.ListIterable.distinct.

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

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

Redeclares org.eclipse.collections.api.list.ListIterable.distinctBy.

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

public MutableList<T>
drop(int count)

Redeclares org.eclipse.collections.api.list.ListIterable.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 MutableList<T>
dropWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.list.ListIterable.dropWhile.

Returns the final elements that do not satisfy the Predicate.

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

Overrides default org.eclipse.collections.api.collection.MutableCollection.flatCollectWith, org.eclipse.collections.api.list.ListIterable.flatCollectWith.

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

public default T
getFirst()

Overrides default java.util.List.getFirst.

Implements org.eclipse.collections.api.RichIterable.getFirst, org.eclipse.collections.api.list.ListIterable.getFirst.

This default override exists because java.util.List added a default getFirst() method in Java 21.

public default T
getLast()

Overrides default java.util.List.getLast.

Implements org.eclipse.collections.api.RichIterable.getLast, org.eclipse.collections.api.list.ListIterable.getLast.

This default override exists because java.util.List added a default getLast() method in Java 21.

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

Redeclares org.eclipse.collections.api.collection.MutableCollection.groupBy, org.eclipse.collections.api.list.ListIterable.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> MutableListMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.collection.MutableCollection.groupByEach, org.eclipse.collections.api.list.ListIterable.groupByEach.

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

public default int
indexOf(Object o)

Overrides default org.eclipse.collections.api.ordered.OrderedIterable.indexOf.

Implements java.util.List.indexOf.

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

public MutableList<T>
newEmpty()

Redeclares org.eclipse.collections.api.collection.MutableCollection.newEmpty.

Creates a new empty mutable version of the same collection type.

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

Redeclares org.eclipse.collections.api.collection.MutableCollection.partition, org.eclipse.collections.api.list.ListIterable.partition.

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

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

Redeclares org.eclipse.collections.api.list.ListIterable.partitionWhile.

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

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

Redeclares org.eclipse.collections.api.collection.MutableCollection.partitionWith, org.eclipse.collections.api.list.ListIterable.partitionWith.

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

public default MutableList<T>
reject(Predicate<? super T> predicate)

Implements org.eclipse.collections.api.collection.MutableCollection.reject, org.eclipse.collections.api.list.ListIterable.reject.

Returns a MutableCollection with all elements that evaluate to false for the specified predicate.

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

Implements org.eclipse.collections.api.collection.MutableCollection.rejectWith, org.eclipse.collections.api.list.ListIterable.rejectWith.

Returns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter.

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

Overrides default org.eclipse.collections.api.list.ListIterable.rejectWithIndex.

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

public default MutableList<T>
reverseThis()

Mutates this list by reversing its order and returns the current list as a result.

public default MutableList<T>
select(Predicate<? super T> predicate)

Implements org.eclipse.collections.api.collection.MutableCollection.select, org.eclipse.collections.api.list.ListIterable.select.

Returns a MutableCollection with all elements that evaluate to true for the specified predicate.

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

Redeclares org.eclipse.collections.api.collection.MutableCollection.selectInstancesOf, org.eclipse.collections.api.list.ListIterable.selectInstancesOf.

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

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

Implements org.eclipse.collections.api.collection.MutableCollection.selectWith, org.eclipse.collections.api.list.ListIterable.selectWith.

Returns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter.

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

Overrides default org.eclipse.collections.api.list.ListIterable.selectWithIndex.

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

public default MutableList<T>
shuffleThis()

Mutates this list by shuffling its elements.

public default MutableList<T>
shuffleThis(Random random)

Mutates this list by shuffling its elements using the specified random.

public default MutableList<T>
sortThis(Comparator<? super T> comparator)

Sorts the internal data structure of this list and returns the list itself as a convenience.

public default MutableList<T>
sortThis()

Sorts the internal data structure of this list and returns the list itself as a convenience.

public default <V extends Comparable<? super V>> MutableList<T>
sortThisBy(Function<? super T, ? extends V> function)

Sorts the internal data structure of this list based on the natural order of the attribute returned by function.

public MutableList<T>
sortThisByBoolean(BooleanFunction<? super T> function)

public MutableList<T>
sortThisByByte(ByteFunction<? super T> function)

public MutableList<T>
sortThisByChar(CharFunction<? super T> function)

public MutableList<T>
sortThisByDouble(DoubleFunction<? super T> function)

public MutableList<T>
sortThisByFloat(FloatFunction<? super T> function)

public MutableList<T>
sortThisByInt(IntFunction<? super T> function)

public MutableList<T>
sortThisByLong(LongFunction<? super T> function)

public MutableList<T>
sortThisByShort(ShortFunction<? super T> function)

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

Redeclares java.util.List.subList, org.eclipse.collections.api.list.ListIterable.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

public MutableList<T>
take(int count)

Redeclares org.eclipse.collections.api.list.ListIterable.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 MutableList<T>
takeWhile(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.list.ListIterable.takeWhile.

Returns the initial elements that satisfy the Predicate.

public default MutableList<T>
tap(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.collection.MutableCollection.tap, org.eclipse.collections.api.list.ListIterable.tap.

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

public default Object[]
toArray()

Overrides default org.eclipse.collections.api.collection.MutableCollection.toArray, org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

public default <T1> T1[]
toArray(T1[] a)

Overrides default org.eclipse.collections.api.collection.MutableCollection.toArray, org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

public default ImmutableList<T>
public default ImmutableList<T>
toImmutableList()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableList.

Converts the MutableList to the default ImmutableList implementation.

public default MutableList<T>
toReversed()

Implements org.eclipse.collections.api.list.ListIterable.toReversed.

Returns a new MutableList in reverse order.

public default MutableList<T>
with(T element)

Implements org.eclipse.collections.api.collection.MutableCollection.with.

This method allows mutable and fixed size collections the ability to add elements to their existing elements.

public default MutableList<T>
withAll(Iterable<? extends T> elements)

Implements org.eclipse.collections.api.collection.MutableCollection.withAll.

This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.

public default MutableList<T>
without(T element)

Implements org.eclipse.collections.api.collection.MutableCollection.without.

This method allows mutable and fixed size collections the ability to remove elements from their existing elements.

public default MutableList<T>
withoutAll(Iterable<? extends T> elements)

Implements org.eclipse.collections.api.collection.MutableCollection.withoutAll.

This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.

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

Redeclares org.eclipse.collections.api.collection.MutableCollection.zip, org.eclipse.collections.api.list.ListIterable.zip.

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

public MutableList<Pair<T, Integer>>
Inherited from java.util.List:
addaddaddAlladdAlladdFirstaddLastclearcontainscontainsAllcopyOfequalsgethashCodeisEmptyiteratorlastIndexOflistIteratorlistIteratorofofofofofofofofofofofofremoveremoveremoveAllremoveFirstremoveLastreplaceAllretainAllreversedsetsizesortspliterator
Inherited from org.eclipse.collections.api.collection.MutableCollection:
addAllIterableaggregateByaggregateInPlaceBycountBycountByEachcountByWithgroupByUniqueKeyinjectIntoWithremoveAllIterableremoveIfremoveIfWithretainAllIterableselectAndRejectWithsumByDoublesumByFloatsumByIntsumByLong
Inherited from org.eclipse.collections.api.list.ListIterable:
asParallelbinarySearchbinarySearchequalsforEachInBothgethashCodelastIndexOflistIteratorlistIterator