Class ImmutableArrayList<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection<T>
-
- org.eclipse.collections.impl.list.immutable.AbstractImmutableList<T>
-
- org.eclipse.collections.impl.list.immutable.ImmutableArrayList<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<T>,java.util.Collection<T>,java.util.List<T>,java.util.RandomAccess,ImmutableCollection<T>,InternalIterable<T>,ImmutableList<T>,ListIterable<T>,OrderedIterable<T>,ReversibleIterable<T>,RichIterable<T>,BatchIterable<T>
final class ImmutableArrayList<T> extends AbstractImmutableList<T> implements java.io.Serializable, java.util.RandomAccess, BatchIterable<T>
An ImmutableArrayList wraps a Java array, but it cannot be modified after creation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.collections.impl.list.immutable.AbstractImmutableList
AbstractImmutableList.ImmutableSubList<T>
-
-
Field Summary
Fields Modifier and Type Field Description private T[]itemsprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description ImmutableArrayList(T[] newElements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallSatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.booleananySatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to true for any element of the iterable.voidappendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Prints a string representation of this collection onto the givenAppendable.voidbatchForEach(Procedure<? super T> procedure, int sectionIndex, int sectionCount)<V> ImmutableList<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.<V> ImmutableList<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.<P,V>
ImmutableList<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 java.util.Collection<V>>
RcollectWith(Function2<? super T,? super P,? extends V> function, P parameter, R target)Same as collectWith but with a targetCollection parameter to gather the results.<V> ImmutableList<V>collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.<V,R extends java.util.Collection<V>>
RcollectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function, R target)Adds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.booleancontains(java.lang.Object o)Returns true if the iterable has an element which responds true to element.equals(object).booleancontainsAll(java.util.Collection<?> collection)Returns true if all elements in source are contained in this collection.<S> booleancorresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)Returns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother.intcount(Predicate<? super T> predicate)Return the total number of elements that answer true to the specified predicate.Tdetect(Predicate<? super T> predicate)Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.private intdetectNotIndex(Predicate<? super T> predicate)java.util.Optional<T>detectOptional(Predicate<? super T> predicate)Returns the first element of the iterable for which the predicate evaluates to true as an Optional.<P> TdetectWith(Predicate2<? super T,? super P> predicate, P parameter)Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.<P> java.util.Optional<T>detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)Returns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.ImmutableList<T>drop(int count)Returns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.ImmutableList<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 that)Follows the same general contract asList.equals(Object).<V> ImmutableList<V>flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)flatCollectis a special case ofRichIterable.collect(Function).<V,R extends java.util.Collection<V>>
RflatCollect(Function<? super T,? extends java.lang.Iterable<V>> function, R target)Same as flatCollect, only the results are collected into the target collection.voidforEachWithIndex(int from, int to, ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the section of the iterable covered by the specified inclusive indexes.voidforEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Tget(int index)Returns the item at the specified position in this list iterable.intgetBatchCount(int batchSize)TgetFirst()Returns the first element of an iterable.TgetLast()Returns the last element of an iterable.inthashCode()Follows the same general contract asList.hashCode().booleanimmutableArrayListEquals(ImmutableArrayList<?> otherList)intindexOf(java.lang.Object item)Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.<IV> IVinjectInto(IV injectedValue, Function2<? super IV,? super T,? extends IV> function)Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.booleanisEmpty()Returns true if this iterable has zero items.java.util.Iterator<T>iterator()intlastIndexOf(java.lang.Object item)Returns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.<V extends java.lang.Comparable<? super V>>
TmaxBy(Function<? super T,? extends V> function)Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.<V extends java.lang.Comparable<? super V>>
TminBy(Function<? super T,? extends V> function)Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.static <E> ImmutableArrayList<E>newList(java.lang.Iterable<? extends E> iterable)static <E> ImmutableArrayList<E>newListWith(E... elements)ImmutableList<T>newWith(T newItem)This method is similar to thewithmethod inMutableCollectionwith the difference that a new copy of this collection with the element appended will be returned.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.booleannotEmpty()The English equivalent of !this.isEmpty()PartitionImmutableList<T>partition(Predicate<? super T> predicate)Filters a collection into a PartitionedIterable based on the evaluation of the predicate.PartitionImmutableList<T>partitionWhile(Predicate<? super T> predicate)Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.<P> PartitionImmutableList<T>partitionWith(Predicate2<? super T,? super P> predicate, P parameter)Filters a collection into a PartitionIterable based on the evaluation of the predicate.java.util.Optional<T>reduce(java.util.function.BinaryOperator<T> accumulator)This method produces the equivalent result asStream.reduce(BinaryOperator).<R> RreduceInPlace(java.util.function.Supplier<R> supplier, java.util.function.BiConsumer<R,? super T> accumulator)This method produces the equivalent result asStream.collect(Supplier, BiConsumer, BiConsumer).<R,A>
RreduceInPlace(java.util.stream.Collector<? super T,A,R> collector)This method produces the equivalent result asStream.collect(Collector).ImmutableList<T>reject(Predicate<? super T> predicate)Returns all elements of the source collection that return false when evaluating of the predicate.<P> ImmutableList<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 java.util.Collection<T>>
RrejectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)Similar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.ImmutableList<T>rejectWithIndex(ObjectIntPredicate<? super T> predicate)Returns a new ImmutableList with all elements of the collection that return false when evaluating the specified predicate which is supplied each element and its relative index.<R extends java.util.Collection<T>>
RrejectWithIndex(ObjectIntPredicate<? super T> predicate, R target)Adds all elements to the target Collection that return false when evaluating the specified predicate which is supplied each element and its relative index.ImmutableList<T>select(Predicate<? super T> predicate)Returns all elements of the source collection that return true when evaluating the predicate.<S> ImmutableList<S>selectInstancesOf(java.lang.Class<S> clazz)Returns all elements of the source collection that are instances of the Classclazz.<P> ImmutableList<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 java.util.Collection<T>>
RselectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)Similar toRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.ImmutableList<T>selectWithIndex(ObjectIntPredicate<? super T> predicate)Returns a new ImmutableList with all elements of the collection that return true when evaluating the specified predicate which is supplied each element and its relative index.<R extends java.util.Collection<T>>
RselectWithIndex(ObjectIntPredicate<? super T> predicate, R target)Adds all elements to the target Collection that return true when evaluating the specified predicate which is supplied each element and its relative index.intsize()Returns the number of items in this iterable.java.util.Spliterator<T>spliterator()java.util.DoubleSummaryStatisticssummarizeDouble(DoubleFunction<? super T> function)Returns the result of summarizing the value returned from applying the DoubleFunction to each element of the iterable.java.util.DoubleSummaryStatisticssummarizeFloat(FloatFunction<? super T> function)Returns the result of summarizing the value returned from applying the FloatFunction to each element of the iterable.java.util.IntSummaryStatisticssummarizeInt(IntFunction<? super T> function)Returns the result of summarizing the value returned from applying the IntFunction to each element of the iterable.java.util.LongSummaryStatisticssummarizeLong(LongFunction<? super T> function)Returns the result of summarizing the value returned from applying the LongFunction to each element of the iterable.doublesumOfDouble(DoubleFunction<? super T> function)Returns the final double result of evaluating function for each element of the iterable and adding the results together.doublesumOfFloat(FloatFunction<? super T> function)Returns the final double result of evaluating function for each element of the iterable and adding the results together.longsumOfInt(IntFunction<? super T> function)Returns the final long result of evaluating function for each element of the iterable and adding the results together.longsumOfLong(LongFunction<? super T> function)Returns the final long result of evaluating function for each element of the iterable and adding the results together.ImmutableList<T>take(int count)Returns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.ImmutableList<T>takeWhile(Predicate<? super T> predicate)Returns the initial elements that satisfy the Predicate.java.lang.Object[]toArray()Converts this iterable to an array.<E> E[]toArray(E[] a)Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.java.lang.StringtoString()Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.-
Methods inherited from class org.eclipse.collections.impl.list.immutable.AbstractImmutableList
add, addAll, asParallel, asReversed, castToList, chunk, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, detectIndex, detectLastIndex, distinct, distinct, distinctBy, forEach, forEachWith, groupBy, groupBy, groupByEach, groupByEach, injectInto, injectInto, injectInto, injectInto, listIterator, listIterator, max, max, min, min, newMutable, newWithAll, newWithout, newWithoutAll, regularListEquals, remove, replaceAll, set, sort, subList, tap, toImmutable, toReversed, zip, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection
add, addAll, castToCollection, clear, countBy, countByEach, countByWith, groupByUniqueKey, parallelStream, remove, removeAll, removeAllFrom, retainAll, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfyWith, anySatisfyWith, appendString, asLazy, collect, collectIf, containsAllArguments, containsAllIterable, countWith, detectWithIfNone, forEach, groupByUniqueKey, into, noneSatisfyWith, reject, select, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.impl.parallel.BatchIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.collection.ImmutableCollection
aggregateBy, aggregateInPlaceBy, castToCollection, countBy, countByEach, countByWith, groupByUniqueKey, parallelStream, reduceBy, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.list.ImmutableList
flatCollectWith, toImmutableList
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.list.ListIterable
binarySearch, binarySearch, forEachInBoth
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
getFirstOptional, getLastOptional, toStack, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
reverseForEach, reverseForEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfyWith, anySatisfyWith, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countBy, countByEach, countByWith, countWith, detectIfNone, detectWithIfNone, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupByAndCollect, groupByUniqueKey, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, noneSatisfyWith, reduceBy, reject, select, toBag, toBiMap, toImmutableBag, toImmutableBiMap, 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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
items
private final T[] items
-
-
Constructor Detail
-
ImmutableArrayList
ImmutableArrayList(T[] newElements)
-
-
Method Detail
-
newList
public static <E> ImmutableArrayList<E> newList(java.lang.Iterable<? extends E> iterable)
-
newListWith
public static <E> ImmutableArrayList<E> newListWith(E... elements)
-
newWith
public ImmutableList<T> newWith(T newItem)
Description copied from interface:ImmutableCollectionThis method is similar to thewithmethod inMutableCollectionwith the difference that a new copy of this collection with the element appended will be returned.- Specified by:
newWithin interfaceImmutableCollection<T>- Specified by:
newWithin interfaceImmutableList<T>
-
hashCode
public int hashCode()
Description copied from interface:ListIterableFollows the same general contract asList.hashCode().- Specified by:
hashCodein interfacejava.util.Collection<T>- Specified by:
hashCodein interfacejava.util.List<T>- Specified by:
hashCodein interfaceListIterable<T>- Overrides:
hashCodein classAbstractImmutableList<T>
-
equals
public boolean equals(java.lang.Object that)
Description copied from interface:ListIterableFollows the same general contract asList.equals(Object).- Specified by:
equalsin interfacejava.util.Collection<T>- Specified by:
equalsin interfacejava.util.List<T>- Specified by:
equalsin interfaceListIterable<T>- Overrides:
equalsin classAbstractImmutableList<T>
-
immutableArrayListEquals
public boolean immutableArrayListEquals(ImmutableArrayList<?> otherList)
-
notEmpty
public boolean notEmpty()
Description copied from interface:RichIterableThe English equivalent of !this.isEmpty()- Specified by:
notEmptyin interfaceRichIterable<T>
-
getFirst
public T getFirst()
Description copied from interface:RichIterableReturns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
- Specified by:
getFirstin interfaceListIterable<T>- Specified by:
getFirstin interfaceOrderedIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>- Overrides:
getFirstin classAbstractImmutableList<T>
-
getLast
public T getLast()
Description copied from interface:RichIterableReturns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
- Specified by:
getLastin interfaceListIterable<T>- Specified by:
getLastin interfaceOrderedIterable<T>- Specified by:
getLastin interfaceRichIterable<T>- Overrides:
getLastin classAbstractImmutableList<T>
-
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)
-
forEachWithIndex
public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Description copied from interface:InternalIterableIterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<T>- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>- Overrides:
forEachWithIndexin classAbstractImmutableList<T>
-
batchForEach
public void batchForEach(Procedure<? super T> procedure, int sectionIndex, int sectionCount)
- Specified by:
batchForEachin interfaceBatchIterable<T>
-
getBatchCount
public int getBatchCount(int batchSize)
- Specified by:
getBatchCountin interfaceBatchIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int from, int to, 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>- Overrides:
forEachWithIndexin classAbstractImmutableList<T>
-
select
public ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
selectin interfaceImmutableList<T>- Specified by:
selectin interfaceListIterable<T>- Specified by:
selectin interfaceOrderedIterable<T>- Specified by:
selectin interfaceReversibleIterable<T>- Specified by:
selectin interfaceRichIterable<T>- Overrides:
selectin classAbstractImmutableList<T>
-
selectWith
public <P> ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
selectWithin interfaceImmutableList<T>- Specified by:
selectWithin interfaceListIterable<T>- Specified by:
selectWithin interfaceOrderedIterable<T>- Specified by:
selectWithin interfaceReversibleIterable<T>- Specified by:
selectWithin interfaceRichIterable<T>- Overrides:
selectWithin classAbstractImmutableList<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)
-
selectWith
public <P,R extends java.util.Collection<T>> R selectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
MutableList<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
selectWithin interfaceRichIterable<T>- Overrides:
selectWithin classAbstractImmutableList<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriapredicate- Returns:
targetCollection, which contains appended elements as a result of the select criteria- See Also:
RichIterable.select(Predicate),RichIterable.select(Predicate, Collection)
-
reject
public ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
rejectin interfaceImmutableList<T>- Specified by:
rejectin interfaceListIterable<T>- Specified by:
rejectin interfaceOrderedIterable<T>- Specified by:
rejectin interfaceReversibleIterable<T>- Specified by:
rejectin interfaceRichIterable<T>- Overrides:
rejectin classAbstractImmutableList<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> ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
rejectWithin interfaceImmutableList<T>- Specified by:
rejectWithin interfaceListIterable<T>- Specified by:
rejectWithin interfaceOrderedIterable<T>- Specified by:
rejectWithin interfaceReversibleIterable<T>- Specified by:
rejectWithin interfaceRichIterable<T>- Overrides:
rejectWithin classAbstractImmutableList<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)
-
rejectWith
public <P,R extends java.util.Collection<T>> R rejectWith(Predicate2<? super T,? super P> predicate, P parameter, R target)
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
MutableList<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
rejectWithin interfaceRichIterable<T>- Overrides:
rejectWithin classAbstractImmutableList<T>- Parameters:
predicate- aPredicate2to use as the reject criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat causePredicate#accept(Object)method to evaluate to false- Returns:
targetCollection, which contains appended elements as a result of the reject criteria- See Also:
RichIterable.reject(Predicate),RichIterable.reject(Predicate, Collection)
-
partition
public PartitionImmutableList<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 interfaceImmutableCollection<T>- Specified by:
partitionin interfaceImmutableList<T>- Specified by:
partitionin interfaceListIterable<T>- Specified by:
partitionin interfaceOrderedIterable<T>- Specified by:
partitionin interfaceReversibleIterable<T>- Specified by:
partitionin interfaceRichIterable<T>- Overrides:
partitionin classAbstractImmutableList<T>
-
partitionWith
public <P> PartitionImmutableList<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 interfaceImmutableCollection<T>- Specified by:
partitionWithin interfaceImmutableList<T>- Specified by:
partitionWithin interfaceListIterable<T>- Specified by:
partitionWithin interfaceOrderedIterable<T>- Specified by:
partitionWithin interfaceReversibleIterable<T>- Specified by:
partitionWithin interfaceRichIterable<T>- Overrides:
partitionWithin classAbstractImmutableList<T>
-
selectInstancesOf
public <S> ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
selectInstancesOfin interfaceImmutableList<T>- Specified by:
selectInstancesOfin interfaceListIterable<T>- Specified by:
selectInstancesOfin interfaceOrderedIterable<T>- Specified by:
selectInstancesOfin interfaceReversibleIterable<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>- Overrides:
selectInstancesOfin classAbstractImmutableList<T>
-
collect
public <V> ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
collectin interfaceImmutableList<T>- Specified by:
collectin interfaceListIterable<T>- Specified by:
collectin interfaceOrderedIterable<T>- Specified by:
collectin interfaceReversibleIterable<T>- Specified by:
collectin interfaceRichIterable<T>- Overrides:
collectin classAbstractImmutableList<T>
-
collectWith
public <P,V> ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
collectWithin interfaceImmutableList<T>- Specified by:
collectWithin interfaceListIterable<T>- Specified by:
collectWithin interfaceOrderedIterable<T>- Specified by:
collectWithin interfaceReversibleIterable<T>- Specified by:
collectWithin interfaceRichIterable<T>- Overrides:
collectWithin classAbstractImmutableList<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)
-
collectWithIndex
public <V> ImmutableList<V> collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)
Description copied from interface:OrderedIterableReturns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndexin interfaceImmutableList<T>- Specified by:
collectWithIndexin interfaceListIterable<T>- Specified by:
collectWithIndexin interfaceOrderedIterable<T>- Specified by:
collectWithIndexin interfaceReversibleIterable<T>- Since:
- 9.1.
-
collectWithIndex
public <V,R extends java.util.Collection<V>> R collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function, R target)
Description copied from interface:OrderedIterableAdds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndexin interfaceOrderedIterable<T>- Since:
- 9.1.
-
selectWithIndex
public ImmutableList<T> selectWithIndex(ObjectIntPredicate<? super T> predicate)
Description copied from interface:ImmutableListReturns a new ImmutableList with all elements of the collection that return true when evaluating the specified predicate which is supplied each element and its relative index.- Specified by:
selectWithIndexin interfaceImmutableList<T>- Specified by:
selectWithIndexin interfaceListIterable<T>- Since:
- 11.0
-
rejectWithIndex
public ImmutableList<T> rejectWithIndex(ObjectIntPredicate<? super T> predicate)
Description copied from interface:ImmutableListReturns a new ImmutableList with all elements of the collection that return false when evaluating the specified predicate which is supplied each element and its relative index.- Specified by:
rejectWithIndexin interfaceImmutableList<T>- Specified by:
rejectWithIndexin interfaceListIterable<T>- Since:
- 11.0
-
selectWithIndex
public <R extends java.util.Collection<T>> R selectWithIndex(ObjectIntPredicate<? super T> predicate, R target)
Description copied from interface:OrderedIterableAdds all elements to the target Collection that return true when evaluating the specified predicate which is supplied each element and its relative index.- Specified by:
selectWithIndexin interfaceOrderedIterable<T>- Since:
- 11.0
-
rejectWithIndex
public <R extends java.util.Collection<T>> R rejectWithIndex(ObjectIntPredicate<? super T> predicate, R target)
Description copied from interface:OrderedIterableAdds all elements to the target Collection that return false when evaluating the specified predicate which is supplied each element and its relative index.- Specified by:
rejectWithIndexin interfaceOrderedIterable<T>- Since:
- 11.0
-
collectIf
public <V> ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
collectIfin interfaceImmutableList<T>- Specified by:
collectIfin interfaceListIterable<T>- Specified by:
collectIfin interfaceOrderedIterable<T>- Specified by:
collectIfin interfaceReversibleIterable<T>- Specified by:
collectIfin interfaceRichIterable<T>- Overrides:
collectIfin classAbstractImmutableList<T>
-
collectWith
public <P,V,R extends java.util.Collection<V>> R collectWith(Function2<? super T,? super P,? extends V> function, P parameter, R target)
Description copied from interface:RichIterableSame as collectWith but with a targetCollection parameter to gather the results.Example using a Java 8 lambda expression:
MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());- Specified by:
collectWithin interfaceRichIterable<T>- Overrides:
collectWithin classAbstractImmutableList<T>- Parameters:
function- aFunction2to use as the collect transformation functionparameter- a parameter to pass in for evaluation of the second argumentPinfunctiontarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriafunction- Returns:
targetCollection, which contains appended elements as a result of the collect transformation
-
flatCollect
public <V> ImmutableList<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 interfaceImmutableCollection<T>- Specified by:
flatCollectin interfaceImmutableList<T>- Specified by:
flatCollectin interfaceListIterable<T>- Specified by:
flatCollectin interfaceOrderedIterable<T>- Specified by:
flatCollectin interfaceReversibleIterable<T>- Specified by:
flatCollectin interfaceRichIterable<T>- Overrides:
flatCollectin classAbstractImmutableList<T>- Parameters:
function- TheFunctionto apply- Returns:
- a new flattened collection produced by applying the given
function
-
flatCollect
public <V,R extends java.util.Collection<V>> R flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectin interfaceRichIterable<T>- Overrides:
flatCollectin classAbstractImmutableList<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
detect
public T detect(Predicate<? super T> predicate)
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"));- Specified by:
detectin interfaceRichIterable<T>- Overrides:
detectin classAbstractRichIterable<T>
-
detectWith
public <P> T detectWith(Predicate2<? super T,? super P> predicate, P parameter)
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");- Specified by:
detectWithin interfaceRichIterable<T>- Overrides:
detectWithin classAbstractRichIterable<T>
-
detectOptional
public java.util.Optional<T> detectOptional(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true as an Optional. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));- Specified by:
detectOptionalin interfaceRichIterable<T>- Overrides:
detectOptionalin classAbstractRichIterable<T>
-
detectWithOptional
public <P> java.util.Optional<T> detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.Example using a Java 8 lambda expression:
Optional<Person> person = people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");- Specified by:
detectWithOptionalin interfaceRichIterable<T>- Overrides:
detectWithOptionalin classAbstractRichIterable<T>
-
count
public int count(Predicate<? super T> predicate)
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"));- Specified by:
countin interfaceRichIterable<T>- Overrides:
countin classAbstractImmutableList<T>
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)
Description copied from interface:OrderedIterableReturns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother. Thepredicateis evaluated for each element at the same position of eachOrderedIterablein a forward iteration order. This is a short circuit pattern.- Specified by:
correspondsin interfaceOrderedIterable<T>- Overrides:
correspondsin classAbstractImmutableList<T>
-
anySatisfy
public boolean anySatisfy(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.- Specified by:
anySatisfyin interfaceRichIterable<T>- Overrides:
anySatisfyin classAbstractRichIterable<T>
-
allSatisfy
public boolean allSatisfy(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfyin interfaceRichIterable<T>- Overrides:
allSatisfyin classAbstractRichIterable<T>
-
noneSatisfy
public boolean noneSatisfy(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfyin interfaceRichIterable<T>- Overrides:
noneSatisfyin classAbstractRichIterable<T>
-
summarizeInt
public java.util.IntSummaryStatistics summarizeInt(IntFunction<? super T> function)
Description copied from interface:RichIterableReturns the result of summarizing the value returned from applying the IntFunction to each element of the iterable.IntSummaryStatistics stats = Lists.mutable.with(1, 2, 3).summarizeInt(Integer::intValue);- Specified by:
summarizeIntin interfaceRichIterable<T>- Since:
- 8.0
-
summarizeFloat
public java.util.DoubleSummaryStatistics summarizeFloat(FloatFunction<? super T> function)
Description copied from interface:RichIterableReturns the result of summarizing the value returned from applying the FloatFunction to each element of the iterable.DoubleSummaryStatistics stats = Lists.mutable.with(1, 2, 3).summarizeFloat(Integer::floatValue);- Specified by:
summarizeFloatin interfaceRichIterable<T>- Since:
- 8.0
-
summarizeLong
public java.util.LongSummaryStatistics summarizeLong(LongFunction<? super T> function)
Description copied from interface:RichIterableReturns the result of summarizing the value returned from applying the LongFunction to each element of the iterable.LongSummaryStatistics stats = Lists.mutable.with(1, 2, 3).summarizeLong(Integer::longValue);- Specified by:
summarizeLongin interfaceRichIterable<T>- Since:
- 8.0
-
summarizeDouble
public java.util.DoubleSummaryStatistics summarizeDouble(DoubleFunction<? super T> function)
Description copied from interface:RichIterableReturns the result of summarizing the value returned from applying the DoubleFunction to each element of the iterable.DoubleSummaryStatistics stats = Lists.mutable.with(1, 2, 3).summarizeDouble(Integer::doubleValue);- Specified by:
summarizeDoublein interfaceRichIterable<T>- Since:
- 8.0
-
reduce
public java.util.Optional<T> reduce(java.util.function.BinaryOperator<T> accumulator)
Description copied from interface:RichIterableThis method produces the equivalent result asStream.reduce(BinaryOperator).- Specified by:
reducein interfaceRichIterable<T>- Overrides:
reducein classAbstractImmutableCollection<T>- Since:
- 8.0
-
reduceInPlace
public <R,A> R reduceInPlace(java.util.stream.Collector<? super T,A,R> collector)
Description copied from interface:RichIterableThis method produces the equivalent result asStream.collect(Collector).MutableObjectLongMap<Integer> map2 = Lists.mutable.with(1, 2, 3, 4, 5).reduceInPlace(Collectors2.sumByInt(i -> Integer.valueOf(i % 2), Integer::intValue));- Specified by:
reduceInPlacein interfaceRichIterable<T>- Since:
- 8.0
-
reduceInPlace
public <R> R reduceInPlace(java.util.function.Supplier<R> supplier, java.util.function.BiConsumer<R,? super T> accumulator)Description copied from interface:RichIterableThis method produces the equivalent result asStream.collect(Supplier, BiConsumer, BiConsumer). The combiner used in collect is unnecessary in the serial case, so is not included in the API.- Specified by:
reduceInPlacein interfaceRichIterable<T>- Since:
- 8.0
-
sumOfInt
public long sumOfInt(IntFunction<? super T> function)
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>- Overrides:
sumOfIntin classAbstractImmutableList<T>
-
sumOfLong
public long sumOfLong(LongFunction<? super T> function)
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>- Overrides:
sumOfLongin classAbstractImmutableList<T>
-
sumOfFloat
public double sumOfFloat(FloatFunction<? super T> function)
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>- Overrides:
sumOfFloatin classAbstractImmutableList<T>
-
sumOfDouble
public double sumOfDouble(DoubleFunction<? super T> function)
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>- Overrides:
sumOfDoublein classAbstractImmutableList<T>
-
injectInto
public <IV> IV injectInto(IV injectedValue, Function2<? super IV,? super T,? extends IV> function)Description copied from interface:RichIterableReturns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.- Specified by:
injectIntoin interfaceRichIterable<T>- Overrides:
injectIntoin classAbstractImmutableList<T>
-
size
public int size()
Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceBatchIterable<T>- Specified by:
sizein interfacejava.util.Collection<T>- Specified by:
sizein interfacejava.util.List<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 interfacejava.util.Collection<T>- Specified by:
isEmptyin interfacejava.util.List<T>- Specified by:
isEmptyin interfaceRichIterable<T>- Overrides:
isEmptyin classAbstractRichIterable<T>
-
contains
public boolean contains(java.lang.Object o)
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfacejava.util.Collection<T>- Specified by:
containsin interfacejava.util.List<T>- Specified by:
containsin interfaceRichIterable<T>- Overrides:
containsin classAbstractRichIterable<T>
-
iterator
public java.util.Iterator<T> iterator()
-
toArray
public java.lang.Object[] toArray()
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfacejava.util.Collection<T>- Specified by:
toArrayin interfacejava.util.List<T>- Specified by:
toArrayin interfaceRichIterable<T>- Overrides:
toArrayin classAbstractImmutableCollection<T>- See Also:
Collection.toArray()
-
toArray
public <E> E[] toArray(E[] a)
Description copied from interface:RichIterableConverts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArrayin interfacejava.util.Collection<T>- Specified by:
toArrayin interfacejava.util.List<T>- Specified by:
toArrayin interfaceRichIterable<T>- Overrides:
toArrayin classAbstractImmutableCollection<T>- See Also:
Collection.toArray(Object[])
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Description copied from interface:RichIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byRichIterable.makeString(String, String, String).- Specified by:
appendStringin interfaceRichIterable<T>- Overrides:
appendStringin classAbstractImmutableList<T>
-
toString
public java.lang.String toString()
Description copied from class:AbstractRichIterableReturns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.Assert.assertEquals("[]", Lists.mutable.empty().toString()); Assert.assertEquals("[1]", Lists.mutable.with(1).toString()); Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());- Specified by:
toStringin interfaceRichIterable<T>- Overrides:
toStringin classAbstractRichIterable<T>- Returns:
- a string representation of this collection.
- See Also:
AbstractCollection.toString()
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllin interfacejava.util.Collection<T>- Specified by:
containsAllin interfacejava.util.List<T>- Specified by:
containsAllin interfaceRichIterable<T>- Overrides:
containsAllin classAbstractRichIterable<T>- See Also:
Collection.containsAll(Collection)
-
get
public T get(int index)
Description copied from interface:ListIterableReturns the item at the specified position in this list iterable.- Specified by:
getin interfacejava.util.List<T>- Specified by:
getin interfaceListIterable<T>
-
indexOf
public int indexOf(java.lang.Object item)
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 interfacejava.util.List<T>- Specified by:
indexOfin interfaceOrderedIterable<T>- Overrides:
indexOfin classAbstractImmutableList<T>- See Also:
List.indexOf(Object)
-
lastIndexOf
public int lastIndexOf(java.lang.Object item)
Description copied from interface:ListIterableReturns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.- Specified by:
lastIndexOfin interfacejava.util.List<T>- Specified by:
lastIndexOfin interfaceListIterable<T>- Overrides:
lastIndexOfin classAbstractImmutableList<T>
-
minBy
public <V extends java.lang.Comparable<? super V>> T minBy(Function<? super T,? extends V> function)
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>- Overrides:
minByin classAbstractImmutableList<T>
-
maxBy
public <V extends java.lang.Comparable<? super V>> T maxBy(Function<? super T,? extends V> function)
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>- Overrides:
maxByin classAbstractImmutableList<T>
-
take
public ImmutableList<T> take(int count)
Description copied from interface:ReversibleIterableReturns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.- Specified by:
takein interfaceImmutableList<T>- Specified by:
takein interfaceListIterable<T>- Specified by:
takein interfaceReversibleIterable<T>- Overrides:
takein classAbstractImmutableList<T>- Parameters:
count- the number of items to take.
-
takeWhile
public ImmutableList<T> takeWhile(Predicate<? super T> predicate)
Description copied from interface:ListIterableReturns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.- Specified by:
takeWhilein interfaceImmutableList<T>- Specified by:
takeWhilein interfaceListIterable<T>- Specified by:
takeWhilein interfaceOrderedIterable<T>- Specified by:
takeWhilein interfaceReversibleIterable<T>- Overrides:
takeWhilein classAbstractImmutableList<T>
-
drop
public ImmutableList<T> drop(int count)
Description copied from interface:ReversibleIterableReturns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.- Specified by:
dropin interfaceImmutableList<T>- Specified by:
dropin interfaceListIterable<T>- Specified by:
dropin interfaceReversibleIterable<T>- Overrides:
dropin classAbstractImmutableList<T>- Parameters:
count- the number of items to drop.
-
dropWhile
public ImmutableList<T> dropWhile(Predicate<? super T> predicate)
Description copied from interface:ListIterableReturns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.- Specified by:
dropWhilein interfaceImmutableList<T>- Specified by:
dropWhilein interfaceListIterable<T>- Specified by:
dropWhilein interfaceOrderedIterable<T>- Specified by:
dropWhilein interfaceReversibleIterable<T>- Overrides:
dropWhilein classAbstractImmutableList<T>
-
partitionWhile
public PartitionImmutableList<T> partitionWhile(Predicate<? super T> predicate)
Description copied from interface:ListIterableReturns 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 interfaceImmutableList<T>- Specified by:
partitionWhilein interfaceListIterable<T>- Specified by:
partitionWhilein interfaceOrderedIterable<T>- Specified by:
partitionWhilein interfaceReversibleIterable<T>- Overrides:
partitionWhilein classAbstractImmutableList<T>
-
spliterator
public java.util.Spliterator<T> spliterator()
- Specified by:
spliteratorin interfacejava.util.Collection<T>- Specified by:
spliteratorin interfaceImmutableCollection<T>- Specified by:
spliteratorin interfacejava.lang.Iterable<T>- Specified by:
spliteratorin interfacejava.util.List<T>- Overrides:
spliteratorin classAbstractImmutableCollection<T>- Since:
- 9.0
-
-