Class AbstractCollectionAdapter<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,MutableCollection<T>,InternalIterable<T>,RichIterable<T>
- Direct Known Subclasses:
AbstractListAdapter,CollectionAdapter,SetAdapter,SortedSetAdapter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(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.asLazy()Returns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).chunk(int size) Partitions elements in fixed size chunks.voidclear()<V> MutableCollection<V>Returns a new MutableCollection with the results of applying the specified function to each element of the source collection.<V,R extends Collection<V>>
RSame asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.<R extends MutableBooleanCollection>
RcollectBoolean(BooleanFunction<? super T> booleanFunction, R target) Same asRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableByteCollection>
RcollectByte(ByteFunction<? super T> byteFunction, R target) Same asRichIterable.collectByte(ByteFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableCharCollection>
RcollectChar(CharFunction<? super T> charFunction, R target) Same asRichIterable.collectChar(CharFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableDoubleCollection>
RcollectDouble(DoubleFunction<? super T> doubleFunction, R target) Same asRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableFloatCollection>
RcollectFloat(FloatFunction<? super T> floatFunction, R target) Same asRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specifiedtargetcollection.<V> MutableCollection<V>Returns a new MutableCollection with the results of applying the specified function to each element of the source collection, but only for elements that evaluate to true for the specified predicate.<V,R extends Collection<V>>
RSame as the collectIf method with two parameters but uses the specified target collection for the results.<R extends MutableIntCollection>
RcollectInt(IntFunction<? super T> intFunction, R target) Same asRichIterable.collectInt(IntFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableLongCollection>
RcollectLong(LongFunction<? super T> longFunction, R target) Same asRichIterable.collectLong(LongFunction), except that the results are gathered into the specifiedtargetcollection.<R extends MutableShortCollection>
RcollectShort(ShortFunction<? super T> shortFunction, R target) Same asRichIterable.collectShort(ShortFunction), except that the results are gathered into the specifiedtargetcollection.<P,A, R extends Collection<A>>
RcollectWith(Function2<? super T, ? super P, ? extends A> function, P parameter, R targetCollection) Same as collectWith but with a targetCollection parameter to gather the results.<P,V> MutableCollection<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.booleanReturns 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.booleancontainsAllArguments(Object... elements) Returns true if all elements in the specified var arg array are contained in this collection.booleancontainsAllIterable(Iterable<?> source) Returns true if all elements in source are contained in this collection.intReturn 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.Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function) Returns the first element of the iterable for which the predicate evaluates to true.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> TdetectWithIfNone(Predicate2<? super T, ? super P> predicate, P parameter, Function0<? extends T> function) Returns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or returns the value of evaluating the specified function.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.voidThe procedure is executed for each element in the iterable.<V> MutableCollection<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.<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(ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.getFirst()Returns the first element of an iterable.getLast()Returns the last element of an iterable.getOnly()Returns the element if the iterable has exactly one element.<V> MutableMultimap<V,T> 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,R extends MutableMultimap<V, T>>
RSame asRichIterable.groupBy(Function), except that the results are gathered into the specifiedtargetmultimap.<V> MutableMultimap<V,T> groupByEach(Function<? super T, ? extends Iterable<V>> function) Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.<V,R extends MutableMultimap<V, T>>
RgroupByEach(Function<? super T, ? extends Iterable<V>> function, R target) Same asRichIterable.groupByEach(Function), except that the results are gathered into the specifiedtargetmultimap.<V> MutableMap<V,T> groupByUniqueKey(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 map, where the transformed value is the key.<V,R extends MutableMapIterable<V, T>>
RgroupByUniqueKey(Function<? super T, ? extends V> function, R target) Same asRichIterable.groupByUniqueKey(Function), except that the results are gathered into the specifiedtargetmap.doubleinjectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function) Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.floatinjectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function) Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.intinjectInto(int injectedValue, IntObjectToIntFunction<? super T> function) Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.longinjectInto(long injectedValue, LongObjectToLongFunction<? super T> function) Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.<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> IV injectIntoWith(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.<R extends Collection<T>>
Rinto(R target) Adds all the elements in this iterable to the specific target Collection.booleanisEmpty()Returns true if this iterable has zero items.iterator()max()Returns the maximum element out of this container based on the natural order.max(Comparator<? super T> comparator) Returns the maximum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.min()Returns the minimum element out of this container based on the natural order.min(Comparator<? super T> comparator) Returns the minimum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.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()Filters a collection into a PartitionedIterable based on the evaluation of the predicate.partitionWith(Predicate2<? super T, ? super P> predicate, P parameter) Filters a collection into a PartitionIterable based on the evaluation of the predicate.Returns a MutableCollection with all elements that evaluate to false for the specified predicate.<R extends Collection<T>>
RSame as the reject method with one parameter but uses the specified target collection for the results.<P> MutableCollection<T>rejectWith(Predicate2<? super T, ? super P> predicate, P parameter) Returns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter.<P,R extends Collection<T>>
RrejectWith(Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) Similar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.booleanbooleanremoveAll(Collection<?> collection) booleanremoveAllIterable(Iterable<?> iterable) booleanRemoves 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.booleanretainAll(Collection<?> collection) booleanretainAllIterable(Iterable<?> iterable) Returns a MutableCollection with all elements that evaluate to true for the specified predicate.<R extends Collection<T>>
RSame 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.<S> MutableCollection<S>selectInstancesOf(Class<S> clazz) Returns all elements of the source collection that are instances of the Classclazz.<P> MutableCollection<T>selectWith(Predicate2<? super T, ? super P> predicate, P parameter) Returns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter.<P,R extends Collection<T>>
RselectWith(Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) 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.<V> MutableObjectDoubleMap<V>sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function) Groups and sums the values using the two specified functions.<V> MutableObjectDoubleMap<V>sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) Groups and sums the values using the two specified functions.<V> MutableObjectLongMap<V>sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) Groups and sums the values using the two specified functions.<V> MutableObjectLongMap<V>sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) Groups and sums the values using the two specified functions.doublesumOfDouble(DoubleFunction<? super T> function) Returns the final double result of evaluating function for each element of the iterable and adding the results together.doublesumOfFloat(FloatFunction<? super T> function) Returns the final double result of evaluating function for each element of the iterable and adding the results together.longsumOfInt(IntFunction<? super T> function) Returns the final long result of evaluating function for each element of the iterable and adding the results together.longsumOfLong(LongFunction<? super T> function) Returns the final long result of evaluating function for each element of the iterable and adding the results together.Executes the Procedure for each element in the iterable and returnsthis.Object[]toArray()Converts this iterable to an array.<E> E[]toArray(E[] a) Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.toBag()Converts the collection to the default MutableBag implementation.<K,V> MutableBiMap<K, V> Converts the collection to a BiMap implementation using the specified key and value functions.toList()Converts the collection to a MutableList implementation.<K,V> MutableMap<K, V> Converts the collection to a MutableMap implementation using the specified key and value functions.<K,V, R extends Map<K, V>>
RtoMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction, R target) Same asRichIterable.toMap(Function, Function), except that the results are gathered into the specifiedtargetmap.toSet()Converts the collection to a MutableSet implementation.Converts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.toSortedBag(Comparator<? super T> comparator) Converts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.toSortedList(Comparator<? super T> comparator) Converts the collection to a MutableList implementation and sorts it using the specified comparator.<K,V> MutableSortedMap<K, V> toSortedMap(Comparator<? super K> comparator, Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) Converts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the given comparator.<K,V> MutableSortedMap<K, V> toSortedMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) Converts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the key elements' natural ordering.Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.toSortedSet(Comparator<? super T> comparator) Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.toString()Returns a string with the elements of this iterable separated by commas with spaces and enclosed in square brackets.<S> MutableCollection<Pair<T,S>> Returns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs.<S,R extends Collection<Pair<T, S>>>
RSame asRichIterable.zip(Iterable)but usestargetfor output.Zips thisRichIterablewith its indices.<R extends Collection<Pair<T,Integer>>>
RzipWithIndex(R target) Same asRichIterable.zipWithIndex()but usestargetfor output.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArrayMethods inherited from interface org.eclipse.collections.api.InternalIterable
forEachMethods inherited from interface org.eclipse.collections.api.collection.MutableCollection
aggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, countBy, countByEach, countByWith, flatCollectWith, newEmpty, toImmutable, with, withAll, without, withoutAllMethods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, appendString, appendString, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countBy, countByEach, countByWith, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, groupByAndCollect, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, reduce, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toSortedBagBy, toSortedList, toSortedListBy, toSortedMapBy, toSortedSetBy
-
Constructor Details
-
AbstractCollectionAdapter
public AbstractCollectionAdapter()
-
-
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 interfaceRichIterable<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 interfaceRichIterable<T>
-
getOnly
Description copied from interface:RichIterableReturns the element if the iterable has exactly one element. Otherwise, throwIllegalStateException.- Specified by:
getOnlyin interfaceRichIterable<T>- Returns:
- an element of an iterable.
-
tap
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()));Example using an anonymous inner class:
RichIterable<Person> tapped = people.tap(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });- Specified by:
tapin interfaceMutableCollection<T>- Specified by:
tapin interfaceRichIterable<T>- See Also:
-
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>- See Also:
-
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>
-
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>
-
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>
-
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>
-
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>
-
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>
-
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>
-
detectIfNone
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true. If no element matches the predicate, then returns the value of applying the specified function.- Specified by:
detectIfNonein interfaceRichIterable<T>
-
detectWithIfNone
public <P> T detectWithIfNone(Predicate2<? super T, ? super P> predicate, P parameter, Function0<? extends T> function) Description copied from interface:RichIterableReturns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or returns the value of evaluating the specified function.- Specified by:
detectWithIfNonein interfaceRichIterable<T>
-
min
Description copied from interface:RichIterableReturns the minimum element out of this container based on the comparator.- Specified by:
minin interfaceRichIterable<T>
-
max
Description copied from interface:RichIterableReturns the maximum element out of this container based on the comparator.- Specified by:
maxin interfaceRichIterable<T>
-
min
Description copied from interface:RichIterableReturns the minimum element out of this container based on the natural order.- Specified by:
minin interfaceRichIterable<T>
-
max
Description copied from interface:RichIterableReturns the maximum element out of this container based on the natural order.- Specified by:
maxin interfaceRichIterable<T>
-
minBy
Description copied from interface:RichIterableReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
minByin interfaceRichIterable<T>
-
maxBy
Description copied from interface:RichIterableReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
maxByin interfaceRichIterable<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>
-
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>
-
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>
-
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>
-
injectInto
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>
-
injectInto
Description copied from interface:RichIterableReturns the final int 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.- Specified by:
injectIntoin interfaceRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final long 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.- Specified by:
injectIntoin interfaceRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final double 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.- Specified by:
injectIntoin interfaceRichIterable<T>
-
injectInto
Description copied from interface:RichIterableReturns the final float 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.- Specified by:
injectIntoin interfaceRichIterable<T>
-
sumOfInt
Description copied from interface:RichIterableReturns the final long result of evaluating function for each element of the iterable and adding the results together.- Specified by:
sumOfIntin interfaceRichIterable<T>
-
sumOfFloat
Description copied from interface:RichIterableReturns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.- Specified by:
sumOfFloatin interfaceRichIterable<T>
-
sumOfLong
Description copied from interface:RichIterableReturns the final long result of evaluating function for each element of the iterable and adding the results together.- Specified by:
sumOfLongin interfaceRichIterable<T>
-
sumOfDouble
Description copied from interface:RichIterableReturns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.- Specified by:
sumOfDoublein interfaceRichIterable<T>
-
sumByInt
public <V> MutableObjectLongMap<V> sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByIntin interfaceMutableCollection<T>- Specified by:
sumByIntin interfaceRichIterable<T>
-
sumByFloat
public <V> MutableObjectDoubleMap<V> sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByFloatin interfaceMutableCollection<T>- Specified by:
sumByFloatin interfaceRichIterable<T>
-
sumByLong
public <V> MutableObjectLongMap<V> sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByLongin interfaceMutableCollection<T>- Specified by:
sumByLongin interfaceRichIterable<T>
-
sumByDouble
public <V> MutableObjectDoubleMap<V> sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByDoublein interfaceMutableCollection<T>- Specified by:
sumByDoublein interfaceRichIterable<T>
-
select
Description copied from interface:MutableCollectionReturns a MutableCollection with all elements that evaluate to true for the specified predicate.MutableCollection<Integer> livesInLondon = people.select(person -> person.getAddress().getCity().equals("London"));- Specified by:
selectin interfaceMutableCollection<T>- Specified by:
selectin interfaceRichIterable<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>- 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:
-
reject
Description copied from interface:MutableCollectionReturns a MutableCollection with all elements that evaluate to false for the specified predicate.MutableCollection<Person> notSmiths = people.reject(person -> person.person.getLastName().equals("Smith"));Using thePredicatesfactory:MutableCollection<Person> notSmiths = people.reject(Predicates.attributeEqual("lastName", "Smith"));- Specified by:
rejectin interfaceMutableCollection<T>- Specified by:
rejectin interfaceRichIterable<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
-
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>- 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
-
selectInstancesOf
Description copied from interface:MutableCollectionReturns 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);Co-variant example for MutableCollection:MutableCollection<Integer> integers = List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);- Specified by:
selectInstancesOfin interfaceMutableCollection<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>
-
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 interfaceMutableCollection<T>- Specified by:
collectin interfaceRichIterable<T>
-
collectBoolean
public <R extends MutableBooleanCollection> R collectBoolean(BooleanFunction<? super T> booleanFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
BooleanArrayList licenses = people.collectBoolean(person -> person.hasDrivingLicense(), new BooleanArrayList());Example using an anonymous inner class:
BooleanArrayList licenses = people.collectBoolean(new BooleanFunction<Person>() { public boolean booleanValueOf(Person person) { return person.hasDrivingLicense(); } }, new BooleanArrayList());- Specified by:
collectBooleanin interfaceRichIterable<T>- Parameters:
booleanFunction- aBooleanFunctionto use as the collect transformation functiontarget- the MutableBooleanCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collectByte
public <R extends MutableByteCollection> R collectByte(ByteFunction<? super T> byteFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectByte(ByteFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
ByteArrayList bytes = people.collectByte(person -> person.getCode(), new ByteArrayList());Example using an anonymous inner class:
ByteArrayList bytes = people.collectByte(new ByteFunction<Person>() { public byte byteValueOf(Person person) { return person.getCode(); } }, new ByteArrayList());- Specified by:
collectBytein interfaceRichIterable<T>- Parameters:
byteFunction- aByteFunctionto use as the collect transformation functiontarget- the MutableByteCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collectChar
public <R extends MutableCharCollection> R collectChar(CharFunction<? super T> charFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectChar(CharFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
CharArrayList chars = people.collectChar(person -> person.getMiddleInitial(), new CharArrayList());Example using an anonymous inner class:
CharArrayList chars = people.collectChar(new CharFunction<Person>() { public char charValueOf(Person person) { return person.getMiddleInitial(); } }, new CharArrayList());- Specified by:
collectCharin interfaceRichIterable<T>- Parameters:
charFunction- aCharFunctionto use as the collect transformation functiontarget- the MutableCharCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collectDouble
public <R extends MutableDoubleCollection> R collectDouble(DoubleFunction<? super T> doubleFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
DoubleArrayList doubles = people.collectDouble(person -> person.getMilesFromNorthPole(), new DoubleArrayList());Example using an anonymous inner class:
DoubleArrayList doubles = people.collectDouble(new DoubleFunction<Person>() { public double doubleValueOf(Person person) { return person.getMilesFromNorthPole(); } }, new DoubleArrayList());- Specified by:
collectDoublein interfaceRichIterable<T>- Parameters:
doubleFunction- aDoubleFunctionto use as the collect transformation functiontarget- the MutableDoubleCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collectFloat
public <R extends MutableFloatCollection> R collectFloat(FloatFunction<? super T> floatFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
FloatArrayList floats = people.collectFloat(person -> person.getHeightInInches(), new FloatArrayList());Example using an anonymous inner class:
FloatArrayList floats = people.collectFloat(new FloatFunction<Person>() { public float floatValueOf(Person person) { return person.getHeightInInches(); } }, new FloatArrayList());- Specified by:
collectFloatin interfaceRichIterable<T>- Parameters:
floatFunction- aFloatFunctionto use as the collect transformation functiontarget- the MutableFloatCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collectInt
Description copied from interface:RichIterableSame asRichIterable.collectInt(IntFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
IntArrayList ints = people.collectInt(person -> person.getAge(), new IntArrayList());Example using an anonymous inner class:
IntArrayList ints = people.collectInt(new IntFunction<Person>() { public int intValueOf(Person person) { return person.getAge(); } }, new IntArrayList());- Specified by:
collectIntin interfaceRichIterable<T>- Parameters:
intFunction- aIntFunctionto use as the collect transformation functiontarget- the MutableIntCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collectLong
public <R extends MutableLongCollection> R collectLong(LongFunction<? super T> longFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectLong(LongFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
LongArrayList longs = people.collectLong(person -> person.getGuid(), new LongArrayList());Example using an anonymous inner class:
LongArrayList longs = people.collectLong(new LongFunction<Person>() { public long longValueOf(Person person) { return person.getGuid(); } }, new LongArrayList());- Specified by:
collectLongin interfaceRichIterable<T>- Parameters:
longFunction- aLongFunctionto use as the collect transformation functiontarget- the MutableLongCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collectShort
public <R extends MutableShortCollection> R collectShort(ShortFunction<? super T> shortFunction, R target) Description copied from interface:RichIterableSame asRichIterable.collectShort(ShortFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
ShortArrayList shorts = people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth, new ShortArrayList());Example using an anonymous inner class:
ShortArrayList shorts = people.collectShort(new ShortFunction<Person>() { public short shortValueOf(Person person) { return person.getNumberOfJunkMailItemsReceivedPerMonth; } }, new ShortArrayList());- Specified by:
collectShortin interfaceRichIterable<T>- Parameters:
shortFunction- aShortFunctionto use as the collect transformation functiontarget- the MutableShortCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
collect
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>- 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:
-
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 interfaceMutableCollection<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>- 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:
-
collectIf
public <V> MutableCollection<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function) Description copied from interface:MutableCollectionReturns a new MutableCollection with the results of applying the specified function to each element of the source collection, but only for elements that evaluate to true for the specified predicate.MutableCollection<String> collected = Lists.mutable.of().with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString())- Specified by:
collectIfin interfaceMutableCollection<T>- Specified by:
collectIfin interfaceRichIterable<T>
-
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>- 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:
-
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>
-
partition
Description copied from interface:MutableCollectionFilters 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"));Example using an anonymous inner class:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partition(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });Co-variant example for MutableCollection:PartitionMutableCollection<Person> newYorkersAndNonNewYorkers = people.partition(person -> person.getAddress().getState().getName().equals("New York"));- Specified by:
partitionin interfaceMutableCollection<T>- Specified by:
partitionin interfaceRichIterable<T>
-
partitionWith
public <P> PartitionMutableCollection<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter) Description copied from interface:MutableCollectionFilters 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");Example using an anonymous inner class:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partitionWith(new Predicate2<Person, String>() { public boolean accept(Person person, String state) { return person.getAddress().getState().getName().equals(state); } }, "New York");Co-variant example for MutableCollection:PartitionMutableCollection<Person> newYorkersAndNonNewYorkers = people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");- Specified by:
partitionWithin interfaceMutableCollection<T>- Specified by:
partitionWithin interfaceRichIterable<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 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 interfaceRichIterable<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 interfaceRichIterable<T>
-
iterator
-
toArray
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceRichIterable<T>- See Also:
-
toArray
public <E> E[] toArray(E[] a) 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 interfaceRichIterable<T>- See Also:
-
add
- Specified by:
addin interfaceCollection<T>
-
remove
- Specified by:
removein interfaceCollection<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 interfaceRichIterable<T>- See Also:
-
containsAllIterable
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllIterablein interfaceRichIterable<T>
-
containsAllArguments
Description copied from interface:RichIterableReturns true if all elements in the specified var arg array are contained in this collection.- Specified by:
containsAllArgumentsin interfaceRichIterable<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>
-
addAllIterable
- Specified by:
addAllIterablein interfaceMutableCollection<T>- See Also:
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>
-
removeAllIterable
- Specified by:
removeAllIterablein interfaceMutableCollection<T>- See Also:
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>
-
retainAllIterable
- Specified by:
retainAllIterablein interfaceMutableCollection<T>- See Also:
-
clear
public void clear()- Specified by:
clearin interfaceCollection<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>
-
selectWith
Description copied from interface:MutableCollectionReturns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter.MutableCollection<Integer> fives = integers.selectWith(Predicates2.equal(), Integer.valueOf(5));- Specified by:
selectWithin interfaceMutableCollection<T>- Specified by:
selectWithin interfaceRichIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
-
selectWith
public <P,R extends Collection<T>> R selectWith(Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) 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>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetargetCollection- 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:
-
rejectWith
Description copied from interface:MutableCollectionReturns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter.e.g. MutableCollection<Integer> selected = integers.rejectWith(Predicates2.equal(), Integer.valueOf(5));- Specified by:
rejectWithin interfaceMutableCollection<T>- Specified by:
rejectWithin interfaceRichIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
-
rejectWith
public <P,R extends Collection<T>> R rejectWith(Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) 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>- Parameters:
predicate- aPredicate2to use as the reject criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetargetCollection- 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:
-
collectWith
public <P,V> MutableCollection<V> collectWith(Function2<? super T, ? super P, ? extends V> 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 interfaceMutableCollection<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:
-
collectWith
public <P,A, R collectWithR extends Collection<A>> (Function2<? super T, ? super P, ? extends A> function, P parameter, R targetCollection) 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>- Parameters:
function- aFunction2to use as the collect transformation functionparameter- a parameter to pass in for evaluation of the second argumentPinfunctiontargetCollection- 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>- See Also:
-
into
Description copied from interface:RichIterableAdds all the elements in this iterable to the specific target Collection.- Specified by:
intoin interfaceRichIterable<T>
-
toList
Description copied from interface:RichIterableConverts the collection to a MutableList implementation.- Specified by:
toListin interfaceRichIterable<T>
-
toSortedList
Description copied from interface:RichIterableConverts the collection to a MutableList implementation and sorts it using the specified comparator.- Specified by:
toSortedListin interfaceRichIterable<T>
-
toSortedSet
Description copied from interface:RichIterableConverts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.- Specified by:
toSortedSetin interfaceRichIterable<T>
-
toSortedSet
Description copied from interface:RichIterableConverts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.- Specified by:
toSortedSetin interfaceRichIterable<T>
-
toSet
Description copied from interface:RichIterableConverts the collection to a MutableSet implementation.- Specified by:
toSetin interfaceRichIterable<T>
-
toBag
Description copied from interface:RichIterableConverts the collection to the default MutableBag implementation.- Specified by:
toBagin interfaceRichIterable<T>
-
toSortedBag
Description copied from interface:RichIterableConverts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.- Specified by:
toSortedBagin interfaceRichIterable<T>
-
toSortedBag
Description copied from interface:RichIterableConverts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.- Specified by:
toSortedBagin interfaceRichIterable<T>
-
toMap
public <K,V> MutableMap<K,V> toMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) Description copied from interface:RichIterableConverts the collection to a MutableMap implementation using the specified key and value functions.- Specified by:
toMapin interfaceRichIterable<T>
-
toMap
public <K,V, R toMapR extends Map<K, V>> (Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction, R target) Description copied from interface:RichIterableSame asRichIterable.toMap(Function, Function), except that the results are gathered into the specifiedtargetmap.- Specified by:
toMapin interfaceRichIterable<T>
-
toSortedMap
public <K,V> MutableSortedMap<K,V> toSortedMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) Description copied from interface:RichIterableConverts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the key elements' natural ordering.- Specified by:
toSortedMapin interfaceRichIterable<T>
-
toSortedMap
public <K,V> MutableSortedMap<K,V> toSortedMap(Comparator<? super K> comparator, Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) Description copied from interface:RichIterableConverts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the given comparator.- Specified by:
toSortedMapin interfaceRichIterable<T>
-
toBiMap
public <K,V> MutableBiMap<K,V> toBiMap(Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) Description copied from interface:RichIterableConverts the collection to a BiMap implementation using the specified key and value functions.- Specified by:
toBiMapin interfaceRichIterable<T>
-
asLazy
Description copied from interface:RichIterableReturns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).- Specified by:
asLazyin interfaceRichIterable<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>
-
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>
-
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>
-
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>
-
toString
Description copied from interface:RichIterableReturns a string with the elements of this iterable separated by commas with spaces and enclosed in square brackets.Assert.assertEquals("[]", Lists.mutable.empty().toString()); Assert.assertEquals("[1]", Lists.mutable.with(1).toString()); Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());- Specified by:
toStringin interfaceRichIterable<T>- Overrides:
toStringin classObject- Returns:
- a string representation of this RichIterable
- See Also:
-
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>
-
groupBy
Description copied from interface:MutableCollectionFor 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);Example using an anonymous inner class:
Multimap<String, Person> peopleByLastName = people.groupBy(new Function<Person, String>() { public String valueOf(Person person) { return person.getLastName(); } });Co-variant example for MutableCollection:MutableMultimap<String, Person> peopleByLastName = people.groupBy(Person::getLastName);- Specified by:
groupByin interfaceMutableCollection<T>- Specified by:
groupByin interfaceRichIterable<T>
-
groupBy
public <V,R extends MutableMultimap<V, R groupByT>> (Function<? super T, ? extends V> function, R target) Description copied from interface:RichIterableSame asRichIterable.groupBy(Function), except that the results are gathered into the specifiedtargetmultimap.Example using a Java 8 method reference:
FastListMultimap<String, Person> peopleByLastName = people.groupBy(Person::getLastName, new FastListMultimap<String, Person>());Example using an anonymous inner class:
FastListMultimap<String, Person> peopleByLastName = people.groupBy(new Function<Person, String>() { public String valueOf(Person person) { return person.getLastName(); } }, new FastListMultimap<String, Person>());- Specified by:
groupByin interfaceRichIterable<T>
-
groupByEach
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 interfaceMutableCollection<T>- Specified by:
groupByEachin interfaceRichIterable<T>
-
groupByEach
public <V,R extends MutableMultimap<V, R groupByEachT>> (Function<? super T, ? extends Iterable<V>> function, R target) Description copied from interface:RichIterableSame asRichIterable.groupByEach(Function), except that the results are gathered into the specifiedtargetmultimap.- Specified by:
groupByEachin interfaceRichIterable<T>
-
groupByUniqueKey
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 map, where the transformed value is the key. The generated keys must each be unique, or else an exception is thrown.- Specified by:
groupByUniqueKeyin interfaceMutableCollection<T>- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>- See Also:
-
groupByUniqueKey
public <V,R extends MutableMapIterable<V, R groupByUniqueKeyT>> (Function<? super T, ? extends V> function, R target) Description copied from interface:RichIterableSame asRichIterable.groupByUniqueKey(Function), except that the results are gathered into the specifiedtargetmap.- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>- See Also:
-
zip
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 interfaceMutableCollection<T>- Specified by:
zipin interfaceRichIterable<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.
-
zip
Description copied from interface:RichIterableSame asRichIterable.zip(Iterable)but usestargetfor output.- Specified by:
zipin interfaceRichIterable<T>
-
zipWithIndex
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceMutableCollection<T>- Specified by:
zipWithIndexin interfaceRichIterable<T>- Returns:
- A new
RichIterablecontaining pairs consisting of all elements of thisRichIterablepaired with their index. Indices start at 0. - See Also:
-
zipWithIndex
Description copied from interface:RichIterableSame asRichIterable.zipWithIndex()but usestargetfor output.- Specified by:
zipWithIndexin interfaceRichIterable<T>
-
chunk
Description copied from interface:RichIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceRichIterable<T>- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingRichIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-