Class ImmutableNotEmptyStack<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.stack.immutable.ImmutableNotEmptyStack<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<T>,InternalIterable<T>,OrderedIterable<T>,RichIterable<T>,ImmutableStack<T>,StackIterable<T>
final class ImmutableNotEmptyStack<T> extends AbstractRichIterable<T> implements ImmutableStack<T>, java.io.Serializable
-
-
Field Summary
Fields Modifier and Type Field Description private Telementprivate ImmutableStack<T>nextprivate static longserialVersionUIDprivate intsize
-
Constructor Summary
Constructors Constructor Description ImmutableNotEmptyStack(T element, ImmutableStack<T> next)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckNegativeCount(int count)private voidcheckSizeLessThanCount(int count)private voidcheckSizeLessThanOrEqualToIndex(int index)private booleancheckZeroCount(int count)RichIterable<RichIterable<T>>chunk(int size)Partitions elements in fixed size chunks.<V> ImmutableStack<V>collect(Function<? super T,? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.ImmutableBooleanStackcollectBoolean(BooleanFunction<? super T> function)Returns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection.ImmutableByteStackcollectByte(ByteFunction<? super T> function)Returns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection.ImmutableCharStackcollectChar(CharFunction<? super T> function)Returns a new primitivechariterable with the results of applying the specified function on each element of the source collection.ImmutableDoubleStackcollectDouble(DoubleFunction<? super T> function)Returns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection.ImmutableFloatStackcollectFloat(FloatFunction<? super T> function)Returns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection.<V> ImmutableStack<V>collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.ImmutableIntStackcollectInt(IntFunction<? super T> function)Returns a new primitiveintiterable with the results of applying the specified function on each element of the source collection.ImmutableLongStackcollectLong(LongFunction<? super T> function)Returns a new primitivelongiterable with the results of applying the specified function on each element of the source collection.ImmutableShortStackcollectShort(ShortFunction<? super T> function)Returns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection.<P,V>
ImmutableStack<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.<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.<V> ImmutableBag<V>countByEach(Function<? super T,? extends java.lang.Iterable<V>> function)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.intdetectIndex(Predicate<? super T> predicate)Returns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true.ImmutableStack<T>distinct()Returns a newOrderedIterablecontaining the distinct elements in this iterable.ImmutableStack<T>dropWhile(Predicate<? super T> predicate)Returns the final elements that do not satisfy the Predicate.voideach(Procedure<? super T> procedure)The procedure is executed for each element in the iterable.booleanequals(java.lang.Object o)Follows the same general contract asList.equals(Object), but for Stacks.<V> ImmutableStack<V>flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)flatCollectis a special case ofRichIterable.collect(Function).voidforEach(int startIndex, int endIndex, Procedure<? super T> procedure)Iterates over the section of the iterable covered by the specified inclusive indexes.voidforEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the section of the iterable covered by the specified inclusive indexes.TgetFirst()Should return the same value as peek().TgetLast()Should not work as it violates the contract of a Stack.<V> ImmutableListMultimap<V,T>groupBy(Function<? super T,? extends V> function)For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.<V> ImmutableListMultimap<V,T>groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function)Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.<V> ImmutableMap<V,T>groupByUniqueKey(Function<? super T,? extends V> function)For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key.inthashCode()Follows the same general contract asList.hashCode(), but for Stacks.booleanhasSameElements(OrderedIterable<T> other)booleanisEmpty()Returns true if this iterable has zero items.java.util.Iterator<T>iterator()booleannotEmpty()The English equivalent of !this.isEmpty()PartitionImmutableStack<T>partition(Predicate<? super T> predicate)Filters a collection into a PartitionedIterable based on the evaluation of the predicate.PartitionImmutableStack<T>partitionWhile(Predicate<? super T> predicate)Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.<P> PartitionImmutableStack<T>partitionWith(Predicate2<? super T,? super P> predicate, P parameter)Filters a collection into a PartitionIterable based on the evaluation of the predicate.Tpeek()Returns the element at the top of the stack, without removing it from the stack.ListIterable<T>peek(int count)Pair<T,ImmutableStack<T>>peekAndPop()Pair<ListIterable<T>,ImmutableStack<T>>peekAndPop(int count)TpeekAt(int index)Returns the element at a specific index, without removing it from the stack.ImmutableStack<T>pop()ImmutableStack<T>pop(int count)ImmutableStack<T>push(T item)ImmutableStack<T>reject(Predicate<? super T> predicate)Returns all elements of the source collection that return false when evaluating of the predicate.<P> ImmutableStack<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.ImmutableStack<T>select(Predicate<? super T> predicate)Returns all elements of the source collection that return true when evaluating the predicate.<S> ImmutableStack<S>selectInstancesOf(java.lang.Class<S> clazz)Returns all elements of the source collection that are instances of the Classclazz.<P> ImmutableStack<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.intsize()Size takes linear time on ImmutableStacks.<V> ImmutableObjectDoubleMap<V>sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ImmutableObjectDoubleMap<V>sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ImmutableObjectLongMap<V>sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ImmutableObjectLongMap<V>sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)Groups and sums the values using the two specified functions.ImmutableStack<T>takeWhile(Predicate<? super T> predicate)Returns the initial elements that satisfy the Predicate.ImmutableStack<T>tap(Procedure<? super T> procedure)Executes the Procedure for each element in the iterable and returnsthis.ImmutableStack<T>toImmutable()Converts the StackIterable to an immutable implementation.private java.lang.ObjectwriteReplace()<S> ImmutableStack<Pair<T,S>>zip(java.lang.Iterable<S> that)Returns aOrderedIterableformed from thisOrderedIterableand anotherIterableby combining corresponding elements in pairs.ImmutableStack<Pair<T,java.lang.Integer>>zipWithIndex()Zips thisRichIterablewith its indices.-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asLazy, collect, collectIf, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, forEachWith, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.stack.ImmutableStack
aggregateBy, aggregateInPlaceBy, collectWithIndex, countBy, countByWith, flatCollectWith, reduceBy
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, forEachWithIndex, getFirstOptional, getLastOptional, indexOf, max, min, rejectWithIndex, selectWithIndex, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, reduce, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy
-
Methods inherited from interface org.eclipse.collections.api.stack.StackIterable
toStack, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
element
private final T element
-
next
private final ImmutableStack<T> next
-
size
private final int size
-
-
Constructor Detail
-
ImmutableNotEmptyStack
ImmutableNotEmptyStack(T element, ImmutableStack<T> next)
-
-
Method Detail
-
push
public ImmutableStack<T> push(T item)
- Specified by:
pushin interfaceImmutableStack<T>
-
pop
public ImmutableStack<T> pop()
- Specified by:
popin interfaceImmutableStack<T>
-
pop
public ImmutableStack<T> pop(int count)
- Specified by:
popin interfaceImmutableStack<T>
-
peekAndPop
public Pair<T,ImmutableStack<T>> peekAndPop()
- Specified by:
peekAndPopin interfaceImmutableStack<T>
-
peekAndPop
public Pair<ListIterable<T>,ImmutableStack<T>> peekAndPop(int count)
- Specified by:
peekAndPopin interfaceImmutableStack<T>
-
peek
public 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
public ListIterable<T> peek(int count)
- Specified by:
peekin interfaceStackIterable<T>- Returns:
- a ListIterable of the number of elements specified by the count, beginning with the top of the stack.
-
checkZeroCount
private boolean checkZeroCount(int count)
-
checkSizeLessThanCount
private void checkSizeLessThanCount(int count)
-
checkSizeLessThanOrEqualToIndex
private void checkSizeLessThanOrEqualToIndex(int index)
-
checkNegativeCount
private void checkNegativeCount(int count)
-
peekAt
public T peekAt(int index)
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
-
getFirst
public 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
public 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>
-
select
public ImmutableStack<T> select(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.Example using a Java 8 lambda expression:
RichIterable<Person> selected = people.select(person -> person.getAddress().getCity().equals("London"));- Specified by:
selectin interfaceImmutableStack<T>- Specified by:
selectin interfaceOrderedIterable<T>- Specified by:
selectin interfaceRichIterable<T>- Specified by:
selectin interfaceStackIterable<T>
-
selectWith
public <P> ImmutableStack<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));- Specified by:
selectWithin interfaceImmutableStack<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:
RichIterable.select(Predicate)
-
reject
public ImmutableStack<T> reject(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).Example using a Java 8 lambda expression:
RichIterable<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"));- Specified by:
rejectin interfaceImmutableStack<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
-
rejectWith
public <P> ImmutableStack<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));- Specified by:
rejectWithin interfaceImmutableStack<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:
RichIterable.select(Predicate)
-
partition
public PartitionImmutableStack<T> partition(Predicate<? super T> predicate)
Description copied from interface:RichIterableFilters a collection into a PartitionedIterable based on the evaluation of the predicate.Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partition(person -> person.getAddress().getState().getName().equals("New York"));- Specified by:
partitionin interfaceImmutableStack<T>- Specified by:
partitionin interfaceOrderedIterable<T>- Specified by:
partitionin interfaceRichIterable<T>- Specified by:
partitionin interfaceStackIterable<T>
-
partitionWith
public <P> PartitionImmutableStack<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableFilters a collection into a PartitionIterable based on the evaluation of the predicate.Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers = people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");- Specified by:
partitionWithin interfaceImmutableStack<T>- Specified by:
partitionWithin interfaceOrderedIterable<T>- Specified by:
partitionWithin interfaceRichIterable<T>- Specified by:
partitionWithin interfaceStackIterable<T>
-
selectInstancesOf
public <S> ImmutableStack<S> selectInstancesOf(java.lang.Class<S> clazz)
Description copied from interface:RichIterableReturns all elements of the source collection that are instances of the Classclazz.RichIterable<Integer> integers = List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);- Specified by:
selectInstancesOfin interfaceImmutableStack<T>- Specified by:
selectInstancesOfin interfaceOrderedIterable<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>- Specified by:
selectInstancesOfin interfaceStackIterable<T>
-
collect
public <V> ImmutableStack<V> collect(Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
RichIterable<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName());- Specified by:
collectin interfaceImmutableStack<T>- Specified by:
collectin interfaceOrderedIterable<T>- Specified by:
collectin interfaceRichIterable<T>- Specified by:
collectin interfaceStackIterable<T>
-
collectBoolean
public ImmutableBooleanStack collectBoolean(BooleanFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
BooleanIterable licenses = people.collectBoolean(person -> person.hasDrivingLicense());- Specified by:
collectBooleanin interfaceImmutableStack<T>- Specified by:
collectBooleanin interfaceOrderedIterable<T>- Specified by:
collectBooleanin interfaceRichIterable<T>- Specified by:
collectBooleanin interfaceStackIterable<T>
-
collectByte
public ImmutableByteStack collectByte(ByteFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
ByteIterable bytes = people.collectByte(person -> person.getCode());- Specified by:
collectBytein interfaceImmutableStack<T>- Specified by:
collectBytein interfaceOrderedIterable<T>- Specified by:
collectBytein interfaceRichIterable<T>- Specified by:
collectBytein interfaceStackIterable<T>
-
collectChar
public ImmutableCharStack collectChar(CharFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitivechariterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
CharIterable chars = people.collectChar(person -> person.getMiddleInitial());- Specified by:
collectCharin interfaceImmutableStack<T>- Specified by:
collectCharin interfaceOrderedIterable<T>- Specified by:
collectCharin interfaceRichIterable<T>- Specified by:
collectCharin interfaceStackIterable<T>
-
collectDouble
public ImmutableDoubleStack collectDouble(DoubleFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
DoubleIterable doubles = people.collectDouble(person -> person.getMilesFromNorthPole());- Specified by:
collectDoublein interfaceImmutableStack<T>- Specified by:
collectDoublein interfaceOrderedIterable<T>- Specified by:
collectDoublein interfaceRichIterable<T>- Specified by:
collectDoublein interfaceStackIterable<T>
-
collectFloat
public ImmutableFloatStack collectFloat(FloatFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
FloatIterable floats = people.collectFloat(person -> person.getHeightInInches());- Specified by:
collectFloatin interfaceImmutableStack<T>- Specified by:
collectFloatin interfaceOrderedIterable<T>- Specified by:
collectFloatin interfaceRichIterable<T>- Specified by:
collectFloatin interfaceStackIterable<T>
-
collectInt
public ImmutableIntStack collectInt(IntFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitiveintiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
IntIterable ints = people.collectInt(person -> person.getAge());- Specified by:
collectIntin interfaceImmutableStack<T>- Specified by:
collectIntin interfaceOrderedIterable<T>- Specified by:
collectIntin interfaceRichIterable<T>- Specified by:
collectIntin interfaceStackIterable<T>
-
collectLong
public ImmutableLongStack collectLong(LongFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitivelongiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
LongIterable longs = people.collectLong(person -> person.getGuid());- Specified by:
collectLongin interfaceImmutableStack<T>- Specified by:
collectLongin interfaceOrderedIterable<T>- Specified by:
collectLongin interfaceRichIterable<T>- Specified by:
collectLongin interfaceStackIterable<T>
-
collectShort
public ImmutableShortStack collectShort(ShortFunction<? super T> function)
Description copied from interface:RichIterableReturns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
ShortIterable shorts = people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth());- Specified by:
collectShortin interfaceImmutableStack<T>- Specified by:
collectShortin interfaceOrderedIterable<T>- Specified by:
collectShortin interfaceRichIterable<T>- Specified by:
collectShortin interfaceStackIterable<T>
-
collectWith
public <P,V> ImmutableStack<V> collectWith(Function2<? super T,? super P,? extends V> function, P parameter)
Description copied from interface:RichIterableSame asRichIterable.collect(Function)with aFunction2and specified parameter which is passed to the block.Example using a Java 8 lambda expression:
RichIterable<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));- Specified by:
collectWithin interfaceImmutableStack<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:
RichIterable.collect(Function)
-
collectIf
public <V> ImmutableStack<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the optimized equivalent of calling iterable.select(predicate).collect(function).Example using a Java 8 lambda and method reference:
RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString);
Example using Predicates factory:
RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
- Specified by:
collectIfin interfaceImmutableStack<T>- Specified by:
collectIfin interfaceOrderedIterable<T>- Specified by:
collectIfin interfaceRichIterable<T>- Specified by:
collectIfin interfaceStackIterable<T>
-
flatCollect
public <V> ImmutableStack<V> flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)
Description copied from interface:RichIterableflatCollectis a special case ofRichIterable.collect(Function). Withcollect, when theFunctionreturns a collection, the result is a collection of collections.flatCollectoutputs a single "flattened" collection instead. This method is commonly called flatMap.Consider the following example where we have a
Personclass, and eachPersonhas a list ofAddressobjects. Take the followingFunction:Function<Person, List<Address>> addressFunction = Person::getAddresses; RichIterable<Person> people = ...;
Usingcollectreturns a collection of collections of addresses.RichIterable<List<Address>> addresses = people.collect(addressFunction);
UsingflatCollectreturns a single flattened list of addresses.RichIterable<Address> addresses = people.flatCollect(addressFunction);
- Specified by:
flatCollectin interfaceImmutableStack<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
-
sumByInt
public <V> ImmutableObjectLongMap<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 interfaceImmutableStack<T>- Specified by:
sumByIntin interfaceRichIterable<T>
-
sumByFloat
public <V> ImmutableObjectDoubleMap<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 interfaceImmutableStack<T>- Specified by:
sumByFloatin interfaceRichIterable<T>
-
sumByLong
public <V> ImmutableObjectLongMap<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 interfaceImmutableStack<T>- Specified by:
sumByLongin interfaceRichIterable<T>
-
sumByDouble
public <V> ImmutableObjectDoubleMap<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 interfaceImmutableStack<T>- Specified by:
sumByDoublein interfaceRichIterable<T>
-
groupBy
public <V> ImmutableListMultimap<V,T> groupBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableFor each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.Example using a Java 8 method reference:
Multimap<String, Person> peopleByLastName = people.groupBy(Person::getLastName);- Specified by:
groupByin interfaceImmutableStack<T>- Specified by:
groupByin interfaceOrderedIterable<T>- Specified by:
groupByin interfaceRichIterable<T>- Specified by:
groupByin interfaceStackIterable<T>
-
groupByEach
public <V> ImmutableListMultimap<V,T> groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function)
Description copied from interface:RichIterableSimilar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.- Specified by:
groupByEachin interfaceImmutableStack<T>- Specified by:
groupByEachin interfaceOrderedIterable<T>- Specified by:
groupByEachin interfaceRichIterable<T>- Specified by:
groupByEachin interfaceStackIterable<T>
-
groupByUniqueKey
public <V> ImmutableMap<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
Description copied from interface:RichIterableFor each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key. The generated keys must each be unique, or else an exception is thrown.- Specified by:
groupByUniqueKeyin interfaceImmutableStack<T>- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>- See Also:
RichIterable.groupBy(Function)
-
zip
public <S> ImmutableStack<Pair<T,S>> zip(java.lang.Iterable<S> that)
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 interfaceImmutableStack<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.
-
zipWithIndex
public ImmutableStack<Pair<T,java.lang.Integer>> zipWithIndex()
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceImmutableStack<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:
RichIterable.zip(Iterable)
-
toImmutable
public ImmutableStack<T> toImmutable()
Description copied from interface:StackIterableConverts the StackIterable to an immutable implementation. Returns this for immutable stacks.- Specified by:
toImmutablein interfaceStackIterable<T>
-
chunk
public RichIterable<RichIterable<T>> chunk(int size)
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.
-
countByEach
public <V> ImmutableBag<V> countByEach(Function<? super T,? extends java.lang.Iterable<V>> function)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByEachin interfaceImmutableStack<T>- Specified by:
countByEachin interfaceRichIterable<T>- Overrides:
countByEachin classAbstractRichIterable<T>
-
size
public int size()
Description copied from interface:ImmutableStackSize takes linear time on ImmutableStacks.- Specified by:
sizein interfaceImmutableStack<T>- Specified by:
sizein interfaceRichIterable<T>
-
isEmpty
public boolean isEmpty()
Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceRichIterable<T>- Overrides:
isEmptyin classAbstractRichIterable<T>
-
notEmpty
public boolean notEmpty()
Description copied from interface:RichIterableThe English equivalent of !this.isEmpty()- Specified by:
notEmptyin interfaceRichIterable<T>
-
tap
public ImmutableStack<T> tap(Procedure<? super T> procedure)
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceImmutableStack<T>- Specified by:
tapin interfaceOrderedIterable<T>- Specified by:
tapin interfaceRichIterable<T>- Specified by:
tapin interfaceStackIterable<T>- See Also:
RichIterable.each(Procedure),RichIterable.forEach(Procedure)
-
each
public void each(Procedure<? super T> procedure)
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()));
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:
InternalIterable.forEach(Procedure),Iterable.forEach(java.util.function.Consumer)
-
takeWhile
public ImmutableStack<T> takeWhile(Predicate<? super T> predicate)
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 interfaceImmutableStack<T>- Specified by:
takeWhilein interfaceOrderedIterable<T>- Specified by:
takeWhilein interfaceStackIterable<T>
-
dropWhile
public ImmutableStack<T> dropWhile(Predicate<? super T> predicate)
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 interfaceImmutableStack<T>- Specified by:
dropWhilein interfaceOrderedIterable<T>- Specified by:
dropWhilein interfaceStackIterable<T>
-
partitionWhile
public PartitionImmutableStack<T> partitionWhile(Predicate<? super T> predicate)
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 interfaceImmutableStack<T>- Specified by:
partitionWhilein interfaceOrderedIterable<T>- Specified by:
partitionWhilein interfaceStackIterable<T>
-
distinct
public ImmutableStack<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 interfaceImmutableStack<T>- Specified by:
distinctin interfaceOrderedIterable<T>- Specified by:
distinctin interfaceStackIterable<T>- Returns:
OrderedIterableof distinct elements
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)
Description copied from interface:OrderedIterableReturns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother. Thepredicateis evaluated for each element at the same position of eachOrderedIterablein a forward iteration order. This is a short circuit pattern.- Specified by:
correspondsin interfaceOrderedIterable<T>
-
hasSameElements
public boolean hasSameElements(OrderedIterable<T> other)
-
forEach
public void forEach(int startIndex, int endIndex, Procedure<? super T> procedure)Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<Person> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, person -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachin interfaceOrderedIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEachWithIndex(0, 1, (person, index) -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>
-
detectIndex
public int detectIndex(Predicate<? super T> predicate)
Description copied from interface:OrderedIterableReturns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true. Returns -1 if no element evaluates true for thepredicate.- Specified by:
detectIndexin interfaceOrderedIterable<T>
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T>
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:StackIterableFollows the same general contract asList.equals(Object), but for Stacks.- Specified by:
equalsin interfaceStackIterable<T>- Overrides:
equalsin classjava.lang.Object
-
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 classjava.lang.Object
-
writeReplace
private java.lang.Object writeReplace()
-
-