Top Description Methods
org.eclipse.collections.api

public Interface IntIterable

extends PrimitiveIterable
Known Direct Subinterfaces
org.eclipse.collections.api.LazyIntIterable, org.eclipse.collections.api.bag.primitive.IntBag, org.eclipse.collections.api.collection.primitive.ImmutableIntCollection, org.eclipse.collections.api.collection.primitive.MutableIntCollection, org.eclipse.collections.api.map.primitive.ObjectIntMap, org.eclipse.collections.api.map.primitive.IntValuesMap, org.eclipse.collections.api.ordered.primitive.OrderedIntIterable, org.eclipse.collections.api.set.primitive.IntSet
Imports
java.util.Collection, .NoSuchElementException, .IntSummaryStatistics, .Comparator, org.eclipse.collections.api.block.comparator.primitive.IntComparator, org.eclipse.collections.api.bag.primitive.MutableIntBag, org.eclipse.collections.api.block.function.primitive.IntToBooleanFunction, .IntToByteFunction, .IntToShortFunction, .IntToCharFunction, .IntToDoubleFunction, .IntToFloatFunction, .IntToIntFunction, .IntToLongFunction, .IntToObjectFunction, .BooleanIntToBooleanFunction, .ByteIntToByteFunction, .CharIntToCharFunction, .DoubleIntToDoubleFunction, .FloatIntToFloatFunction, .IntIntToIntFunction, .LongIntToLongFunction, .ObjectIntToObjectFunction, .ShortIntToShortFunction, org.eclipse.collections.api.block.predicate.primitive.IntPredicate, org.eclipse.collections.api.block.procedure.primitive.IntProcedure, org.eclipse.collections.api.collection.primitive.MutableBooleanCollection, .MutableByteCollection, .MutableCharCollection, .MutableDoubleCollection, .MutableFloatCollection, .MutableIntCollection, .MutableLongCollection, .MutableShortCollection, org.eclipse.collections.api.iterator.IntIterator, org.eclipse.collections.api.list.primitive.MutableIntList, org.eclipse.collections.api.set.primitive.IntSet, .MutableIntSet

IntIterable is an interface which is memory-optimized for int primitives. It is inspired by the interface RichIterable, and contains a subset of the internal iterator methods on RichIterable like collect, sum, etc. The API also includes an external iterator method, which returns an IntIterator. IntIterator helps iterate over the IntIterable without boxing the primitives. This file was automatically generated from template file primitiveIterable.stg.

Method Summary

Modifier and TypeMethod and Description
public boolean
allSatisfy(IntPredicate predicate)

Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.

public boolean
anySatisfy(IntPredicate predicate)

Returns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.

public LazyIntIterable
asLazy()

Returns a LazyIntIterable adapter wrapping the source IntIterable.

public double
public default double
averageIfEmpty(double defaultValue)

public default RichIterable<IntIterable>

Returns:

A RichIterable containing IntIterables of size size, except the last will be truncated if the elements don't divide evenly.
chunk
(int
the number of elements per chunk
size
)

Partitions elements in fixed size chunks.

public <V> RichIterable<V>
collect(IntToObjectFunction<? extends V> function)

Returns a new collection with the results of applying the specified function on each element of the source collection.

public default <V, R extends Collection<V>> R
collect(IntToObjectFunction<? extends V> function, R target)

Same as collect(IntToObjectFunction) , only the results are added to the target Collection.

public default <R extends MutableBooleanCollection> R
collectBoolean(IntToBooleanFunction function, R target)

Returns the target MutableBooleanCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableByteCollection> R
collectByte(IntToByteFunction function, R target)

Returns the target MutableByteCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableCharCollection> R
collectChar(IntToCharFunction function, R target)

Returns the target MutableCharCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableDoubleCollection> R
collectDouble(IntToDoubleFunction function, R target)

Returns the target MutableDoubleCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableFloatCollection> R
collectFloat(IntToFloatFunction function, R target)

Returns the target MutableFloatCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableIntCollection> R
collectInt(IntToIntFunction function, R target)

Returns the target MutableIntCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableLongCollection> R
collectLong(IntToLongFunction function, R target)

Returns the target MutableLongCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableShortCollection> R
collectShort(IntToShortFunction function, R target)

Returns the target MutableShortCollection with the results of applying the specified function on each element of the source collection.

