Class ImmutableNotEmptyStack<T>
- All Implemented Interfaces:
Serializable, Iterable<T>, InternalIterable<T>, OrderedIterable<T>, RichIterable<T>, ImmutableStack<T>, StackIterable<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Tprivate final ImmutableStack<T> private static final longprivate final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckNegativeCount(int count) private voidcheckSizeLessThanCount(int count) private voidcheckSizeLessThanOrEqualToIndex(int index) private booleancheckZeroCount(int count) chunk(int size) Partitions elements in fixed size chunks.<V> ImmutableStack<V> Returns a new collection with the results of applying the specified function on each element of the source collection.collectBoolean(BooleanFunction<? super T> function) Returns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection.collectByte(ByteFunction<? super T> function) Returns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection.collectChar(CharFunction<? super T> function) Returns a new primitivechariterable with the results of applying the specified function on each element of the source collection.collectDouble(DoubleFunction<? super T> function) Returns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection.collectFloat(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> 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.collectInt(IntFunction<? super T> function) Returns a new primitiveintiterable with the results of applying the specified function on each element of the source collection.collectLong(LongFunction<? super T> function) Returns a new primitivelongiterable with the results of applying the specified function on each element of the source collection.collectShort(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 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.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> ImmutableStack<V> flatCollect(Function<? super T, ? extends Iterable<V>> function) flatCollectis a special case ofRichIterable.collect(Function).voidIterates 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.getFirst()Returns the first element of an iterable.getLast()Returns the last element of an iterable.<V> ImmutableListMultimap<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> ImmutableListMultimap<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> 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.iterator()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> PartitionImmutableStack<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) Pair<T, ImmutableStack<T>> Pair<ListIterable<T>, ImmutableStack<T>> peekAndPop(int count) peekAt(int index) Returns the element at a specific index, without removing it from the stack.pop()pop(int count) 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.Returns all elements of the source collection that return true when evaluating the predicate.<S> ImmutableStack<S> selectInstancesOf(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()Returns the number of items in this iterable.<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.Returns the initial elements that satisfy the Predicate.Executes the Procedure for each element in the iterable and returnsthis.Converts the StackIterable to an immutable implementation.private Object<S> ImmutableStack<Pair<T, S>> Returns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs.Zips thisRichIterablewith its indices.Methods inherited from class 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, zipWithIndexMethods inherited from interface ImmutableStack
aggregateBy, aggregateInPlaceBy, collectWithIndex, countBy, countByWith, flatCollectWith, reduceByMethods inherited from interface InternalIterable
forEach, forEachWithMethods inherited from interface Iterable
spliteratorMethods inherited from interface OrderedIterable
collectWithIndex, forEachWithIndex, getFirstOptional, getLastOptional, indexOf, max, min, rejectWithIndex, selectWithIndex, zip, zipWithIndexMethods inherited from interface 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, toSortedSetByMethods inherited from interface StackIterable
toStack, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
element
-
next
-
size
private final int size
-
-
Constructor Details
-
ImmutableNotEmptyStack
ImmutableNotEmptyStack(T element, ImmutableStack<T> next)
-
-
Method Details
-
push
- Specified by:
pushin interfaceImmutableStack<T>
-
pop
- Specified by:
popin interfaceImmutableStack<T>
-
pop
- Specified by:
popin interfaceImmutableStack<T>
-
peekAndPop
- Specified by:
peekAndPopin interfaceImmutableStack<T>
-
peekAndPop
- Specified by:
peekAndPopin interfaceImmutableStack<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.
-
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
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
Description copied from interface:RichIterableReturns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
- Specified by:
getFirstin interfaceOrderedIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>- Specified by:
getFirstin interfaceStackIterable<T>
-
getLast
Description copied from interface:RichIterableReturns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
- Specified by:
getLastin interfaceOrderedIterable<T>- Specified by:
getLastin interfaceRichIterable<T>- Specified by:
getLastin interfaceStackIterable<T>
-
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"));- Specified by:
selectin interfaceImmutableStack<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));- 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:
-
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"));- 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
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:
-
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"));- 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
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
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
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
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
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
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
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
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
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
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:
-
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
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
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 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
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:
-
zip
Description copied from interface:RichIterableReturns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs. If one of the twoRichIterables is longer than the other, its remaining elements are ignored.- Specified by:
zipin 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- TheRichIterableproviding the second half of each result pair- Returns:
- A new
RichIterablecontaining pairs consisting of corresponding elements of thisRichIterableand that. The length of the returnedRichIterableis the minimum of the lengths of thisRichIterableand that.
-
zipWithIndex
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:
-
toImmutable
Description copied from interface:StackIterableConverts the StackIterable to an immutable implementation. Returns this for immutable stacks.- Specified by:
toImmutablein interfaceStackIterable<T>
-
chunk
Description copied from interface:RichIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceRichIterable<T>- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingRichIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
countByEach
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:RichIterableReturns the number of items in this iterable.- 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
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:
-
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()));
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:
-
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 interfaceImmutableStack<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 interfaceImmutableStack<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 interfaceImmutableStack<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 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
-
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<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
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
-
equals
Description copied from interface:StackIterableFollows the same general contract asList.equals(Object), but for Stacks.- Specified by:
equalsin interfaceStackIterable<T>- Overrides:
equalsin classObject
-
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
-
writeReplace
-