Class ArrayStack<T>
- All Implemented Interfaces:
Externalizable,Serializable,Iterable<T>,InternalIterable<T>,OrderedIterable<T>,RichIterable<T>,MutableStack<T>,StackIterable<T>
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionArrayStack(int initialCapacity) ArrayStack(Iterable<T> items) ArrayStack(T... items) -
Method Summary
Modifier and TypeMethodDescriptionbooleanallSatisfy(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) Prints a string representation of this collection onto the givenAppendable.voidappendString(Appendable appendable, String separator) Prints a string representation of this collection onto the givenAppendable.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> ArrayStack<V>Returns a new collection with the results of applying the specified function on each element of the source collection.<V,R extends Collection<V>>
RSame asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.collectBoolean(BooleanFunction<? super T> booleanFunction) Returns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection.<R extends MutableBooleanCollection>
RcollectBoolean(BooleanFunction<? super T> booleanFunction, R target) Same asRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specifiedtargetcollection.collectByte(ByteFunction<? super T> byteFunction) Returns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection.<R extends MutableByteCollection>
RcollectByte(ByteFunction<? super T> byteFunction, R target) Same asRichIterable.collectByte(ByteFunction), except that the results are gathered into the specifiedtargetcollection.collectChar(CharFunction<? super T> charFunction) Returns a new primitivechariterable with the results of applying the specified function on each element of the source collection.<R extends MutableCharCollection>
RcollectChar(CharFunction<? super T> charFunction, R target) Same asRichIterable.collectChar(CharFunction), except that the results are gathered into the specifiedtargetcollection.collectDouble(DoubleFunction<? super T> doubleFunction) Returns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection.<R extends MutableDoubleCollection>
RcollectDouble(DoubleFunction<? super T> doubleFunction, R target) Same asRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specifiedtargetcollection.collectFloat(FloatFunction<? super T> floatFunction) Returns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection.<R extends MutableFloatCollection>
RcollectFloat(FloatFunction<? super T> floatFunction, R target) Same asRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specifiedtargetcollection.<V> ArrayStack<V>Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.<V,R extends Collection<V>>
RSame as the collectIf method with two parameters but uses the specified target collection for the results.collectInt(IntFunction<? super T> intFunction) Returns a new primitiveintiterable with the results of applying the specified function on each element of the source collection.<R extends MutableIntCollection>
RcollectInt(IntFunction<? super T> intFunction, R target) Same asRichIterable.collectInt(IntFunction), except that the results are gathered into the specifiedtargetcollection.collectLong(LongFunction<? super T> longFunction) Returns a new primitivelongiterable with the results of applying the specified function on each element of the source collection.<R extends MutableLongCollection>
RcollectLong(LongFunction<? super T> longFunction, R target) Same asRichIterable.collectLong(LongFunction), except that the results are gathered into the specifiedtargetcollection.collectShort(ShortFunction<? super T> shortFunction) Returns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection.<R extends MutableShortCollection>
RcollectShort(ShortFunction<? super T> shortFunction, R target) Same asRichIterable.collectShort(ShortFunction), except that the results are gathered into the specifiedtargetcollection.<P,V> ArrayStack<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.<P,V, R extends Collection<V>>
RcollectWith(Function2<? super T, ? super P, ? extends V> function, P parameter, R targetCollection) Same as collectWith but with a targetCollection parameter to gather the results.booleanReturns true if the iterable has an element which responds true to element.equals(object).booleancontainsAll(Collection<?> source) 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.<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.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.intdetectIndex(Predicate<? super T> predicate) Returns the index of the first element of theOrderedIterablefor which thepredicateevaluates 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.distinct()Returns a newOrderedIterablecontaining the distinct elements in this iterable.Returns the final elements that do not satisfy the Predicate.voidThe procedure is executed for each element in the iterable.booleanFollows the same general contract asList.equals(Object), but for Stacks.<V> ArrayStack<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.<R extends MutableBooleanCollection>
RflatCollectBoolean(Function<? super T, ? extends BooleanIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableByteCollection>
RflatCollectByte(Function<? super T, ? extends ByteIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableCharCollection>
RflatCollectChar(Function<? super T, ? extends CharIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableDoubleCollection>
RflatCollectDouble(Function<? super T, ? extends DoubleIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableFloatCollection>
RflatCollectFloat(Function<? super T, ? extends FloatIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableIntCollection>
RflatCollectInt(Function<? super T, ? extends IntIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableLongCollection>
RflatCollectLong(Function<? super T, ? extends LongIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.<R extends MutableShortCollection>
RflatCollectShort(Function<? super T, ? extends ShortIterable> function, R target) Same as flatCollect, only the results are collected into the target collection.voidIterates 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 ObjectIntProceduregetFirst()Should return the same value as peek().getLast()Should not work as it violates the contract of a Stack.getOnly()Returns the element if the iterable has exactly one element.<V> MutableListMultimap<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> MutableListMultimap<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 he 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.inthashCode()Follows the same general contract asList.hashCode(), but for Stacks.booleanhasSameElements(OrderedIterable<T> other) intReturns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.doubleinjectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> doubleObjectToDoubleFunction) 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> floatObjectToFloatFunction) 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> intObjectToIntFunction) 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> longObjectToLongFunction) 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.<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()Returns a string representation of this collection by delegating toRichIterable.makeString(String)and defaulting the separator parameter to the characters", "(comma and space).makeString(String separator) Returns a string representation of this collection by delegating toRichIterable.makeString(String, String, String)and defaulting the start and end parameters to""(the empty String).makeString(String start, String separator, String end) Returns a string representation of this collection with the elements separated by the specified separator and enclosed between the start and end strings.max()Returns the maximum element out of this container based on the natural order, not the order of this container.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, not the order of this container.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.static <T> ArrayStack<T>newStack()static <T> ArrayStack<T>static <T> ArrayStack<T>newStackFromTopToBottom(Iterable<? extends T> items) static <T> ArrayStack<T>newStackFromTopToBottom(T... items) static <T> ArrayStack<T>newStackWith(T... items) 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.partitionWhile(Predicate<? super T> predicate) Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.<P> PartitionMutableStack<T>partitionWith(Predicate2<? super T, ? super P> predicate, P parameter) Filters a collection into a PartitionIterable based on the evaluation of the predicate.peek()Returns the element at the top of the stack, without removing it from the stack.peek(int count) peekAt(int index) Returns the element at a specific index, without removing it from the stack.pop()Removes and returns the top element of the stack.pop(int count) Removes and returns a ListIterable of the number of elements specified by the count, beginning with the top of the stack.<R extends Collection<T>>
Rpop(int count, R targetCollection) Removes and returns a ListIterable of the number of elements specified by the count, beginning with the top of the stack and puts them into the targeted collection type.voidAdds an item to the top of the stack.voidReturns all elements of the source collection that return false when evaluating of the predicate.<R extends Collection<T>>
RSame as the reject method with one parameter but uses the specified target collection for the results.<P> ArrayStack<T>rejectWith(Predicate2<? super T, ? super P> predicate, P parameter) Similar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.<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.Returns all elements of the source collection that return true when evaluating the predicate.<R extends Collection<T>>
RSame as the select method with one parameter but uses the specified target collection for the results.<S> ArrayStack<S>selectInstancesOf(Class<S> clazz) Returns all elements of the source collection that are instances of the Classclazz.<P> ArrayStack<T>selectWith(Predicate2<? super T, ? super P> predicate, P parameter) Similar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.<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> doubleFunction) Returns the final double result of evaluating function for each element of the iterable and adding the results together.doublesumOfFloat(FloatFunction<? super T> floatFunction) Returns the final double result of evaluating function for each element of the iterable and adding the results together.longsumOfInt(IntFunction<? super T> intFunction) Returns the final long result of evaluating function for each element of the iterable and adding the results together.longsumOfLong(LongFunction<? super T> longFunction) Returns the final long result of evaluating function for each element of the iterable and adding the results together.Returns the initial elements that satisfy the Predicate.Executes the Procedure for each element in the iterable and returnsthis.Object[]toArray()Converts this iterable to an array.<T> T[]toArray(T[] 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.<NK,NV> MutableBiMap<NK, NV> toBiMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) Converts the collection to a BiMap implementation using the specified key and value functions.Converts the StackIterable to an immutable implementation.toList()Converts the collection to a MutableList implementation.<NK,NV> MutableMap<NK, NV> Converts the collection to a MutableMap implementation using the specified key and value functions.<NK,NV, R extends Map<NK, NV>>
RtoMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> 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.<V extends Comparable<? super V>>
MutableSortedBag<T>toSortedBagBy(Function<? super T, ? extends V> function) Converts the collection to a MutableSortedBag implementation and sorts it based on the natural order of the attribute returned byfunction.Converts the collection to a MutableList implementation and sorts it using the natural order of the elements.toSortedList(Comparator<? super T> comparator) Converts the collection to a MutableList implementation and sorts it using the specified comparator.<V extends Comparable<? super V>>
MutableList<T>toSortedListBy(Function<? super T, ? extends V> function) Converts the collection to a MutableList implementation and sorts it based on the natural order of the attribute returned byfunction.<NK,NV> MutableSortedMap<NK, NV> toSortedMap(Comparator<? super NK> comparator, Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) Converts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the given comparator.<NK,NV> MutableSortedMap<NK, NV> toSortedMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) Converts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the key elements' natural ordering.<KK extends Comparable<? super KK>,NK, NV>
MutableSortedMap<NK,NV> toSortedMapBy(Function<? super NK, KK> sortBy, Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) Converts the collection to a MutableSortedMap implementation using the specified key and value functions and sorts it based on the natural order of the attribute returned bysortByfunction.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.<V extends Comparable<? super V>>
MutableSortedSet<T>toSortedSetBy(Function<? super T, ? extends V> function) Converts the collection to a MutableSortedSet implementation and sorts it based on the natural order of the attribute returned byfunction.toString()Follows the same rules asAbstractCollection.toString()except it processes the elements in the same order asforEach().void<S> ArrayStack<Pair<T,S>> Returns aOrderedIterableformed from thisOrderedIterableand anotherIterableby combining corresponding elements in pairs.<S,R extends Collection<Pair<T, S>>>
RSame asOrderedIterable.zip(Iterable)but usestargetfor output.Zips thisRichIterablewith its indices.<R extends Collection<Pair<T,Integer>>>
RzipWithIndex(R target) Same asOrderedIterable.zipWithIndex()but usestargetfor output.Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEachMethods inherited from interface java.lang.Iterable
spliteratorMethods inherited from interface org.eclipse.collections.api.stack.MutableStack
aggregateBy, aggregateInPlaceBy, collectWithIndex, countBy, countByEach, countByWith, flatCollectWithMethods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, getFirstOptional, getLastOptional, rejectWithIndex, selectWithIndexMethods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, containsBy, countBy, countByEach, countByWith, flatCollectWith, forEach, getAny, groupByAndCollect, 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, toImmutableSortedSetByMethods inherited from interface org.eclipse.collections.api.stack.StackIterable
toStack
-
Constructor Details
-
ArrayStack
public ArrayStack() -
ArrayStack
public ArrayStack(int initialCapacity) -
ArrayStack
-
ArrayStack
-
-
Method Details
-
newStack
-
newStack
-
newStackWith
-
newStackFromTopToBottom
-
newStackFromTopToBottom
-
push
Description copied from interface:MutableStackAdds an item to the top of the stack.- Specified by:
pushin interfaceMutableStack<T>
-
pop
Description copied from interface:MutableStackRemoves and returns the top element of the stack.- Specified by:
popin interfaceMutableStack<T>
-
pop
Description copied from interface:MutableStackRemoves and returns a ListIterable of the number of elements specified by the count, beginning with the top of the stack.- Specified by:
popin interfaceMutableStack<T>
-
pop
Description copied from interface:MutableStackRemoves and returns a ListIterable of the number of elements specified by the count, beginning with the top of the stack and puts them into the targeted collection type.- Specified by:
popin interfaceMutableStack<T>
-
pop
Description copied from interface:MutableStackRemoves and returns a ListIterable of the number of elements specified by the count, beginning with the top of the stack and puts them into a new stack.- Specified by:
popin interfaceMutableStack<T>
-
clear
public void clear()- Specified by:
clearin interfaceMutableStack<T>
-
peek
Description copied from interface:StackIterableReturns the element at the top of the stack, without removing it from the stack.- Specified by:
peekin interfaceStackIterable<T>- Returns:
- the top of the stack.
-
peek
- Specified by:
peekin interfaceStackIterable<T>- Returns:
- a ListIterable of the number of elements specified by the count, beginning with the top of the stack.
-
peekAt
Description copied from interface:StackIterableReturns the element at a specific index, without removing it from the stack.- Specified by:
peekAtin interfaceStackIterable<T>- Parameters:
index- the location to peek into- Returns:
- the element at the specified index
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceRichIterable<T>
-
isEmpty
public boolean isEmpty()Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceRichIterable<T>
-
notEmpty
public boolean notEmpty()Description copied from interface:RichIterableThe English equivalent of !this.isEmpty()- Specified by:
notEmptyin interfaceRichIterable<T>
-
getFirst
Description copied from interface:StackIterableShould return the same value as peek().- Specified by:
getFirstin interfaceOrderedIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>- Specified by:
getFirstin interfaceStackIterable<T>
-
getLast
Description copied from interface:StackIterableShould not work as it violates the contract of a Stack.- Specified by:
getLastin interfaceOrderedIterable<T>- Specified by:
getLastin interfaceRichIterable<T>- Specified by:
getLastin interfaceStackIterable<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.
-
contains
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfaceRichIterable<T>
-
containsAllIterable
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllIterablein interfaceRichIterable<T>
-
containsAll
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllin interfaceRichIterable<T>- See Also:
-
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>
-
collect
Description copied from interface:RichIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
RichIterable<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName());Example using an anonymous inner class:
RichIterable<String> names = people.collect(new Function<Person, String>() { public String valueOf(Person person) { return person.getFirstName() + " " + person.getLastName(); } });- Specified by:
collectin interfaceMutableStack<T>- Specified by:
collectin interfaceOrderedIterable<T>- Specified by:
collectin interfaceRichIterable<T>- Specified by:
collectin interfaceStackIterable<T>
-
collectBoolean
Description copied from interface:RichIterableReturns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
BooleanIterable licenses = people.collectBoolean(person -> person.hasDrivingLicense());Example using an anonymous inner class:
BooleanIterable licenses = people.collectBoolean(new BooleanFunction<Person>() { public boolean booleanValueOf(Person person) { return person.hasDrivingLicense(); } });- Specified by:
collectBooleanin interfaceMutableStack<T>- Specified by:
collectBooleanin interfaceOrderedIterable<T>- Specified by:
collectBooleanin interfaceRichIterable<T>- Specified by:
collectBooleanin interfaceStackIterable<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
-
flatCollectBoolean
public <R extends MutableBooleanCollection> R flatCollectBoolean(Function<? super T, ? extends BooleanIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectBooleanin 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:
-
collectByte
Description copied from interface:RichIterableReturns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
ByteIterable bytes = people.collectByte(person -> person.getCode());Example using an anonymous inner class:
ByteIterable bytes = people.collectByte(new ByteFunction<Person>() { public byte byteValueOf(Person person) { return person.getCode(); } });- Specified by:
collectBytein interfaceMutableStack<T>- Specified by:
collectBytein interfaceOrderedIterable<T>- Specified by:
collectBytein interfaceRichIterable<T>- Specified by:
collectBytein interfaceStackIterable<T>
-
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
-
flatCollectByte
public <R extends MutableByteCollection> R flatCollectByte(Function<? super T, ? extends ByteIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectBytein 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:
-
collectChar
Description copied from interface:RichIterableReturns a new primitivechariterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
CharIterable chars = people.collectChar(person -> person.getMiddleInitial());Example using an anonymous inner class:
CharIterable chars = people.collectChar(new CharFunction<Person>() { public char charValueOf(Person person) { return person.getMiddleInitial(); } });- Specified by:
collectCharin interfaceMutableStack<T>- Specified by:
collectCharin interfaceOrderedIterable<T>- Specified by:
collectCharin interfaceRichIterable<T>- Specified by:
collectCharin interfaceStackIterable<T>
-
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
-
flatCollectChar
public <R extends MutableCharCollection> R flatCollectChar(Function<? super T, ? extends CharIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectCharin 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:
-
collectDouble
Description copied from interface:RichIterableReturns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
DoubleIterable doubles = people.collectDouble(person -> person.getMilesFromNorthPole());Example using an anonymous inner class:
DoubleIterable doubles = people.collectDouble(new DoubleFunction<Person>() { public double doubleValueOf(Person person) { return person.getMilesFromNorthPole(); } });- Specified by:
collectDoublein interfaceMutableStack<T>- Specified by:
collectDoublein interfaceOrderedIterable<T>- Specified by:
collectDoublein interfaceRichIterable<T>- Specified by:
collectDoublein interfaceStackIterable<T>
-
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
-
flatCollectDouble
public <R extends MutableDoubleCollection> R flatCollectDouble(Function<? super T, ? extends DoubleIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectDoublein 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:
-
collectFloat
Description copied from interface:RichIterableReturns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
FloatIterable floats = people.collectFloat(person -> person.getHeightInInches());Example using an anonymous inner class:
FloatIterable floats = people.collectFloat(new FloatFunction<Person>() { public float floatValueOf(Person person) { return person.getHeightInInches(); } });- Specified by:
collectFloatin interfaceMutableStack<T>- Specified by:
collectFloatin interfaceOrderedIterable<T>- Specified by:
collectFloatin interfaceRichIterable<T>- Specified by:
collectFloatin interfaceStackIterable<T>
-
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
-
flatCollectFloat
public <R extends MutableFloatCollection> R flatCollectFloat(Function<? super T, ? extends FloatIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectFloatin 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:
-
collectInt
Description copied from interface:RichIterableReturns a new primitiveintiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
IntIterable ints = people.collectInt(person -> person.getAge());Example using an anonymous inner class:
IntIterable ints = people.collectInt(new IntFunction<Person>() { public int intValueOf(Person person) { return person.getAge(); } });- Specified by:
collectIntin interfaceMutableStack<T>- Specified by:
collectIntin interfaceOrderedIterable<T>- Specified by:
collectIntin interfaceRichIterable<T>- Specified by:
collectIntin interfaceStackIterable<T>
-
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
-
flatCollectInt
public <R extends MutableIntCollection> R flatCollectInt(Function<? super T, ? extends IntIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectIntin 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:
-
collectLong
Description copied from interface:RichIterableReturns a new primitivelongiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
LongIterable longs = people.collectLong(person -> person.getGuid());Example using an anonymous inner class:
LongIterable longs = people.collectLong(new LongFunction<Person>() { public long longValueOf(Person person) { return person.getGuid(); } });- Specified by:
collectLongin interfaceMutableStack<T>- Specified by:
collectLongin interfaceOrderedIterable<T>- Specified by:
collectLongin interfaceRichIterable<T>- Specified by:
collectLongin interfaceStackIterable<T>
-
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
-
flatCollectLong
public <R extends MutableLongCollection> R flatCollectLong(Function<? super T, ? extends LongIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectLongin 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:
-
collectShort
Description copied from interface:RichIterableReturns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
ShortIterable shorts = people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth());Example using an anonymous inner class:
ShortIterable shorts = people.collectShort(new ShortFunction<Person>() { public short shortValueOf(Person person) { return person.getNumberOfJunkMailItemsReceivedPerMonth(); } });- Specified by:
collectShortin interfaceMutableStack<T>- Specified by:
collectShortin interfaceOrderedIterable<T>- Specified by:
collectShortin interfaceRichIterable<T>- Specified by:
collectShortin interfaceStackIterable<T>
-
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
-
flatCollectShort
public <R extends MutableShortCollection> R flatCollectShort(Function<? super T, ? extends ShortIterable> function, R target) Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectShortin 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:
-
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:
-
collectWith
public <P,V> ArrayStack<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter) Description copied from interface:RichIterableSame asRichIterable.collect(Function)with aFunction2and specified parameter which is passed to the block.Example using a Java 8 lambda expression:
RichIterable<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));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));- Specified by:
collectWithin interfaceMutableStack<T>- Specified by:
collectWithin interfaceOrderedIterable<T>- Specified by:
collectWithin interfaceRichIterable<T>- Specified by:
collectWithin interfaceStackIterable<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:
-
collectIf
public <V> ArrayStack<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function) Description copied from interface:RichIterableReturns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the the optimized equivalent of calling iterable.select(predicate).collect(function).Example using a Java 8 lambda and method reference:
RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString);
Example using Predicates factory:
RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
- Specified by:
collectIfin interfaceMutableStack<T>- Specified by:
collectIfin interfaceOrderedIterable<T>- Specified by:
collectIfin interfaceRichIterable<T>- Specified by:
collectIfin interfaceStackIterable<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:
-
collectWith
public <P,V, R collectWithR extends Collection<V>> (Function2<? super T, ? super P, ? extends V> 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
-
flatCollect
Description copied from interface:RichIterableflatCollectis a special case ofRichIterable.collect(Function). Withcollect, when theFunctionreturns a collection, the result is a collection of collections.flatCollectoutputs a single "flattened" collection instead. This method is commonly called flatMap.Consider the following example where we have a
Personclass, and eachPersonhas a list ofAddressobjects. Take the followingFunction:Function<Person, List<Address>> addressFunction = Person::getAddresses; RichIterable<Person> people = ...;
Usingcollectreturns a collection of collections of addresses.RichIterable<List<Address>> addresses = people.collect(addressFunction);
UsingflatCollectreturns a single flattened list of addresses.RichIterable<Address> addresses = people.flatCollect(addressFunction);
- Specified by:
flatCollectin interfaceMutableStack<T>- Specified by:
flatCollectin interfaceOrderedIterable<T>- Specified by:
flatCollectin interfaceRichIterable<T>- Specified by:
flatCollectin interfaceStackIterable<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:
-
select
Description copied from interface:RichIterableReturns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.Example using a Java 8 lambda expression:
RichIterable<Person> selected = people.select(person -> person.getAddress().getCity().equals("London"));Example using an anonymous inner class:
RichIterable<Person> selected = people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getCity().equals("London"); } });- Specified by:
selectin interfaceMutableStack<T>- Specified by:
selectin interfaceOrderedIterable<T>- Specified by:
selectin interfaceRichIterable<T>- Specified by:
selectin interfaceStackIterable<T>
-
selectWith
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));Example using an anonymous inner class:
RichIterable<Person> selected = people.selectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge()>= age; } }, Integer.valueOf(18));- Specified by:
selectWithin interfaceMutableStack<T>- Specified by:
selectWithin interfaceOrderedIterable<T>- Specified by:
selectWithin interfaceRichIterable<T>- Specified by:
selectWithin interfaceStackIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
-
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:
-
selectInstancesOf
Description copied from interface:RichIterableReturns all elements of the source collection that are instances of the Classclazz.RichIterable<Integer> integers = List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);- Specified by:
selectInstancesOfin interfaceMutableStack<T>- Specified by:
selectInstancesOfin interfaceOrderedIterable<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>- Specified by:
selectInstancesOfin interfaceStackIterable<T>
-
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:
-
reject
Description copied from interface:RichIterableReturns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).Example using a Java 8 lambda expression:
RichIterable<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"));Example using an anonymous inner class:
RichIterable<Person> rejected = people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } });- Specified by:
rejectin interfaceMutableStack<T>- Specified by:
rejectin interfaceOrderedIterable<T>- Specified by:
rejectin interfaceRichIterable<T>- Specified by:
rejectin interfaceStackIterable<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
-
rejectWith
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));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));- Specified by:
rejectWithin interfaceMutableStack<T>- Specified by:
rejectWithin interfaceOrderedIterable<T>- Specified by:
rejectWithin interfaceRichIterable<T>- Specified by:
rejectWithin interfaceStackIterable<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:
-
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>
-
partition
Description copied from interface:RichIterableFilters a collection into a PartitionedIterable based on the evaluation of the predicate.Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partition(person -> person.getAddress().getState().getName().equals("New York"));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"); } });- Specified by:
partitionin interfaceMutableStack<T>- Specified by:
partitionin interfaceOrderedIterable<T>- Specified by:
partitionin interfaceRichIterable<T>- Specified by:
partitionin interfaceStackIterable<T>
-
partitionWith
public <P> PartitionMutableStack<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter) Description copied from interface:RichIterableFilters a collection into a PartitionIterable based on the evaluation of the predicate.Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");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");- Specified by:
partitionWithin interfaceMutableStack<T>- Specified by:
partitionWithin interfaceOrderedIterable<T>- Specified by:
partitionWithin interfaceRichIterable<T>- Specified by:
partitionWithin interfaceStackIterable<T>
-
zip
Description copied from interface:OrderedIterableReturns aOrderedIterableformed from thisOrderedIterableand anotherIterableby combining corresponding elements in pairs. The secondIterableshould also be ordered. If one of the twoIterables is longer than the other, its remaining elements are ignored.- Specified by:
zipin interfaceMutableStack<T>- Specified by:
zipin interfaceOrderedIterable<T>- Specified by:
zipin interfaceRichIterable<T>- Specified by:
zipin interfaceStackIterable<T>- Type Parameters:
S- the type of the second half of the returned pairs- Parameters:
that- TheIterableproviding the second half of each result pair- Returns:
- A new
OrderedIterablecontaining pairs consisting of corresponding elements of thisOrderedIterableand that. The length of the returnedOrderedIterableis the minimum of the lengths of thisOrderedIterableand that.
-
zip
Description copied from interface:OrderedIterableSame asOrderedIterable.zip(Iterable)but usestargetfor output.- Specified by:
zipin interfaceOrderedIterable<T>- Specified by:
zipin interfaceRichIterable<T>
-
zipWithIndex
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceMutableStack<T>- Specified by:
zipWithIndexin interfaceOrderedIterable<T>- Specified by:
zipWithIndexin interfaceRichIterable<T>- Specified by:
zipWithIndexin interfaceStackIterable<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:OrderedIterableSame asOrderedIterable.zipWithIndex()but usestargetfor output.- Specified by:
zipWithIndexin interfaceOrderedIterable<T>- Specified by:
zipWithIndexin 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>
-
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>
-
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>
-
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>
-
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>
-
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>
-
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>
-
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>
-
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
public long injectInto(long injectedValue, LongObjectToLongFunction<? super T> longObjectToLongFunction) 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
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> doubleObjectToDoubleFunction) 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
public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super T> floatObjectToFloatFunction) 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 interfaceMutableStack<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 interfaceMutableStack<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 interfaceMutableStack<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 interfaceMutableStack<T>- Specified by:
sumByDoublein interfaceRichIterable<T>
-
max
Description copied from interface:OrderedIterableReturns the maximum element out of this container based on the natural order, not the order of this container. If you want the maximum element based on the order of this container, useOrderedIterable.getLast().- Specified by:
maxin interfaceOrderedIterable<T>- Specified by:
maxin interfaceRichIterable<T>
-
max
Description copied from interface:RichIterableReturns the maximum element out of this container based on the comparator.- Specified by:
maxin 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>
-
min
Description copied from interface:OrderedIterableReturns the minimum element out of this container based on the natural order, not the order of this container. If you want the minimum element based on the order of this container, useOrderedIterable.getFirst().- Specified by:
minin interfaceOrderedIterable<T>- Specified by:
minin interfaceRichIterable<T>
-
min
Description copied from interface:RichIterableReturns the minimum element out of this container based on the comparator.- Specified by:
minin 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>
-
makeString
Description copied from interface:RichIterableReturns a string representation of this collection by delegating toRichIterable.makeString(String)and defaulting the separator parameter to the characters", "(comma and space).- Specified by:
makeStringin interfaceRichIterable<T>- Returns:
- a string representation of this collection.
-
makeString
Description copied from interface:RichIterableReturns a string representation of this collection by delegating toRichIterable.makeString(String, String, String)and defaulting the start and end parameters to""(the empty String).- Specified by:
makeStringin interfaceRichIterable<T>- Returns:
- a string representation of this collection.
-
makeString
Description copied from interface:RichIterableReturns a string representation of this collection with the elements separated by the specified separator and enclosed between the start and end strings.- Specified by:
makeStringin interfaceRichIterable<T>- Returns:
- a string representation of this collection.
-
appendString
Description copied from interface:RichIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byRichIterable.makeString().- Specified by:
appendStringin interfaceRichIterable<T>
-
appendString
Description copied from interface:RichIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byRichIterable.makeString(String).- Specified by:
appendStringin interfaceRichIterable<T>
-
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:RichIterableFor each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.Example using a Java 8 method reference:
Multimap<String, Person> peopleByLastName = people.groupBy(Person::getLastName);Example using an anonymous inner class:
Multimap<String, Person> peopleByLastName = people.groupBy(new Function<Person, String>() { public String valueOf(Person person) { return person.getLastName(); } });- Specified by:
groupByin interfaceMutableStack<T>- Specified by:
groupByin interfaceOrderedIterable<T>- Specified by:
groupByin interfaceRichIterable<T>- Specified by:
groupByin interfaceStackIterable<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 interfaceMutableStack<T>- Specified by:
groupByEachin interfaceOrderedIterable<T>- Specified by:
groupByEachin interfaceRichIterable<T>- Specified by:
groupByEachin interfaceStackIterable<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 he 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 interfaceMutableStack<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:
-
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.
-
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 interfaceMutableStack<T>- Specified by:
tapin interfaceOrderedIterable<T>- Specified by:
tapin interfaceRichIterable<T>- Specified by:
tapin interfaceStackIterable<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:
-
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>
-
forEachWithIndex
Description copied from interface:OrderedIterableIterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProceduree.g. 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>
-
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 natural order of the elements.- Specified by:
toSortedListin 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>
-
toSortedListBy
public <V extends Comparable<? super V>> MutableList<T> toSortedListBy(Function<? super T, ? extends V> function) Description copied from interface:RichIterableConverts the collection to a MutableList implementation and sorts it based on the natural order of the attribute returned byfunction.- Specified by:
toSortedListByin interfaceRichIterable<T>
-
toSet
Description copied from interface:RichIterableConverts the collection to a MutableSet implementation.- Specified by:
toSetin 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>
-
toImmutable
Description copied from interface:StackIterableConverts the StackIterable to an immutable implementation. Returns this for immutable stacks.- Specified by:
toImmutablein interfaceStackIterable<T>
-
toSortedSetBy
public <V extends Comparable<? super V>> MutableSortedSet<T> toSortedSetBy(Function<? super T, ? extends V> function) Description copied from interface:RichIterableConverts the collection to a MutableSortedSet implementation and sorts it based on the natural order of the attribute returned byfunction.- Specified by:
toSortedSetByin 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>
-
toSortedBagBy
public <V extends Comparable<? super V>> MutableSortedBag<T> toSortedBagBy(Function<? super T, ? extends V> function) Description copied from interface:RichIterableConverts the collection to a MutableSortedBag implementation and sorts it based on the natural order of the attribute returned byfunction.- Specified by:
toSortedBagByin interfaceRichIterable<T>
-
toMap
public <NK,NV> MutableMap<NK,NV> toMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> 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 <NK,NV, R toMapR extends Map<NK, NV>> (Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> 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 <NK,NV> MutableSortedMap<NK,NV> toSortedMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> 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 <NK,NV> MutableSortedMap<NK,NV> toSortedMap(Comparator<? super NK> comparator, Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> 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>
-
toSortedMapBy
public <KK extends Comparable<? super KK>,NK, MutableSortedMap<NK,NV> NV> toSortedMapBy(Function<? super NK, KK> sortBy, Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) Description copied from interface:RichIterableConverts the collection to a MutableSortedMap implementation using the specified key and value functions and sorts it based on the natural order of the attribute returned bysortByfunction.- Specified by:
toSortedMapByin interfaceRichIterable<T>
-
toBiMap
public <NK,NV> MutableBiMap<NK,NV> toBiMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> 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>
-
asUnmodifiable
- Specified by:
asUnmodifiablein interfaceMutableStack<T>
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableStack<T>
-
toArray
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfaceRichIterable<T>- See Also:
-
toArray
public <T> T[] toArray(T[] 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 interfaceRichIterable<T>- See Also:
-
iterator
-
equals
Description copied from interface:StackIterableFollows the same general contract asList.equals(Object), but for Stacks.- Specified by:
equalsin interfaceStackIterable<T>- Overrides:
equalsin classObject
-
toString
Description copied from interface:StackIterableFollows the same rules asAbstractCollection.toString()except it processes the elements in the same order asforEach().Assert.assertEquals("[3, 2, 1]", Stacks.mutable.with(1, 2, 3).toString());- Specified by:
toStringin interfaceRichIterable<T>- Specified by:
toStringin interfaceStackIterable<T>- Overrides:
toStringin classObject- Returns:
- a string representation of this RichIterable
- See Also:
-
hashCode
public int hashCode()Description copied from interface:StackIterableFollows the same general contract asList.hashCode(), but for Stacks.- Specified by:
hashCodein interfaceStackIterable<T>- Overrides:
hashCodein classObject
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
takeWhile
Description copied from interface:OrderedIterableReturns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.- Specified by:
takeWhilein interfaceMutableStack<T>- Specified by:
takeWhilein interfaceOrderedIterable<T>- Specified by:
takeWhilein interfaceStackIterable<T>
-
dropWhile
Description copied from interface:OrderedIterableReturns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.- Specified by:
dropWhilein interfaceMutableStack<T>- Specified by:
dropWhilein interfaceOrderedIterable<T>- Specified by:
dropWhilein interfaceStackIterable<T>
-
partitionWhile
Description copied from interface:OrderedIterableReturns a Partition of the initial elements that satisfy the Predicate and the remaining elements. Short circuits at the first element which does satisfy the Predicate.- Specified by:
partitionWhilein interfaceMutableStack<T>- Specified by:
partitionWhilein interfaceOrderedIterable<T>- Specified by:
partitionWhilein interfaceStackIterable<T>
-
distinct
Description copied from interface:OrderedIterableReturns a newOrderedIterablecontaining the distinct elements in this iterable.Conceptually similar to
RichIterable.toSet().RichIterable.toList()but retains the original order. If an element appears multiple times in this iterable, the first one will be copied into the result.- Specified by:
distinctin interfaceMutableStack<T>- Specified by:
distinctin interfaceOrderedIterable<T>- Specified by:
distinctin interfaceStackIterable<T>- Returns:
OrderedIterableof distinct elements
-
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 interfaceOrderedIterable<T>- See Also:
-
corresponds
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>
-
hasSameElements
-
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>
-
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>
-
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>
-