Class AbstractArrayAdapter<T>
- All Implemented Interfaces:
Cloneable,Iterable<T>,Collection<T>,List<T>,RandomAccess,MutableCollection<T>,InternalIterable<T>,ListIterable<T>,MutableList<T>,OrderedIterable<T>,ReversibleIterable<T>,RichIterable<T>
- Direct Known Subclasses:
ArrayAdapter
public abstract class AbstractArrayAdapter<T> extends AbstractMutableList<T> implements RandomAccess
-
Method Summary
Modifier and Type Method Description booleanabstractArrayAdapterEquals(AbstractArrayAdapter<?> list)voidadd(int index, T element)booleanaddAll(int index, Collection<? extends T> collection)booleanaddAll(Collection<? extends T> collection)booleanaddAllIterable(Iterable<? extends T> iterable)booleanallSatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.<P> booleanallSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)Returns true if the predicate evaluates to true for every element of the collection, or returns false.booleananySatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to true for any element of the iterable.<P> booleananySatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)Returns true if the predicate evaluates to true for any element of the collection, or return false.voidappendString(Appendable appendable, String start, String separator, String end)Prints a string representation of this collection onto the givenAppendable.voidclear()<V> MutableList<V>collect(Function<? super T,? extends V> function)Returns a new MutableCollection with the results of applying the specified function to each element of the source collection.<V, R extends Collection<V>>
Rcollect(Function<? super T,? extends V> function, R target)Same asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.<V, R extends Collection<V>>
RcollectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function, R target)Same as the collectIf method with two parameters but uses the specified target collection for the results.<P, A> MutableList<A>collectWith(Function2<? super T,? super P,? extends A> function, P parameter)Same asRichIterable.collect(Function)with aFunction2and specified parameter which is passed to the block.<P, A, R extends Collection<A>>
RcollectWith(Function2<? super T,? super P,? extends A> function, P parameter, R target)Same as collectWith but with a targetCollection parameter to gather the results.booleancontains(Object o)Returns true if the iterable has an element which responds true to element.equals(object).booleancontainsAll(Collection<?> collection)Returns true if all elements in source are contained in this collection.<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.intcount(Predicate<? super T> predicate)Return the total number of elements that answer true to the specified predicate.<P> intcountWith(Predicate2<? super T,? super P> predicate, P parameter)Returns the total number of elements that evaluate to true for the specified predicate.Tdetect(Predicate<? super T> predicate)Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.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.Optional<T>detectOptional(Predicate<? super T> predicate)Returns the first element of the iterable for which the predicate evaluates to true as an Optional.<P> TdetectWith(Predicate2<? super T,? super P> predicate, P parameter)Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.<P> Optional<T>detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)Returns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.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.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.voideach(Procedure<? super T> procedure)The procedure is executed for each element in the iterable.booleanequals(Object that)Follows the same general contract asList.equals(Object).<V> MutableList<V>flatCollect(Function<? super T,? extends Iterable<V>> function)flatCollectis a special case ofRichIterable.collect(Function).<V, R extends Collection<V>>
RflatCollect(Function<? super T,? extends Iterable<V>> function, R target)Same as flatCollect, only the results are collected into the target collection.voidforEach(int fromIndex, int toIndex, Procedure<? super T> procedure)Iterates over the section of the iterable covered by the specified inclusive indexes.<P> voidforEachWith(Procedure2<? super T,? super P> procedure, P parameter)The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.voidforEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the section of the iterable covered by the specified inclusive indexes.voidforEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Tget(int index)Returns the item at the specified position in this list iterable.TgetFirst()Returns the first element of an iterable.TgetLast()Returns the last element of an iterable.inthashCode()Follows the same general contract asList.hashCode().intindexOf(Object item)Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.<IV> IVinjectInto(IV injectedValue, Function2<? super IV,? super T,? extends IV> function)Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.<IV, P> IVinjectIntoWith(IV injectValue, Function3<? super IV,? super T,? super P,? extends IV> function, P parameter)Returns the final result of evaluating function using each element of the iterable, the previous evaluation result and the parameters.booleanisEmpty()Returns true if this iterable has zero items.Iterator<T>iterator()intlastIndexOf(Object item)Returns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.ListIterator<T>listIterator(int index)booleannoneSatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.<P> booleannoneSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)Returns true if the predicate evaluates to false for every element of the collection, or return false.booleannotEmpty()The English equivalent of !this.isEmpty()<R extends Collection<T>>
Rreject(Predicate<? super T> predicate, R target)Same as the reject method with one parameter but uses the specified target collection for the results.<P, R extends Collection<T>>
RrejectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)Similar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.Tremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> collection)booleanremoveAllIterable(Iterable<?> iterable)booleanremoveIf(Predicate<? super T> predicate)Removes all elements in the collection that evaluate to true for the specified predicate.<P> booleanremoveIfWith(Predicate2<? super T,? super P> predicate, P parameter)Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.voidreplaceAll(UnaryOperator<T> operator)booleanretainAll(Collection<?> collection)booleanretainAllIterable(Iterable<?> iterable)<R extends Collection<T>>
Rselect(Predicate<? super T> predicate, R target)Same as the select method with one parameter but uses the specified target collection for the results.<P> Twin<MutableList<T>>selectAndRejectWith(Predicate2<? super T,? super P> predicate, P parameter)Filters a collection into two separate collections based on a predicate returned via a Pair.<P, R extends Collection<T>>
RselectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)Similar toRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.intsize()Returns the number of items in this iterable.voidsort(Comparator<? super T> comparator)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.Object[]toArray()Converts this iterable to an array.<E> E[]toArray(E[] array)Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.Methods inherited from class org.eclipse.collections.impl.list.mutable.AbstractMutableList
appendString, asParallel, asReversed, asSynchronized, asUnmodifiable, binarySearch, chunk, clone, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, distinctBy, dropWhile, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, listIterator, max, max, maxBy, min, min, minBy, newEmpty, partition, partitionWhile, partitionWith, selectInstancesOf, sortThisBy, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, takeWhile, tap, toSet, toSortedList, toStack, zip, zip, zipWithIndex, zipWithIndexMethods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection
add, aggregateInPlaceBy, countBy, countByEach, countByWith, reduce, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from class org.eclipse.collections.impl.AbstractRichIterable
asLazy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, detectWithIfNone, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, into, toBag, toBiMap, toList, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toStringMethods inherited from interface org.eclipse.collections.api.list.ListIterable
binarySearch, forEachInBothMethods inherited from interface org.eclipse.collections.api.collection.MutableCollection
aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from interface org.eclipse.collections.api.list.MutableList
collectIf, collectWithIndex, flatCollectWith, reject, rejectWith, reverseThis, select, selectWith, shuffleThis, shuffleThis, sortThis, sortThis, toImmutable, toReversed, with, withAll, without, withoutAllMethods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, getFirstOptional, getLastOptionalMethods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
reverseForEach, reverseForEachWithIndexMethods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, appendString, asLazy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, containsBy, countBy, countByEach, countByWith, detectIfNone, detectWithIfNone, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, into, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, reduce, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toBag, toBiMap, toList, toMap, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
Method Details
-
notEmpty
public boolean notEmpty()Description copied from interface:RichIterableThe English equivalent of !this.isEmpty()- Specified by:
notEmptyin interfaceRichIterable<T>
-
getFirst
Description copied from interface:RichIterableReturns the first element of an iterable. 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, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
- Specified by:
getFirstin interfaceListIterable<T>- Specified by:
getFirstin interfaceOrderedIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>- Overrides:
getFirstin classAbstractMutableList<T>
-
getLast
Description copied from interface:RichIterableReturns the last element of an iterable. 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, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
- Specified by:
getLastin interfaceListIterable<T>- Specified by:
getLastin interfaceOrderedIterable<T>- Specified by:
getLastin interfaceRichIterable<T>- Overrides:
getLastin classAbstractMutableList<T>
-
each
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });This method is a variant ofInternalIterable.forEach(Procedure)that has a signature conflict withIterable.forEach(java.util.function.Consumer).- Specified by:
eachin interfaceRichIterable<T>- Overrides:
eachin classAbstractMutableList<T>- See Also:
InternalIterable.forEach(Procedure),Iterable.forEach(java.util.function.Consumer)
-
forEachWithIndex
Description copied from interface:InternalIterableIterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<T>- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>- Overrides:
forEachWithIndexin classAbstractMutableList<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, new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info(person.getName()); } });This code would output ted and mary's names.
- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>- Overrides:
forEachWithIndexin classAbstractMutableList<T>
-
removeIf
Description copied from interface:MutableCollectionRemoves all elements in the collection that evaluate to true for the specified predicate.e.g. return lastNames.removeIf(Predicates.isNull());
- Specified by:
removeIfin interfaceMutableCollection<T>- Overrides:
removeIfin classAbstractMutableList<T>
-
removeIfWith
Description copied from interface:MutableCollectionRemoves all elements in the collection that evaluate to true for the specified predicate2 and parameter.return lastNames.removeIfWith(Predicates2.isNull(), null);
- Specified by:
removeIfWithin interfaceMutableCollection<T>- Overrides:
removeIfWithin classAbstractMutableList<T>
-
detect
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));Example using an anonymous inner class:
Person person = people.detect(new Predicate<Person>() { public boolean accept(Person person) { return person.getFirstName().equals("John") && person.getLastName().equals("Smith"); } });- Specified by:
detectin interfaceRichIterable<T>- Overrides:
detectin classAbstractMutableList<T>
-
detectWith
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.Example using a Java 8 lambda expression:
Person person = people.detectWith((person, fullName) -> person.getFullName().equals(fullName), "John Smith");Example using an anonymous inner class:
Person person = people.detectWith(new Predicate2<Person, String>() { public boolean accept(Person person, String fullName) { return person.getFullName().equals(fullName); } }, "John Smith");- Specified by:
detectWithin interfaceRichIterable<T>- Overrides:
detectWithin classAbstractMutableList<T>
-
detectOptional
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true as an Optional. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));- Specified by:
detectOptionalin interfaceRichIterable<T>- Overrides:
detectOptionalin classAbstractMutableList<T>
-
detectWithOptional
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.Example using a Java 8 lambda expression:
Optional<Person> person = people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");- Specified by:
detectWithOptionalin interfaceRichIterable<T>- Overrides:
detectWithOptionalin classAbstractMutableList<T>
-
detectIndex
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>- Overrides:
detectIndexin classAbstractMutableList<T>
-
detectLastIndex
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>- Overrides:
detectLastIndexin classAbstractMutableList<T>
-
count
Description copied from interface:RichIterableReturn the total number of elements that answer true to the specified predicate.Example using a Java 8 lambda expression:
int count = people.count(person -> person.getAddress().getState().getName().equals("New York"));Example using an anonymous inner class:
int count = people.count(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });- Specified by:
countin interfaceRichIterable<T>- Overrides:
countin classAbstractMutableList<T>
-
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>- Overrides:
correspondsin classAbstractMutableList<T>
-
anySatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.- Specified by:
anySatisfyin interfaceRichIterable<T>- Overrides:
anySatisfyin classAbstractMutableList<T>
-
allSatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfyin interfaceRichIterable<T>- Overrides:
allSatisfyin classAbstractMutableList<T>
-
noneSatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfyin interfaceRichIterable<T>- Overrides:
noneSatisfyin classAbstractMutableList<T>
-
injectInto
public <IV> IV injectInto(IV injectedValue, Function2<? super IV,? super T,? extends IV> function)Description copied from interface:RichIterableReturns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.- Specified by:
injectIntoin interfaceRichIterable<T>- Overrides:
injectIntoin classAbstractMutableList<T>
-
select
Description copied from interface:RichIterableSame as the select method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> selected = people.select(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> selected = people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());- Specified by:
selectin interfaceRichIterable<T>- Overrides:
selectin classAbstractMutableList<T>- Parameters:
predicate- aPredicateto use as the select criteriatarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriapredicate- Returns:
target, which contains appended elements as a result of the select criteria- See Also:
RichIterable.select(Predicate)
-
reject
Description copied from interface:RichIterableSame as the reject method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> rejected = people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());- Specified by:
rejectin interfaceRichIterable<T>- Overrides:
rejectin classAbstractMutableList<T>- Parameters:
predicate- aPredicateto use as the reject criteriatarget- the Collection to append to for all elements in thisRichIterablethat causePredicate#accept(Object)method to evaluate to false- Returns:
target, which contains appended elements as a result of the reject criteria
-
collect
Description copied from interface:MutableCollectionReturns a new MutableCollection with the results of applying the specified function to each element of the source collection.MutableCollection<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>
-
collect
public <V, R extends Collection<V>> R collect(Function<? super T,? extends V> function, R target)Description copied from interface:RichIterableSame asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
MutableList<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName(), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<String> names = people.collect(new Function<Person, String>() { public String valueOf(Person person) { return person.getFirstName() + " " + person.getLastName(); } }, Lists.mutable.empty());- Specified by:
collectin interfaceRichIterable<T>- Overrides:
collectin classAbstractMutableList<T>- Parameters:
function- aFunctionto use as the collect transformation functiontarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriafunction- Returns:
target, which contains appended elements as a result of the collect transformation- See Also:
RichIterable.collect(Function)
-
collectIf
public <V, R extends Collection<V>> R collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function, R target)Description copied from interface:RichIterableSame as the collectIf method with two parameters but uses the specified target collection for the results.- Specified by:
collectIfin interfaceRichIterable<T>- Overrides:
collectIfin classAbstractMutableList<T>- Parameters:
predicate- aPredicateto use as the select criteriafunction- aFunctionto use as the collect transformation functiontarget- the Collection to append to for all elements in thisRichIterablethat meet the collect criteriapredicate- Returns:
targetCollection, which contains appended elements as a result of the collect criteria and transformation- See Also:
RichIterable.collectIf(Predicate, Function)
-
flatCollect
Description copied from interface:MutableCollectionflatCollectis 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);
Co-variant example for MutableCollection:Function<Person, List<Address>> addressFunction = Person::getAddresses; MutableCollection<Person> people = ...; MutableCollection<List<Address>> addresses = people.collect(addressFunction); MutableCollection<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>- Parameters:
function- TheFunctionto apply- Returns:
- a new flattened collection produced by applying the given
function
-
flatCollect
public <V, R extends Collection<V>> R flatCollect(Function<? super T,? extends Iterable<V>> function, R target)Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectin interfaceRichIterable<T>- Overrides:
flatCollectin classAbstractMutableList<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
selectAndRejectWith
public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T,? super P> predicate, P parameter)Description copied from interface:MutableCollectionFilters a collection into two separate collections based on a predicate returned via a Pair.e.g. return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
- Specified by:
selectAndRejectWithin interfaceMutableCollection<T>- Overrides:
selectAndRejectWithin classAbstractMutableList<T>
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein interfaceRichIterable<T>
-
isEmpty
public boolean isEmpty()Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceList<T>- Specified by:
isEmptyin interfaceRichIterable<T>- Overrides:
isEmptyin classAbstractRichIterable<T>
-
contains
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceList<T>- Specified by:
containsin interfaceRichIterable<T>- Overrides:
containsin classAbstractMutableList<T>
-
iterator
-
toArray
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceList<T>- Specified by:
toArrayin interfaceRichIterable<T>- Overrides:
toArrayin classAbstractRichIterable<T>- See Also:
Collection.toArray()
-
toArray
public <E> E[] toArray(E[] array)Description copied from interface:RichIterableConverts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceList<T>- Specified by:
toArrayin interfaceRichIterable<T>- Overrides:
toArrayin classAbstractRichIterable<T>- See Also:
Collection.toArray(Object[])
-
remove
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceList<T>- Overrides:
removein classAbstractMutableCollection<T>
-
containsAll
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceList<T>- Specified by:
containsAllin interfaceRichIterable<T>- Overrides:
containsAllin classAbstractMutableList<T>- See Also:
Collection.containsAll(Collection)
-
addAll
- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceList<T>- Overrides:
addAllin classAbstractMutableCollection<T>
-
addAllIterable
- Specified by:
addAllIterablein interfaceMutableCollection<T>- Overrides:
addAllIterablein classAbstractMutableCollection<T>- See Also:
Collection.addAll(Collection)
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Specified by:
removeAllin interfaceList<T>- Overrides:
removeAllin classAbstractMutableList<T>
-
removeAllIterable
- Specified by:
removeAllIterablein interfaceMutableCollection<T>- Overrides:
removeAllIterablein classAbstractMutableCollection<T>- See Also:
Collection.removeAll(Collection)
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Specified by:
retainAllin interfaceList<T>- Overrides:
retainAllin classAbstractMutableList<T>
-
retainAllIterable
- Specified by:
retainAllIterablein interfaceMutableCollection<T>- Overrides:
retainAllIterablein classAbstractMutableCollection<T>- See Also:
Collection.retainAll(Collection)
-
replaceAll
- Specified by:
replaceAllin interfaceList<T>- Since:
- 10.0 - Overridden for efficiency
-
sort
-
clear
public void clear() -
addAll
-
get
Description copied from interface:ListIterableReturns the item at the specified position in this list iterable. -
add
-
remove
-
indexOf
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 interfaceList<T>- Specified by:
indexOfin interfaceOrderedIterable<T>- Overrides:
indexOfin classAbstractMutableList<T>- See Also:
List.indexOf(Object)
-
lastIndexOf
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 interfaceList<T>- Specified by:
lastIndexOfin interfaceListIterable<T>- Overrides:
lastIndexOfin classAbstractMutableList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>- Specified by:
listIteratorin interfaceListIterable<T>- Overrides:
listIteratorin classAbstractMutableList<T>- See Also:
List.listIterator(int)
-
subList
- Specified by:
subListin interfaceList<T>- Specified by:
subListin interfaceListIterable<T>- Specified by:
subListin interfaceMutableList<T>- Overrides:
subListin classAbstractMutableList<T>- See Also:
List.subList(int, int)
-
equals
Description copied from interface:ListIterableFollows the same general contract asList.equals(Object).- Specified by:
equalsin interfaceCollection<T>- Specified by:
equalsin interfaceList<T>- Specified by:
equalsin interfaceListIterable<T>- Overrides:
equalsin classAbstractMutableList<T>
-
abstractArrayAdapterEquals
-
hashCode
public int hashCode()Description copied from interface:ListIterableFollows the same general contract asList.hashCode().- Specified by:
hashCodein interfaceCollection<T>- Specified by:
hashCodein interfaceList<T>- Specified by:
hashCodein interfaceListIterable<T>- Overrides:
hashCodein classAbstractMutableList<T>
-
forEachWith
Description copied from interface:InternalIterableThe procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) -> { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } }, fred);Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);- Specified by:
forEachWithin interfaceInternalIterable<T>- Overrides:
forEachWithin classAbstractMutableList<T>
-
selectWith
public <P, R extends Collection<T>> R selectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate, Collection), 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:
MutableList<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> selected = people.selectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge()>= age; } }, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
selectWithin interfaceRichIterable<T>- Overrides:
selectWithin classAbstractMutableList<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriapredicate- Returns:
targetCollection, which contains appended elements as a result of the select criteria- See Also:
RichIterable.select(Predicate),RichIterable.select(Predicate, Collection)
-
rejectWith
public <P, R extends Collection<T>> R rejectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate, Collection), 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:
MutableList<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());Example using an anonymous inner class:
MutableList<Person> rejected = people.rejectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge() < age; } }, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
rejectWithin interfaceRichIterable<T>- Overrides:
rejectWithin classAbstractMutableList<T>- Parameters:
predicate- aPredicate2to use as the reject criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat causePredicate#accept(Object)method to evaluate to false- Returns:
targetCollection, which contains appended elements as a result of the reject criteria- See Also:
RichIterable.reject(Predicate),RichIterable.reject(Predicate, Collection)
-
collectWith
public <P, A> MutableList<A> collectWith(Function2<? super T,? super P,? extends A> function, P parameter)Description copied from interface:MutableCollectionSame 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));Example using an anonymous inner class:
Function2<Integer, Integer, Integer> addParameterFunction = new Function2<Integer, Integer, Integer>() { public Integer value(Integer each, Integer parameter) { return each + parameter; } }; RichIterable<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1));Co-variant example for MutableCollection:MutableCollection<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>- 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)
-
collectWith
public <P, A, R extends Collection<A>> R collectWith(Function2<? super T,? super P,? extends A> function, P parameter, R target)Description copied from interface:RichIterableSame as collectWith but with a targetCollection parameter to gather the results.Example using a Java 8 lambda expression:
MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());Example using an anonymous inner class:
Function2<Integer, Integer, Integer> addParameterFunction = new Function2<Integer, Integer, Integer>() { public Integer value(final Integer each, final Integer parameter) { return each + parameter; } }; MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1), Sets.mutable.empty());- Specified by:
collectWithin interfaceRichIterable<T>- Overrides:
collectWithin classAbstractMutableList<T>- Parameters:
function- aFunction2to use as the collect transformation functionparameter- a parameter to pass in for evaluation of the second argumentPinfunctiontarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriafunction- Returns:
targetCollection, which contains appended elements as a result of the collect transformation
-
injectIntoWith
public <IV, P> IV injectIntoWith(IV injectValue, Function3<? super IV,? super T,? super P,? extends IV> function, P parameter)Description copied from interface:MutableCollectionReturns the final result of evaluating function using each element of the iterable, the previous evaluation result and the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. The parameter value is always used as the third parameter to the function call.- Specified by:
injectIntoWithin interfaceMutableCollection<T>- Overrides:
injectIntoWithin classAbstractMutableList<T>- See Also:
RichIterable.injectInto(Object, Function2)
-
forEach
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.forEach(0, 1, new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });This code would output ted and mary's names.
- Specified by:
forEachin interfaceOrderedIterable<T>- Overrides:
forEachin classAbstractMutableList<T>
-
countWith
Description copied from interface:RichIterableReturns the total number of elements that evaluate to true for the specified predicate.e.g. return lastNames.countWith(Predicates2.equal(), "Smith");
- Specified by:
countWithin interfaceRichIterable<T>- Overrides:
countWithin classAbstractMutableList<T>
-
anySatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the collection, or return false. Returns false if the collection is empty.- Specified by:
anySatisfyWithin interfaceRichIterable<T>- Overrides:
anySatisfyWithin classAbstractMutableList<T>
-
allSatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the collection, or returns false.- Specified by:
allSatisfyWithin interfaceRichIterable<T>- Overrides:
allSatisfyWithin classAbstractMutableList<T>
-
noneSatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the collection, or return false. Returns true if the collection is empty.- Specified by:
noneSatisfyWithin interfaceRichIterable<T>- Overrides:
noneSatisfyWithin classAbstractMutableList<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>- Overrides:
distinctin classAbstractMutableList<T>- Returns:
ListIterableof distinct elements
-
distinct
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>- Overrides:
distinctin classAbstractMutableList<T>- Returns:
ListIterableof distinct elements
-
appendString
Description copied from interface:RichIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byRichIterable.makeString(String, String, String).- Specified by:
appendStringin interfaceRichIterable<T>- Overrides:
appendStringin classAbstractMutableList<T>
-
take
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>- Overrides:
takein classAbstractMutableList<T>- Parameters:
count- the number of items to take.
-
drop
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>- Overrides:
dropin classAbstractMutableList<T>- Parameters:
count- the number of items to drop.
-