public boolean
contains(int value)

Returns true if the value is contained in the IntIterable, and false if it is not.

public default boolean
containsAll(int... source)

Returns true if all of the values specified in the source array are contained in the IntIterable, and false if they are not.

public default boolean
containsAll(IntIterable source)

Returns true if all of the values specified in the source IntIterable are contained in the IntIterable, and false if they are not.

public default boolean
containsAny(int... source)

Returns true if any of the values specified in the source array are contained in the IntIterable, and false if they are not.

public default boolean
containsAny(IntIterable source)

Returns true if any of the values specified in the source IntIterable are contained in the IntIterable, and false if they are not.

public default boolean
containsNone(int... source)

Returns true if none of the values specified in the source array are contained in the IntIterable, and false if they are.

public default boolean
containsNone(IntIterable source)

Returns true if none of the values specified in the source IntIterable are contained in the IntIterable, and false if they are.

public int
count(IntPredicate predicate)

Returns a count of the number of elements in the IntIterable that return true for the specified predicate.

public int
detectIfNone(IntPredicate predicate, int ifNone)

public void
each(IntProcedure procedure)

A synonym for forEach.

public default <V, R extends Collection<V>> R
flatCollect(IntToObjectFunction<? extends Iterable<V>> function, R target)

flatCollect is a special case of collect(IntToObjectFunction).

public default void
forEach(IntProcedure procedure)

Applies the IntProcedure to each element in the IntIterable.

public <T> T
injectInto(T injectedValue, ObjectIntToObjectFunction<? super T, ? extends T> function)

public default boolean
injectIntoBoolean(boolean injectedValue, BooleanIntToBooleanFunction function)

Returns the final boolean result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default byte
injectIntoByte(byte injectedValue, ByteIntToByteFunction function)

Returns the final byte result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default char
injectIntoChar(char injectedValue, CharIntToCharFunction function)

Returns the final char result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default double
injectIntoDouble(double injectedValue, DoubleIntToDoubleFunction function)

Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default float
injectIntoFloat(float injectedValue, FloatIntToFloatFunction function)

Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default int
injectIntoInt(int injectedValue, IntIntToIntFunction function)

Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default long
injectIntoLong(long injectedValue, LongIntToLongFunction function)

Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default short
injectIntoShort(short injectedValue, ShortIntToShortFunction function)

Returns the final short result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public IntIterator
intIterator()

Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.

public int
max()

public int
maxIfEmpty(int defaultValue)

public double
public default double
medianIfEmpty(double defaultValue)

public int
min()

public int
minIfEmpty(int defaultValue)

public default boolean
noneSatisfy(IntPredicate predicate)

Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.

public default long
public default long
reduceIfEmpty(LongIntToLongFunction accumulator, long defaultValue)

public IntIterable
reject(IntPredicate predicate)

Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.

public default <R extends MutableIntCollection> R
reject(IntPredicate predicate, R target)

Same as reject(IntPredicate) , only the results are added to the target MutableIntCollection.

public IntIterable
select(IntPredicate predicate)

Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.

public default <R extends MutableIntCollection> R
select(IntPredicate predicate, R target)

Same as select(IntPredicate) , only the results are added to the target MutableIntCollection.

public long
sum()

public default IntSummaryStatistics
public default IntIterable
tap(IntProcedure procedure)

public int[]
toArray()

Converts the IntIterable to a primitive int array.

public default int[]
toArray(int[] target)

Converts the IntIterable to a primitive int array.

public MutableIntBag
toBag()

Converts the IntIterable to a new MutableIntBag.

public MutableIntList
toList()

Converts the IntIterable to a new MutableIntList.

public MutableIntSet
toSet()

Converts the IntIterable to a new MutableIntSet.

public int[]
public MutableIntList
public default MutableIntList
toSortedList(IntComparator comparator)

Converts the collection to a MutableIntList implementation sorted using the provided comparator.

public default <T> MutableIntList
toSortedListBy(IntToObjectFunction<T> function)

Converts the collection to a MutableIntListImplementation sorted based on the natural order of the key returned by function.

public default <T> MutableIntList
toSortedListBy(IntToObjectFunction<T> function, Comparator<? super T> comparator)

Converts the collection to a MutableIntList implementation, which is sorted based on the key returned by function using the provided comparator.

