Class SynchronizedMutableList<T>
- java.lang.Object
-
- org.eclipse.collections.impl.collection.AbstractSynchronizedRichIterable<T>
-
- org.eclipse.collections.impl.collection.mutable.AbstractSynchronizedMutableCollection<T>
-
- org.eclipse.collections.impl.list.mutable.SynchronizedMutableList<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<T>,java.util.Collection<T>,java.util.List<T>,MutableCollection<T>,InternalIterable<T>,ListIterable<T>,MutableList<T>,OrderedIterable<T>,ReversibleIterable<T>,RichIterable<T>
public class SynchronizedMutableList<T> extends AbstractSynchronizedMutableCollection<T> implements MutableList<T>, java.io.Serializable
A synchronized view of aMutableList. It is imperative that the user manually synchronize on the collection when iterating over it using the standard JDK iterator or JDK 5 for loop, as perCollections.synchronizedCollection(Collection).- See Also:
MutableList.asSynchronized(), Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID-
Fields inherited from class org.eclipse.collections.impl.collection.AbstractSynchronizedRichIterable
delegate, lock
-
-
Constructor Summary
Constructors Constructor Description SynchronizedMutableList(MutableList<T> newCollection)SynchronizedMutableList(MutableList<T> newCollection, java.lang.Object newLock)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, T element)booleanaddAll(int index, java.util.Collection<? extends T> collection)ParallelListIterable<T>asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)Returns a parallel iterable of this ListIterable.LazyIterable<T>asReversed()Returns a reversed view of this ReversibleIterable.MutableList<T>asSynchronized()Returns a synchronized wrapper backed by this collection.MutableList<T>asUnmodifiable()Returns an unmodifiable view of the list.intbinarySearch(T key)Searches for the specified object using the binary search algorithm.intbinarySearch(T key, java.util.Comparator<? super T> comparator)Searches for the specified object using the binary search algorithm.MutableList<T>clone()<V> MutableList<V>collect(Function<? super T,? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.MutableBooleanListcollectBoolean(BooleanFunction<? super T> booleanFunction)Returns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection.MutableByteListcollectByte(ByteFunction<? super T> byteFunction)Returns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection.MutableCharListcollectChar(CharFunction<? super T> charFunction)Returns a new primitivechariterable with the results of applying the specified function on each element of the source collection.MutableDoubleListcollectDouble(DoubleFunction<? super T> doubleFunction)Returns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection.MutableFloatListcollectFloat(FloatFunction<? super T> floatFunction)Returns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection.<V> MutableList<V>collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)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.MutableIntListcollectInt(IntFunction<? super T> intFunction)Returns a new primitiveintiterable with the results of applying the specified function on each element of the source collection.MutableLongListcollectLong(LongFunction<? super T> longFunction)Returns a new primitivelongiterable with the results of applying the specified function on each element of the source collection.MutableShortListcollectShort(ShortFunction<? super T> shortFunction)Returns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection.<P,V>
MutableList<V>collectWith(Function2<? super T,? super P,? extends V> function, P parameter)Same asRichIterable.collect(Function)with aFunction2and specified parameter which is passed to the block.<V> MutableList<V>collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.<V,R extends java.util.Collection<V>>
RcollectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function, R target)Adds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.<S> booleancorresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)Returns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother.intdetectIndex(Predicate<? super T> predicate)Returns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true.intdetectLastIndex(Predicate<? super T> predicate)Returns the index of the last element of theReversibleIterablefor which thepredicateevaluates to true.MutableList<T>distinct()Returns a newListIterablecontaining the distinct elements in this list.MutableList<T>distinct(HashingStrategy<? super T> hashingStrategy)Returns a newListIterablecontaining the distinct elements in this list.<V> MutableList<T>distinctBy(Function<? super T,? extends V> function)Returns a newListIterablecontaining the distinct elements in this list.MutableList<T>drop(int count)Returns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.MutableList<T>dropWhile(Predicate<? super T> predicate)Returns the final elements that do not satisfy the Predicate.<V> MutableList<V>flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)flatCollectis a special case ofRichIterable.collect(Function).voidforEach(int fromIndex, int toIndex, Procedure<? super T> procedure)Iterates over the section of the iterable covered by the specified inclusive indexes.<T2> voidforEachInBoth(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.voidforEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the section of the iterable covered by the specified inclusive indexes.Tget(int index)Returns the item at the specified position in this list iterable.protected MutableList<T>getDelegate()java.util.Optional<T>getFirstOptional()Returns the first element of an iterable as an Optional.java.util.Optional<T>getLastOptional()Returns the last element of an iterable as an Optional.<V> MutableListMultimap<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> MutableListMultimap<V,T>groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function)Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.intindexOf(java.lang.Object o)Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.intlastIndexOf(java.lang.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.java.util.ListIterator<T>listIterator()java.util.ListIterator<T>listIterator(int index)MutableList<T>newEmpty()Creates a new empty mutable version of the same collection type.static <E,L extends java.util.List<E>>
SynchronizedMutableList<E>of(L list)This method will take a MutableList and wrap it directly in a SynchronizedMutableList.static <E,L extends java.util.List<E>>
SynchronizedMutableList<E>of(L list, java.lang.Object lock)This method will take a MutableList and wrap it directly in a SynchronizedMutableList.PartitionMutableList<T>partition(Predicate<? super T> predicate)Filters a collection into a PartitionedIterable based on the evaluation of the predicate.PartitionMutableList<T>partitionWhile(Predicate<? super T> predicate)Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.<P> PartitionMutableList<T>partitionWith(Predicate2<? super T,? super P> predicate, P parameter)Filters a collection into a PartitionIterable based on the evaluation of the predicate.MutableList<T>reject(Predicate<? super T> predicate)Returns all elements of the source collection that return false when evaluating of the predicate.<P> MutableList<T>rejectWith(Predicate2<? super T,? super P> predicate, P parameter)Similar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.MutableList<T>rejectWithIndex(ObjectIntPredicate<? super T> predicate)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.<R extends java.util.Collection<T>>
RrejectWithIndex(ObjectIntPredicate<? super T> predicate, R target)Adds all elements to the target Collection that return false when evaluating the specified predicate which is supplied each element and its relative index.Tremove(int index)voidreplaceAll(java.util.function.UnaryOperator<T> operator)voidreverseForEach(Procedure<? super T> procedure)Evaluates the procedure for each element of the list iterating in reverse order.voidreverseForEachWithIndex(ObjectIntProcedure<? super T> procedure)Evaluates the procedure for each element and it's index in reverse order.MutableList<T>reverseThis()Mutates this list by reversing its order and returns the current list as a result.MutableList<T>select(Predicate<? super T> predicate)Returns all elements of the source collection that return true when evaluating the predicate.<S> MutableList<S>selectInstancesOf(java.lang.Class<S> clazz)Returns all elements of the source collection that are instances of the Classclazz.<P> MutableList<T>selectWith(Predicate2<? super T,? super P> predicate, P parameter)Similar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.MutableList<T>selectWithIndex(ObjectIntPredicate<? super T> predicate)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.<R extends java.util.Collection<T>>
RselectWithIndex(ObjectIntPredicate<? super T> predicate, R target)Adds all elements to the target Collection that return true when evaluating the specified predicate which is supplied each element and its relative index.Tset(int index, T element)MutableList<T>shuffleThis()Mutates this list by shuffling its elements.MutableList<T>shuffleThis(java.util.Random rnd)Mutates this list by shuffling its elements using the specified random.voidsort(java.util.Comparator<? super T> comparator)MutableList<T>sortThis()Sorts the internal data structure of this list and returns the list itself as a convenience.MutableList<T>sortThis(java.util.Comparator<? super T> comparator)Sorts the internal data structure of this list and returns the list itself as a convenience.<V extends java.lang.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 byfunction.MutableList<T>sortThisByBoolean(BooleanFunction<? super T> function)MutableList<T>sortThisByByte(ByteFunction<? super T> function)MutableList<T>sortThisByChar(CharFunction<? super T> function)MutableList<T>sortThisByDouble(DoubleFunction<? super T> function)MutableList<T>sortThisByFloat(FloatFunction<? super T> function)MutableList<T>sortThisByInt(IntFunction<? super T> function)MutableList<T>sortThisByLong(LongFunction<? super T> function)MutableList<T>sortThisByShort(ShortFunction<? super T> function)MutableList<T>subList(int fromIndex, int toIndex)MutableList<T>take(int count)Returns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.MutableList<T>takeWhile(Predicate<? super T> predicate)Returns the initial elements that satisfy the Predicate.MutableList<T>tap(Procedure<? super T> procedure)Executes the Procedure for each element in the iterable and returnsthis.ImmutableList<T>toImmutable()Returns an immutable copy of this list.MutableList<T>toReversed()Returns a new MutableList in reverse order.MutableStack<T>toStack()Converts the OrderedIterable to a mutable MutableStack implementation.protected java.lang.ObjectwriteReplace()<S> MutableList<Pair<T,S>>zip(java.lang.Iterable<S> that)Returns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs.MutableList<Pair<T,java.lang.Integer>>zipWithIndex()Zips thisRichIterablewith its indices.-
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractSynchronizedMutableCollection
add, addAll, addAllIterable, aggregateBy, aggregateInPlaceBy, clear, countBy, countByEach, countByWith, groupByUniqueKey, injectIntoWith, remove, removeAll, removeAllIterable, removeIf, removeIfWith, retainAll, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.collection.AbstractSynchronizedRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, equals, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, forEachWith, forEachWithIndex, getFirst, getLast, getLock, getOnly, groupBy, groupByEach, groupByUniqueKey, hashCode, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, iterator, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduceBy, reject, rejectWith, select, selectWith, size, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableList, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toString, zip, zipWithIndex
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith
-
Methods inherited from interface java.util.List
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator
-
Methods inherited from interface org.eclipse.collections.api.list.ListIterable
equals, hashCode
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, groupByUniqueKey, injectIntoWith, removeAllIterable, removeIf, removeIfWith, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.list.MutableList
flatCollectWith, getFirst, getLast, toArray, toArray, toImmutableList, with, withAll, without, withoutAll
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
forEachWithIndex, max, min, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SynchronizedMutableList
SynchronizedMutableList(MutableList<T> newCollection)
-
SynchronizedMutableList
SynchronizedMutableList(MutableList<T> newCollection, java.lang.Object newLock)
-
-
Method Detail
-
of
public static <E,L extends java.util.List<E>> SynchronizedMutableList<E> of(L list)
This method will take a MutableList and wrap it directly in a SynchronizedMutableList. It will take any other non-Eclipse-Collections collection and first adapt it will a ListAdapter, and then return a SynchronizedMutableList that wraps the adapter.
-
of
public static <E,L extends java.util.List<E>> SynchronizedMutableList<E> of(L list, java.lang.Object lock)
This method will take a MutableList and wrap it directly in a SynchronizedMutableList. It will take any other non-Eclipse-Collections collection and first adapt it will a ListAdapter, and then return a SynchronizedMutableList that wraps the adapter. Additionally, a developer specifies which lock to use with the collection.
-
getDelegate
protected MutableList<T> getDelegate()
- Overrides:
getDelegatein classAbstractSynchronizedMutableCollection<T>
-
newEmpty
public MutableList<T> newEmpty()
Description copied from interface:MutableCollectionCreates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.- Specified by:
newEmptyin interfaceMutableCollection<T>- Specified by:
newEmptyin interfaceMutableList<T>
-
clone
public MutableList<T> clone()
- Specified by:
clonein interfaceMutableList<T>- Overrides:
clonein classjava.lang.Object
-
writeReplace
protected java.lang.Object writeReplace()
-
addAll
public boolean addAll(int index, java.util.Collection<? extends T> collection)- Specified by:
addAllin interfacejava.util.List<T>
-
subList
public MutableList<T> subList(int fromIndex, int toIndex)
- Specified by:
subListin interfacejava.util.List<T>- Specified by:
subListin interfaceListIterable<T>- Specified by:
subListin interfaceMutableList<T>- See Also:
List.subList(int, int)
-
get
public T get(int index)
Description copied from interface:ListIterableReturns the item at the specified position in this list iterable.- Specified by:
getin interfacejava.util.List<T>- Specified by:
getin interfaceListIterable<T>
-
replaceAll
public void replaceAll(java.util.function.UnaryOperator<T> operator)
- Specified by:
replaceAllin interfacejava.util.List<T>- Since:
- 10.0 - Overridden for correctness
-
sort
public void sort(java.util.Comparator<? super T> comparator)
- Specified by:
sortin interfacejava.util.List<T>- Since:
- 10.0 - Overridden for correctness
-
getFirstOptional
public java.util.Optional<T> getFirstOptional()
Description copied from interface:OrderedIterableReturns the first element of an iterable as an Optional. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty,Optional.empty()is returned.- Specified by:
getFirstOptionalin interfaceOrderedIterable<T>
-
getLastOptional
public java.util.Optional<T> getLastOptional()
Description copied from interface:OrderedIterableReturns the last element of an iterable as an Optional. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty,Optional.empty()is returned.- Specified by:
getLastOptionalin interfaceOrderedIterable<T>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
Description copied from interface:ListIterableReturns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.- Specified by:
lastIndexOfin interfacejava.util.List<T>- Specified by:
lastIndexOfin interfaceListIterable<T>
-
listIterator
public java.util.ListIterator<T> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<T>- Specified by:
listIteratorin interfaceListIterable<T>- See Also:
List.listIterator()
-
listIterator
public java.util.ListIterator<T> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<T>- Specified by:
listIteratorin interfaceListIterable<T>- See Also:
List.listIterator(int)
-
asParallel
public ParallelListIterable<T> asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)
Description copied from interface:ListIterableReturns a parallel iterable of this ListIterable.- Specified by:
asParallelin interfaceListIterable<T>
-
binarySearch
public int binarySearch(T key, java.util.Comparator<? super T> comparator)
Description copied from interface:ListIterableSearches for the specified object using the binary search algorithm. The list must be sorted into ascending order according to the specified comparator.- Specified by:
binarySearchin interfaceListIterable<T>- See Also:
Collections.binarySearch(List, Object, Comparator)
-
binarySearch
public int binarySearch(T key)
Description copied from interface:ListIterableSearches 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.- Specified by:
binarySearchin interfaceListIterable<T>- See Also:
Collections.binarySearch(List, Object)
-
indexOf
public int indexOf(java.lang.Object o)
Description copied from interface:OrderedIterableReturns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.- Specified by:
indexOfin interfacejava.util.List<T>- Specified by:
indexOfin interfaceMutableList<T>- Specified by:
indexOfin interfaceOrderedIterable<T>- See Also:
List.indexOf(Object)
-
distinct
public MutableList<T> distinct()
Description copied from interface:MutableListReturns a newListIterablecontaining the distinct elements in this list.- Specified by:
distinctin interfaceListIterable<T>- Specified by:
distinctin interfaceMutableList<T>- Specified by:
distinctin interfaceOrderedIterable<T>- Specified by:
distinctin interfaceReversibleIterable<T>- Returns:
ListIterableof distinct elements
-
distinct
public MutableList<T> distinct(HashingStrategy<? super T> hashingStrategy)
Description copied from interface:MutableListReturns a newListIterablecontaining the distinct elements in this list. Takes HashingStrategy.- Specified by:
distinctin interfaceListIterable<T>- Specified by:
distinctin interfaceMutableList<T>- Returns:
ListIterableof distinct elements
-
distinctBy
public <V> MutableList<T> distinctBy(Function<? super T,? extends V> function)
Description copied from interface:ListIterableReturns a newListIterablecontaining the distinct elements in this list. The specified function will be used to create a HashingStrategy to unique the elements.- Specified by:
distinctByin interfaceListIterable<T>- Specified by:
distinctByin interfaceMutableList<T>- Since:
- 9.0.
- See Also:
ListIterable.distinct(HashingStrategy)
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)
Description copied from interface:OrderedIterableReturns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother. Thepredicateis evaluated for each element at the same position of eachOrderedIterablein a forward iteration order. This is a short circuit pattern.- Specified by:
correspondsin interfaceOrderedIterable<T>
-
forEachInBoth
public <T2> void forEachInBoth(ListIterable<T2> other, Procedure2<? super T,? super T2> procedure)
Description copied from interface:ListIterableIterates over this ListIterable and the other ListIterable together passing the elements of each list as parameters to the specified procedure.- Specified by:
forEachInBothin interfaceListIterable<T>
-
forEach
public void forEach(int fromIndex, int toIndex, Procedure<? super T> procedure)Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<Person> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, person -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachin interfaceOrderedIterable<T>
-
takeWhile
public MutableList<T> takeWhile(Predicate<? super T> predicate)
Description copied from interface:ListIterableReturns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.- Specified by:
takeWhilein interfaceListIterable<T>- Specified by:
takeWhilein interfaceMutableList<T>- Specified by:
takeWhilein interfaceOrderedIterable<T>- Specified by:
takeWhilein interfaceReversibleIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEachWithIndex(0, 1, (person, index) -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>
-
dropWhile
public MutableList<T> dropWhile(Predicate<? super T> predicate)
Description copied from interface:ListIterableReturns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.- Specified by:
dropWhilein interfaceListIterable<T>- Specified by:
dropWhilein interfaceMutableList<T>- Specified by:
dropWhilein interfaceOrderedIterable<T>- Specified by:
dropWhilein interfaceReversibleIterable<T>
-
partitionWhile
public PartitionMutableList<T> partitionWhile(Predicate<? super T> predicate)
Description copied from interface:ListIterableReturns 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.- Specified by:
partitionWhilein interfaceListIterable<T>- Specified by:
partitionWhilein interfaceMutableList<T>- Specified by:
partitionWhilein interfaceOrderedIterable<T>- Specified by:
partitionWhilein interfaceReversibleIterable<T>
-
detectIndex
public int detectIndex(Predicate<? super T> predicate)
Description copied from interface:OrderedIterableReturns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true. Returns -1 if no element evaluates true for thepredicate.- Specified by:
detectIndexin interfaceOrderedIterable<T>
-
detectLastIndex
public int detectLastIndex(Predicate<? super T> predicate)
Description copied from interface:ReversibleIterableReturns the index of the last element of theReversibleIterablefor which thepredicateevaluates to true. Returns -1 if no element evaluates true for thepredicate.- Specified by:
detectLastIndexin interfaceReversibleIterable<T>
-
take
public MutableList<T> take(int count)
Description copied from interface:ReversibleIterableReturns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.- Specified by:
takein interfaceListIterable<T>- Specified by:
takein interfaceMutableList<T>- Specified by:
takein interfaceReversibleIterable<T>- Parameters:
count- the number of items to take.
-
drop
public MutableList<T> drop(int count)
Description copied from interface:ReversibleIterableReturns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.- Specified by:
dropin interfaceListIterable<T>- Specified by:
dropin interfaceMutableList<T>- Specified by:
dropin interfaceReversibleIterable<T>- Parameters:
count- the number of items to drop.
-
reverseForEach
public void reverseForEach(Procedure<? super T> procedure)
Description copied from interface:ReversibleIterableEvaluates the procedure for each element of the list iterating in reverse order.e.g. people.reverseForEach(person -> LOGGER.info(person.getName()));
- Specified by:
reverseForEachin interfaceReversibleIterable<T>
-
reverseForEachWithIndex
public void reverseForEachWithIndex(ObjectIntProcedure<? super T> procedure)
Description copied from interface:ReversibleIterableEvaluates the procedure for each element and it's index in reverse order.e.g. people.reverseForEachWithIndex((person, index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));- Specified by:
reverseForEachWithIndexin interfaceReversibleIterable<T>
-
sortThis
public MutableList<T> sortThis(java.util.Comparator<? super T> comparator)
Description copied from interface:MutableListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceMutableList<T>
-
sortThis
public MutableList<T> sortThis()
Description copied from interface:MutableListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceMutableList<T>
-
sortThisBy
public <V extends java.lang.Comparable<? super V>> MutableList<T> sortThisBy(Function<? super T,? extends V> function)
Description copied from interface:MutableListSorts the internal data structure of this list based on the natural order of the attribute returned byfunction.- Specified by:
sortThisByin interfaceMutableList<T>
-
sortThisByInt
public MutableList<T> sortThisByInt(IntFunction<? super T> function)
- Specified by:
sortThisByIntin interfaceMutableList<T>
-
sortThisByBoolean
public MutableList<T> sortThisByBoolean(BooleanFunction<? super T> function)
- Specified by:
sortThisByBooleanin interfaceMutableList<T>
-
sortThisByChar
public MutableList<T> sortThisByChar(CharFunction<? super T> function)
- Specified by:
sortThisByCharin interfaceMutableList<T>
-
sortThisByByte
public MutableList<T> sortThisByByte(ByteFunction<? super T> function)
- Specified by:
sortThisByBytein interfaceMutableList<T>
-
sortThisByShort
public MutableList<T> sortThisByShort(ShortFunction<? super T> function)
- Specified by:
sortThisByShortin interfaceMutableList<T>
-
sortThisByFloat
public MutableList<T> sortThisByFloat(FloatFunction<? super T> function)
- Specified by:
sortThisByFloatin interfaceMutableList<T>
-
sortThisByLong
public MutableList<T> sortThisByLong(LongFunction<? super T> function)
- Specified by:
sortThisByLongin interfaceMutableList<T>
-
sortThisByDouble
public MutableList<T> sortThisByDouble(DoubleFunction<? super T> function)
- Specified by:
sortThisByDoublein interfaceMutableList<T>
-
reverseThis
public MutableList<T> reverseThis()
Description copied from interface:MutableListMutates this list by reversing its order and returns the current list as a result.- Specified by:
reverseThisin interfaceMutableList<T>
-
shuffleThis
public MutableList<T> shuffleThis()
Description copied from interface:MutableListMutates this list by shuffling its elements.- Specified by:
shuffleThisin interfaceMutableList<T>
-
shuffleThis
public MutableList<T> shuffleThis(java.util.Random rnd)
Description copied from interface:MutableListMutates this list by shuffling its elements using the specified random.- Specified by:
shuffleThisin interfaceMutableList<T>
-
asReversed
public LazyIterable<T> asReversed()
Description copied from interface:ReversibleIterableReturns a reversed view of this ReversibleIterable.- Specified by:
asReversedin interfaceReversibleIterable<T>
-
toReversed
public MutableList<T> toReversed()
Description copied from interface:MutableListReturns a new MutableList in reverse order.- Specified by:
toReversedin interfaceListIterable<T>- Specified by:
toReversedin interfaceMutableList<T>- Specified by:
toReversedin interfaceReversibleIterable<T>
-
toStack
public MutableStack<T> toStack()
Description copied from interface:OrderedIterableConverts the OrderedIterable to a mutable MutableStack implementation.- Specified by:
toStackin interfaceOrderedIterable<T>
-
toImmutable
public ImmutableList<T> toImmutable()
Description copied from interface:MutableListReturns an immutable copy of this list. If the list is immutable, it returns itself.- Specified by:
toImmutablein interfaceListIterable<T>- Specified by:
toImmutablein interfaceMutableCollection<T>- Specified by:
toImmutablein interfaceMutableList<T>
-
tap
public MutableList<T> tap(Procedure<? super T> procedure)
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceListIterable<T>- Specified by:
tapin interfaceMutableCollection<T>- Specified by:
tapin interfaceMutableList<T>- Specified by:
tapin interfaceOrderedIterable<T>- Specified by:
tapin interfaceReversibleIterable<T>- Specified by:
tapin interfaceRichIterable<T>- Overrides:
tapin classAbstractSynchronizedMutableCollection<T>- See Also:
RichIterable.each(Procedure),RichIterable.forEach(Procedure)
-
select
public MutableList<T> select(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns 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"));- Specified by:
selectin interfaceListIterable<T>- Specified by:
selectin interfaceMutableCollection<T>- Specified by:
selectin interfaceMutableList<T>- Specified by:
selectin interfaceOrderedIterable<T>- Specified by:
selectin interfaceReversibleIterable<T>- Specified by:
selectin interfaceRichIterable<T>- Overrides:
selectin classAbstractSynchronizedMutableCollection<T>
-
selectWith
public <P> MutableList<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));- Specified by:
selectWithin interfaceListIterable<T>- Specified by:
selectWithin interfaceMutableCollection<T>- Specified by:
selectWithin interfaceMutableList<T>- Specified by:
selectWithin interfaceOrderedIterable<T>- Specified by:
selectWithin interfaceReversibleIterable<T>- Specified by:
selectWithin interfaceRichIterable<T>- Overrides:
selectWithin classAbstractSynchronizedMutableCollection<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
RichIterable.select(Predicate)
-
reject
public MutableList<T> reject(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns 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"));- Specified by:
rejectin interfaceListIterable<T>- Specified by:
rejectin interfaceMutableCollection<T>- Specified by:
rejectin interfaceMutableList<T>- Specified by:
rejectin interfaceOrderedIterable<T>- Specified by:
rejectin interfaceReversibleIterable<T>- Specified by:
rejectin interfaceRichIterable<T>- Overrides:
rejectin classAbstractSynchronizedMutableCollection<T>- Parameters:
predicate- aPredicateto use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)method to evaluate to false
-
rejectWith
public <P> MutableList<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));- Specified by:
rejectWithin interfaceListIterable<T>- Specified by:
rejectWithin interfaceMutableCollection<T>- Specified by:
rejectWithin interfaceMutableList<T>- Specified by:
rejectWithin interfaceOrderedIterable<T>- Specified by:
rejectWithin interfaceReversibleIterable<T>- Specified by:
rejectWithin interfaceRichIterable<T>- Overrides:
rejectWithin classAbstractSynchronizedMutableCollection<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
RichIterable.select(Predicate)
-
partition
public PartitionMutableList<T> partition(Predicate<? super T> predicate)
Description copied from interface:RichIterableFilters 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"));- Specified by:
partitionin interfaceListIterable<T>- Specified by:
partitionin interfaceMutableCollection<T>- Specified by:
partitionin interfaceMutableList<T>- Specified by:
partitionin interfaceOrderedIterable<T>- Specified by:
partitionin interfaceReversibleIterable<T>- Specified by:
partitionin interfaceRichIterable<T>- Overrides:
partitionin classAbstractSynchronizedMutableCollection<T>
-
partitionWith
public <P> PartitionMutableList<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableFilters 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");- Specified by:
partitionWithin interfaceListIterable<T>- Specified by:
partitionWithin interfaceMutableCollection<T>- Specified by:
partitionWithin interfaceMutableList<T>- Specified by:
partitionWithin interfaceOrderedIterable<T>- Specified by:
partitionWithin interfaceReversibleIterable<T>- Specified by:
partitionWithin interfaceRichIterable<T>- Overrides:
partitionWithin classAbstractSynchronizedMutableCollection<T>
-
selectInstancesOf
public <S> MutableList<S> selectInstancesOf(java.lang.Class<S> clazz)
Description copied from interface:RichIterableReturns all elements of the source collection that are instances of the Classclazz.RichIterable<Integer> integers = List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);- Specified by:
selectInstancesOfin interfaceListIterable<T>- Specified by:
selectInstancesOfin interfaceMutableCollection<T>- Specified by:
selectInstancesOfin interfaceMutableList<T>- Specified by:
selectInstancesOfin interfaceOrderedIterable<T>- Specified by:
selectInstancesOfin interfaceReversibleIterable<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>- Overrides:
selectInstancesOfin classAbstractSynchronizedMutableCollection<T>
-
collectBoolean
public MutableBooleanList collectBoolean(BooleanFunction<? super T> booleanFunction)
Description copied from interface:RichIterableReturns a new primitivebooleaniterable 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());- Specified by:
collectBooleanin interfaceListIterable<T>- Specified by:
collectBooleanin interfaceMutableCollection<T>- Specified by:
collectBooleanin interfaceMutableList<T>- Specified by:
collectBooleanin interfaceOrderedIterable<T>- Specified by:
collectBooleanin interfaceReversibleIterable<T>- Specified by:
collectBooleanin interfaceRichIterable<T>- Overrides:
collectBooleanin classAbstractSynchronizedMutableCollection<T>
-
collectByte
public MutableByteList collectByte(ByteFunction<? super T> byteFunction)
Description copied from interface:RichIterableReturns a new primitivebyteiterable 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());- Specified by:
collectBytein interfaceListIterable<T>- Specified by:
collectBytein interfaceMutableCollection<T>- Specified by:
collectBytein interfaceMutableList<T>- Specified by:
collectBytein interfaceOrderedIterable<T>- Specified by:
collectBytein interfaceReversibleIterable<T>- Specified by:
collectBytein interfaceRichIterable<T>- Overrides:
collectBytein classAbstractSynchronizedMutableCollection<T>
-
collectChar
public MutableCharList collectChar(CharFunction<? super T> charFunction)
Description copied from interface:RichIterableReturns a new primitivechariterable 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());- Specified by:
collectCharin interfaceListIterable<T>- Specified by:
collectCharin interfaceMutableCollection<T>- Specified by:
collectCharin interfaceMutableList<T>- Specified by:
collectCharin interfaceOrderedIterable<T>- Specified by:
collectCharin interfaceReversibleIterable<T>- Specified by:
collectCharin interfaceRichIterable<T>- Overrides:
collectCharin classAbstractSynchronizedMutableCollection<T>
-
collectDouble
public MutableDoubleList collectDouble(DoubleFunction<? super T> doubleFunction)
Description copied from interface:RichIterableReturns a new primitivedoubleiterable 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());- Specified by:
collectDoublein interfaceListIterable<T>- Specified by:
collectDoublein interfaceMutableCollection<T>- Specified by:
collectDoublein interfaceMutableList<T>- Specified by:
collectDoublein interfaceOrderedIterable<T>- Specified by:
collectDoublein interfaceReversibleIterable<T>- Specified by:
collectDoublein interfaceRichIterable<T>- Overrides:
collectDoublein classAbstractSynchronizedMutableCollection<T>
-
collectFloat
public MutableFloatList collectFloat(FloatFunction<? super T> floatFunction)
Description copied from interface:RichIterableReturns a new primitivefloatiterable 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());- Specified by:
collectFloatin interfaceListIterable<T>- Specified by:
collectFloatin interfaceMutableCollection<T>- Specified by:
collectFloatin interfaceMutableList<T>- Specified by:
collectFloatin interfaceOrderedIterable<T>- Specified by:
collectFloatin interfaceReversibleIterable<T>- Specified by:
collectFloatin interfaceRichIterable<T>- Overrides:
collectFloatin classAbstractSynchronizedMutableCollection<T>
-
collectInt
public MutableIntList collectInt(IntFunction<? super T> intFunction)
Description copied from interface:RichIterableReturns a new primitiveintiterable 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());- Specified by:
collectIntin interfaceListIterable<T>- Specified by:
collectIntin interfaceMutableCollection<T>- Specified by:
collectIntin interfaceMutableList<T>- Specified by:
collectIntin interfaceOrderedIterable<T>- Specified by:
collectIntin interfaceReversibleIterable<T>- Specified by:
collectIntin interfaceRichIterable<T>- Overrides:
collectIntin classAbstractSynchronizedMutableCollection<T>
-
collectLong
public MutableLongList collectLong(LongFunction<? super T> longFunction)
Description copied from interface:RichIterableReturns a new primitivelongiterable 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());- Specified by:
collectLongin interfaceListIterable<T>- Specified by:
collectLongin interfaceMutableCollection<T>- Specified by:
collectLongin interfaceMutableList<T>- Specified by:
collectLongin interfaceOrderedIterable<T>- Specified by:
collectLongin interfaceReversibleIterable<T>- Specified by:
collectLongin interfaceRichIterable<T>- Overrides:
collectLongin classAbstractSynchronizedMutableCollection<T>
-
collectShort
public MutableShortList collectShort(ShortFunction<? super T> shortFunction)
Description copied from interface:RichIterableReturns a new primitiveshortiterable 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());- Specified by:
collectShortin interfaceListIterable<T>- Specified by:
collectShortin interfaceMutableCollection<T>- Specified by:
collectShortin interfaceMutableList<T>- Specified by:
collectShortin interfaceOrderedIterable<T>- Specified by:
collectShortin interfaceReversibleIterable<T>- Specified by:
collectShortin interfaceRichIterable<T>- Overrides:
collectShortin classAbstractSynchronizedMutableCollection<T>
-
collect
public <V> MutableList<V> collect(Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns 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());- Specified by:
collectin interfaceListIterable<T>- Specified by:
collectin interfaceMutableCollection<T>- Specified by:
collectin interfaceMutableList<T>- Specified by:
collectin interfaceOrderedIterable<T>- Specified by:
collectin interfaceReversibleIterable<T>- Specified by:
collectin interfaceRichIterable<T>- Overrides:
collectin classAbstractSynchronizedMutableCollection<T>
-
collectWithIndex
public <V> MutableList<V> collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)
Description copied from interface:OrderedIterableReturns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndexin interfaceListIterable<T>- Specified by:
collectWithIndexin interfaceMutableList<T>- Specified by:
collectWithIndexin interfaceOrderedIterable<T>- Specified by:
collectWithIndexin interfaceReversibleIterable<T>- Since:
- 9.1.
-
collectWithIndex
public <V,R extends java.util.Collection<V>> R collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function, R target)
Description copied from interface:OrderedIterableAdds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndexin interfaceOrderedIterable<T>- Since:
- 9.1.
-
selectWithIndex
public MutableList<T> selectWithIndex(ObjectIntPredicate<? super T> predicate)
Description copied from interface:MutableListReturns 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.- Specified by:
selectWithIndexin interfaceListIterable<T>- Specified by:
selectWithIndexin interfaceMutableList<T>- Since:
- 11.0.
-
rejectWithIndex
public MutableList<T> rejectWithIndex(ObjectIntPredicate<? super T> predicate)
Description copied from interface:MutableListReturns 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.- Specified by:
rejectWithIndexin interfaceListIterable<T>- Specified by:
rejectWithIndexin interfaceMutableList<T>- Since:
- 11.0.
-
selectWithIndex
public <R extends java.util.Collection<T>> R selectWithIndex(ObjectIntPredicate<? super T> predicate, R target)
Description copied from interface:OrderedIterableAdds all elements to the target Collection that return true when evaluating the specified predicate which is supplied each element and its relative index.- Specified by:
selectWithIndexin interfaceOrderedIterable<T>- Since:
- 11.0.
-
rejectWithIndex
public <R extends java.util.Collection<T>> R rejectWithIndex(ObjectIntPredicate<? super T> predicate, R target)
Description copied from interface:OrderedIterableAdds all elements to the target Collection that return false when evaluating the specified predicate which is supplied each element and its relative index.- Specified by:
rejectWithIndexin interfaceOrderedIterable<T>- Since:
- 11.0.
-
collectWith
public <P,V> MutableList<V> collectWith(Function2<? super T,? super P,? extends V> function, P parameter)
Description copied from interface:RichIterableSame asRichIterable.collect(Function)with aFunction2and 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));- Specified by:
collectWithin interfaceListIterable<T>- Specified by:
collectWithin interfaceMutableCollection<T>- Specified by:
collectWithin interfaceMutableList<T>- Specified by:
collectWithin interfaceOrderedIterable<T>- Specified by:
collectWithin interfaceReversibleIterable<T>- Specified by:
collectWithin interfaceRichIterable<T>- Overrides:
collectWithin classAbstractSynchronizedMutableCollection<T>- Parameters:
function- AFunction2to use as the collect transformation functionparameter- A parameter to pass in for evaluation of the second argumentPinfunction- Returns:
- A new
RichIterablethat contains the transformed elements returned byFunction2.value(Object, Object) - See Also:
RichIterable.collect(Function)
-
collectIf
public <V> MutableList<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns 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());
- Specified by:
collectIfin interfaceListIterable<T>- Specified by:
collectIfin interfaceMutableCollection<T>- Specified by:
collectIfin interfaceMutableList<T>- Specified by:
collectIfin interfaceOrderedIterable<T>- Specified by:
collectIfin interfaceReversibleIterable<T>- Specified by:
collectIfin interfaceRichIterable<T>- Overrides:
collectIfin classAbstractSynchronizedMutableCollection<T>
-
flatCollect
public <V> MutableList<V> flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)
Description copied from interface:RichIterableflatCollectis a special case ofRichIterable.collect(Function). Withcollect, when theFunctionreturns a collection, the result is a collection of collections.flatCollectoutputs a single "flattened" collection instead. This method is commonly called flatMap.Consider the following example where we have a
Personclass, and eachPersonhas a list ofAddressobjects. Take the followingFunction:Function<Person, List<Address>> addressFunction = Person::getAddresses; RichIterable<Person> people = ...;
Usingcollectreturns a collection of collections of addresses.RichIterable<List<Address>> addresses = people.collect(addressFunction);
UsingflatCollectreturns a single flattened list of addresses.RichIterable<Address> addresses = people.flatCollect(addressFunction);
- Specified by:
flatCollectin interfaceListIterable<T>- Specified by:
flatCollectin interfaceMutableCollection<T>- Specified by:
flatCollectin interfaceMutableList<T>- Specified by:
flatCollectin interfaceOrderedIterable<T>- Specified by:
flatCollectin interfaceReversibleIterable<T>- Specified by:
flatCollectin interfaceRichIterable<T>- Overrides:
flatCollectin classAbstractSynchronizedMutableCollection<T>- Parameters:
function- TheFunctionto apply- Returns:
- a new flattened collection produced by applying the given
function
-
groupBy
public <V> MutableListMultimap<V,T> groupBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableFor 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);- Specified by:
groupByin interfaceListIterable<T>- Specified by:
groupByin interfaceMutableCollection<T>- Specified by:
groupByin interfaceMutableList<T>- Specified by:
groupByin interfaceOrderedIterable<T>- Specified by:
groupByin interfaceReversibleIterable<T>- Specified by:
groupByin interfaceRichIterable<T>- Overrides:
groupByin classAbstractSynchronizedMutableCollection<T>
-
groupByEach
public <V> MutableListMultimap<V,T> groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function)
Description copied from interface:RichIterableSimilar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.- Specified by:
groupByEachin interfaceListIterable<T>- Specified by:
groupByEachin interfaceMutableCollection<T>- Specified by:
groupByEachin interfaceMutableList<T>- Specified by:
groupByEachin interfaceOrderedIterable<T>- Specified by:
groupByEachin interfaceReversibleIterable<T>- Specified by:
groupByEachin interfaceRichIterable<T>- Overrides:
groupByEachin classAbstractSynchronizedMutableCollection<T>
-
zip
public <S> MutableList<Pair<T,S>> zip(java.lang.Iterable<S> that)
Description copied from interface:RichIterableReturns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs. If one of the twoRichIterables is longer than the other, its remaining elements are ignored.- Specified by:
zipin interfaceListIterable<T>- Specified by:
zipin interfaceMutableCollection<T>- Specified by:
zipin interfaceMutableList<T>- Specified by:
zipin interfaceOrderedIterable<T>- Specified by:
zipin interfaceReversibleIterable<T>- Specified by:
zipin interfaceRichIterable<T>- Overrides:
zipin classAbstractSynchronizedMutableCollection<T>- Type Parameters:
S- the type of the second half of the returned pairs- Parameters:
that- TheRichIterableproviding the second half of each result pair- Returns:
- A new
RichIterablecontaining pairs consisting of corresponding elements of thisRichIterableand that. The length of the returnedRichIterableis the minimum of the lengths of thisRichIterableand that.
-
zipWithIndex
public MutableList<Pair<T,java.lang.Integer>> zipWithIndex()
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceListIterable<T>- Specified by:
zipWithIndexin interfaceMutableCollection<T>- Specified by:
zipWithIndexin interfaceMutableList<T>- Specified by:
zipWithIndexin interfaceOrderedIterable<T>- Specified by:
zipWithIndexin interfaceReversibleIterable<T>- Specified by:
zipWithIndexin interfaceRichIterable<T>- Overrides:
zipWithIndexin classAbstractSynchronizedMutableCollection<T>- Returns:
- A new
RichIterablecontaining pairs consisting of all elements of thisRichIterablepaired with their index. Indices start at 0. - See Also:
RichIterable.zip(Iterable)
-
asUnmodifiable
public MutableList<T> asUnmodifiable()
Description copied from interface:MutableListReturns an unmodifiable view of the list.- Specified by:
asUnmodifiablein interfaceMutableCollection<T>- Specified by:
asUnmodifiablein interfaceMutableList<T>- Returns:
- an unmodifiable view of this list
- See Also:
Collections.unmodifiableCollection(Collection)
-
asSynchronized
public MutableList<T> asSynchronized()
Description copied from interface:MutableCollectionReturns a synchronized wrapper backed by this collection. This is the equivalent of usingCollections.synchronizedCollection(this)only with a return type that supports the full iteration protocols available onMutableCollection. The preferred way of iterating over a synchronized collection is to use the internal iteration methods which are properly synchronized internally.MutableCollection synchedCollection = collection.asSynchronized(); ... synchedCollection.forEach(each -> ... ); synchedCollection.select(each -> ... ); synchedCollection.collect(each -> ... );If you want to iterate using an imperative style, you must protect external iterators using a synchronized block. This includes explicit iterators as well as JDK 5 style for loops.- Specified by:
asSynchronizedin interfaceMutableCollection<T>- Specified by:
asSynchronizedin interfaceMutableList<T>- Returns:
- a synchronized view of this collection.
- See Also:
Collections.synchronizedCollection(Collection)
-
-