Inherited from org.eclipse.collections.api.PrimitiveIterable:
appendStringappendStringappendStringisEmptymakeStringmakeStringmakeStringnotEmptysizetoString

Method Detail

allSatisfyback to summary
public boolean allSatisfy(IntPredicate predicate)

Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.

anySatisfyback to summary
public boolean anySatisfy(IntPredicate predicate)

Returns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.

asLazyback to summary
public LazyIntIterable asLazy()

Returns a LazyIntIterable adapter wrapping the source IntIterable.

averageback to summary
public double average()
averageIfEmptyback to summary
public default double averageIfEmpty(double defaultValue)
Since
9.0
chunkback to summary
public default RichIterable<IntIterable> chunk(int size)

Partitions elements in fixed size chunks.

Parameters
size:int

the number of elements per chunk

Returns:RichIterable<IntIterable>

A RichIterable containing IntIterables of size size, except the last will be truncated if the elements don't divide evenly.

Since
9.2
collectback to summary
public <V> RichIterable<V> collect(IntToObjectFunction<? extends V> function)

Returns 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.

collectback to summary
public default <V, R extends Collection<V>> R collect(IntToObjectFunction<? extends V> function, R target)

Same as collect(IntToObjectFunction) , only the results are added to the target Collection.

Since
8.1.
collectBooleanback to summary
public default <R extends MutableBooleanCollection> R collectBoolean(IntToBooleanFunction function, R target)

Returns the target MutableBooleanCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectByteback to summary
public default <R extends MutableByteCollection> R collectByte(IntToByteFunction function, R target)

Returns the target MutableByteCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectCharback to summary
public default <R extends MutableCharCollection> R collectChar(IntToCharFunction function, R target)

Returns the target MutableCharCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectDoubleback to summary
public default <R extends MutableDoubleCollection> R collectDouble(IntToDoubleFunction function, R target)

Returns the target MutableDoubleCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectFloatback to summary
public default <R extends MutableFloatCollection> R collectFloat(IntToFloatFunction function, R target)

Returns the target MutableFloatCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectIntback to summary
public default <R extends MutableIntCollection> R collectInt(IntToIntFunction function, R target)

Returns the target MutableIntCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectLongback to summary
public default <R extends MutableLongCollection> R collectLong(IntToLongFunction function, R target)

Returns the target MutableLongCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectShortback to summary
public default <R extends MutableShortCollection> R collectShort(IntToShortFunction function, R target)

Returns the target MutableShortCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
containsback to summary
public boolean contains(int value)

Returns true if the value is contained in the IntIterable, and false if it is not.

containsAllback to summary
public default boolean containsAll(int... source)

Returns true if all of the values specified in the source array are contained in the IntIterable, and false if they are not.

containsAllback to summary
public default boolean containsAll(IntIterable source)

Returns true if all of the values specified in the source IntIterable are contained in the IntIterable, and false if they are not.

containsAnyback to summary
public default boolean containsAny(int... source)

Returns true if any of the values specified in the source array are contained in the IntIterable, and false if they are not.

Since
11.0
containsAnyback to summary
public default boolean containsAny(IntIterable source)

Returns true if any of the values specified in the source IntIterable are contained in the IntIterable, and false if they are not.

Since
11.0
containsNoneback to summary
public default boolean containsNone(int... source)

Returns true if none of the values specified in the source array are contained in the IntIterable, and false if they are.

Since
11.0
containsNoneback to summary
public default boolean containsNone(IntIterable source)

Returns true if none of the values specified in the source IntIterable are contained in the IntIterable, and false if they are.

Since
11.0
countback to summary
public int count(IntPredicate predicate)

Returns a count of the number of elements in the IntIterable that return true for the specified predicate.

detectIfNoneback to summary
public int detectIfNone(IntPredicate predicate, int ifNone)
eachback to summary
public void each(IntProcedure procedure)

A synonym for forEach.

Since
7.0.
flatCollectback to summary
public default <V, R extends Collection<V>> R flatCollect(IntToObjectFunction<? extends Iterable<V>> function, R target)

flatCollect is a special case of collect(IntToObjectFunction). With collect, when the IntToObjectFunction returns a collection, the result is a collection of collections. flatCollect outputs a single "flattened" collection instead. This method is commonly called flatMap.

Since
8.1.
forEachback to summary
public default void forEach(IntProcedure procedure)

Applies the IntProcedure to each element in the IntIterable.

injectIntoback to summary
public <T> T injectInto(T injectedValue, ObjectIntToObjectFunction<? super T, ? extends T> function)
injectIntoBooleanback to summary
public default boolean injectIntoBoolean(boolean injectedValue, BooleanIntToBooleanFunction function)

Returns the final boolean 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.

Since
11.1
injectIntoByteback to summary
public default byte injectIntoByte(byte injectedValue, ByteIntToByteFunction function)

Returns the final byte 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.

Since
11.1
injectIntoCharback to summary
public default char injectIntoChar(char injectedValue, CharIntToCharFunction function)

Returns the final char 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.

Since
11.1
injectIntoDoubleback to summary
public default double injectIntoDouble(double injectedValue, DoubleIntToDoubleFunction function)

Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoFloatback to summary
public default float injectIntoFloat(float injectedValue, FloatIntToFloatFunction function)

Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoIntback to summary
public default int injectIntoInt(int injectedValue, IntIntToIntFunction function)

Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoLongback to summary
public default long injectIntoLong(long injectedValue, LongIntToLongFunction function)

Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoShortback to summary
public default short injectIntoShort(short injectedValue, ShortIntToShortFunction function)

Returns the final short 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.

Since
11.1
intIteratorback to summary
public IntIterator intIterator()

Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.

maxback to summary
public int max()
maxIfEmptyback to summary
public int maxIfEmpty(int defaultValue)
medianback to summary
public double median()
medianIfEmptyback to summary
public default double medianIfEmpty(double defaultValue)
Since
9.0
minback to summary
public int min()
minIfEmptyback to summary
public int minIfEmpty(int defaultValue)
noneSatisfyback to summary
public default boolean noneSatisfy(IntPredicate predicate)

Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.

reduceback to summary
public default long reduce(LongIntToLongFunction accumulator)
Since
10.0
See Also
RichIterable#reduce(BinaryOperator)
reduceIfEmptyback to summary
public default long reduceIfEmpty(LongIntToLongFunction accumulator, long defaultValue)
Since
10.0
See Also
reduce(LongIntToLongFunction)
rejectback to summary
public IntIterable reject(IntPredicate predicate)

Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.

rejectback to summary
public default <R extends MutableIntCollection> R reject(IntPredicate predicate, R target)

Same as reject(IntPredicate) , only the results are added to the target MutableIntCollection.

Since
8.1.
selectback to summary
public IntIterable select(IntPredicate predicate)

Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.

selectback to summary
public default <R extends MutableIntCollection> R select(IntPredicate predicate, R target)

Same as select(IntPredicate) , only the results are added to the target MutableIntCollection.

Since
8.1.
sumback to summary
public long sum()
summaryStatisticsback to summary
public default IntSummaryStatistics summaryStatistics()
Since
8.0
tapback to summary
public default IntIterable tap(IntProcedure procedure)
Since
9.0.
toArrayback to summary
public int[] toArray()

Converts the IntIterable to a primitive int array.

toArrayback to summary
public default int[] toArray(int[] target)

Converts the IntIterable to a primitive int array. If the collection fits into the provided array it is used to store its elements and is returned from the method, otherwise a new array of the appropriate size is allocated and returned. If the iterable is empty, the target array is returned unchanged.

toBagback to summary
public MutableIntBag toBag()

Converts the IntIterable to a new MutableIntBag.

toListback to summary
public MutableIntList toList()

Converts the IntIterable to a new MutableIntList.

toSetback to summary
public MutableIntSet toSet()

Converts the IntIterable to a new MutableIntSet.

toSortedArrayback to summary
public int[] toSortedArray()
toSortedListback to summary
public MutableIntList toSortedList()
toSortedListback to summary
public default MutableIntList toSortedList(IntComparator comparator)

Converts the collection to a MutableIntList implementation sorted using the provided comparator.

toSortedListByback to summary
public default <T> MutableIntList toSortedListBy(IntToObjectFunction<T> function)

Converts the collection to a MutableIntListImplementation sorted based on the natural order of the key returned by function.

toSortedListByback to summary
public default <T> MutableIntList toSortedListBy(IntToObjectFunction<T> function, Comparator<? super T> comparator)

Converts the collection to a MutableIntList implementation, which is sorted based on the key returned by function using the provided comparator.