Package org.eclipse.collections.api
Interface IntIterable
-
- All Superinterfaces:
PrimitiveIterable
- All Known Subinterfaces:
ByteIntMap
,CharIntMap
,DoubleIntMap
,FloatIntMap
,ImmutableByteIntMap
,ImmutableCharIntMap
,ImmutableDoubleIntMap
,ImmutableFloatIntMap
,ImmutableIntBag
,ImmutableIntCollection
,ImmutableIntIntMap
,ImmutableIntList
,ImmutableIntSet
,ImmutableIntStack
,ImmutableLongIntMap
,ImmutableObjectIntMap<K>
,ImmutableShortIntMap
,IntBag
,IntIntMap
,IntList
,IntSet
,IntStack
,IntValuesMap
,LazyIntIterable
,LongIntMap
,MutableByteIntMap
,MutableCharIntMap
,MutableDoubleIntMap
,MutableFloatIntMap
,MutableIntBag
,MutableIntCollection
,MutableIntIntMap
,MutableIntList
,MutableIntSet
,MutableIntStack
,MutableIntValuesMap
,MutableLongIntMap
,MutableObjectIntMap<K>
,MutableShortIntMap
,ObjectIntMap<K>
,OrderedIntIterable
,ReversibleIntIterable
,ShortIntMap
- All Known Implementing Classes:
AbstractImmutableIntSet
,AbstractImmutableObjectIntMap
,AbstractIntIterable
,AbstractIntSet
,AbstractIntStack
,AbstractLazyIntIterable
,AbstractMutableIntKeySet
,AbstractMutableIntValuesMap
,AbstractMutableIntValuesMap.AbstractIntValuesCollection
,AbstractSynchronizedIntCollection
,AbstractUnmodifiableIntCollection
,ByteIntHashMap
,ByteIntHashMap.ValuesCollection
,CharIntHashMap
,CharIntHashMap.ValuesCollection
,CodePointAdapter
,CodePointList
,CollectBooleanToIntIterable
,CollectByteToIntIterable
,CollectCharToIntIterable
,CollectDoubleToIntIterable
,CollectFloatToIntIterable
,CollectIntIterable
,CollectIntToIntIterable
,CollectLongToIntIterable
,CollectShortToIntIterable
,DoubleIntHashMap
,DoubleIntHashMap.ValuesCollection
,FloatIntHashMap
,FloatIntHashMap.ValuesCollection
,ImmutableByteIntEmptyMap
,ImmutableByteIntHashMap
,ImmutableByteIntSingletonMap
,ImmutableCharIntEmptyMap
,ImmutableCharIntHashMap
,ImmutableCharIntSingletonMap
,ImmutableDoubleIntEmptyMap
,ImmutableDoubleIntHashMap
,ImmutableDoubleIntSingletonMap
,ImmutableFloatIntEmptyMap
,ImmutableFloatIntHashMap
,ImmutableFloatIntSingletonMap
,ImmutableIntArrayList
,ImmutableIntArrayStack
,ImmutableIntEmptyBag
,ImmutableIntEmptyList
,ImmutableIntEmptySet
,ImmutableIntEmptyStack
,ImmutableIntHashBag
,ImmutableIntIntEmptyMap
,ImmutableIntIntHashMap
,ImmutableIntIntMapKeySet
,ImmutableIntIntSingletonMap
,ImmutableIntMapKeySet
,ImmutableIntSingletonBag
,ImmutableIntSingletonList
,ImmutableIntSingletonSet
,ImmutableIntSingletonStack
,ImmutableLongIntEmptyMap
,ImmutableLongIntHashMap
,ImmutableLongIntSingletonMap
,ImmutableObjectIntEmptyMap
,ImmutableObjectIntHashMap
,ImmutableObjectIntSingletonMap
,ImmutableShortIntEmptyMap
,ImmutableShortIntHashMap
,ImmutableShortIntSingletonMap
,IntArrayList
,IntArrayStack
,IntBooleanHashMap.KeySet
,IntBooleanHashMap.KeysView
,IntByteHashMap.KeySet
,IntByteHashMap.KeysView
,IntCharHashMap.KeySet
,IntCharHashMap.KeysView
,IntDoubleHashMap.KeySet
,IntDoubleHashMap.KeysView
,IntFloatHashMap.KeySet
,IntFloatHashMap.KeysView
,IntHashBag
,IntHashSet
,IntHashSet.ImmutableIntHashSet
,IntInterval
,IntIntHashMap
,IntIntHashMap.KeySet
,IntIntHashMap.KeysView
,IntIntHashMap.ValuesCollection
,IntLongHashMap.KeySet
,IntLongHashMap.KeysView
,IntObjectHashMap.KeySet
,IntObjectHashMap.KeysView
,IntShortHashMap.KeySet
,IntShortHashMap.KeysView
,LazyIntIterableAdapter
,LongIntHashMap
,LongIntHashMap.ValuesCollection
,ObjectIntHashMap
,ObjectIntHashMap.ValuesCollection
,ObjectIntHashMapWithHashingStrategy
,ObjectIntHashMapWithHashingStrategy.ValuesCollection
,ReverseIntIterable
,SelectIntIterable
,ShortIntHashMap
,ShortIntHashMap.ValuesCollection
,SynchronizedByteIntMap
,SynchronizedCharIntMap
,SynchronizedDoubleIntMap
,SynchronizedFloatIntMap
,SynchronizedIntBag
,SynchronizedIntCollection
,SynchronizedIntIntMap
,SynchronizedIntIterable
,SynchronizedIntList
,SynchronizedIntSet
,SynchronizedIntStack
,SynchronizedLongIntMap
,SynchronizedObjectIntMap
,SynchronizedShortIntMap
,TapIntIterable
,UnmodifiableByteIntMap
,UnmodifiableCharIntMap
,UnmodifiableDoubleIntMap
,UnmodifiableFloatIntMap
,UnmodifiableIntBag
,UnmodifiableIntCollection
,UnmodifiableIntIntMap
,UnmodifiableIntList
,UnmodifiableIntSet
,UnmodifiableIntStack
,UnmodifiableLongIntMap
,UnmodifiableObjectIntMap
,UnmodifiableShortIntMap
public interface IntIterable extends PrimitiveIterable
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
allSatisfy(IntPredicate predicate)
Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(IntPredicate predicate)
Returns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.LazyIntIterable
asLazy()
Returns a LazyIntIterable adapter wrapping the source IntIterable.double
average()
default double
averageIfEmpty(double defaultValue)
default RichIterable<IntIterable>
chunk(int size)
Partitions elements in fixed size chunks.<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.default <V,R extends java.util.Collection<V>>
Rcollect(IntToObjectFunction<? extends V> function, R target)
Same ascollect(IntToObjectFunction)
, only the results are added to the target Collection.default <R extends MutableBooleanCollection>
RcollectBoolean(IntToBooleanFunction function, R target)
Returns the targetMutableBooleanCollection
with the results of applying the specified function on each element of the source collection.default <R extends MutableByteCollection>
RcollectByte(IntToByteFunction function, R target)
Returns the targetMutableByteCollection
with the results of applying the specified function on each element of the source collection.default <R extends MutableCharCollection>
RcollectChar(IntToCharFunction function, R target)
Returns the targetMutableCharCollection
with the results of applying the specified function on each element of the source collection.default <R extends MutableDoubleCollection>
RcollectDouble(IntToDoubleFunction function, R target)
Returns the targetMutableDoubleCollection
with the results of applying the specified function on each element of the source collection.default <R extends MutableFloatCollection>
RcollectFloat(IntToFloatFunction function, R target)
Returns the targetMutableFloatCollection
with the results of applying the specified function on each element of the source collection.default <R extends MutableIntCollection>
RcollectInt(IntToIntFunction function, R target)
Returns the targetMutableIntCollection
with the results of applying the specified function on each element of the source collection.default <R extends MutableLongCollection>
RcollectLong(IntToLongFunction function, R target)
Returns the targetMutableLongCollection
with the results of applying the specified function on each element of the source collection.default <R extends MutableShortCollection>
RcollectShort(IntToShortFunction function, R target)
Returns the targetMutableShortCollection
with the results of applying the specified function on each element of the source collection.boolean
contains(int value)
Returns true if the value is contained in the IntIterable, and false if it is not.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.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.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.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.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.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.int
count(IntPredicate predicate)
Returns a count of the number of elements in the IntIterable that return true for the specified predicate.int
detectIfNone(IntPredicate predicate, int ifNone)
void
each(IntProcedure procedure)
A synonym for forEach.default <V,R extends java.util.Collection<V>>
RflatCollect(IntToObjectFunction<? extends java.lang.Iterable<V>> function, R target)
flatCollect
is a special case ofcollect(IntToObjectFunction)
.default void
forEach(IntProcedure procedure)
Applies the IntProcedure to each element in the IntIterable.<T> T
injectInto(T injectedValue, ObjectIntToObjectFunction<? super T,? extends T> function)
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.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.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.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.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.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.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.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.IntIterator
intIterator()
Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.int
max()
int
maxIfEmpty(int defaultValue)
double
median()
default double
medianIfEmpty(double defaultValue)
int
min()
int
minIfEmpty(int defaultValue)
default boolean
noneSatisfy(IntPredicate predicate)
Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.default long
reduce(LongIntToLongFunction accumulator)
default long
reduceIfEmpty(LongIntToLongFunction accumulator, long defaultValue)
IntIterable
reject(IntPredicate predicate)
Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.default <R extends MutableIntCollection>
Rreject(IntPredicate predicate, R target)
Same asreject(IntPredicate)
, only the results are added to the target MutableIntCollection.IntIterable
select(IntPredicate predicate)
Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.default <R extends MutableIntCollection>
Rselect(IntPredicate predicate, R target)
Same asselect(IntPredicate)
, only the results are added to the target MutableIntCollection.long
sum()
default java.util.IntSummaryStatistics
summaryStatistics()
default IntIterable
tap(IntProcedure procedure)
int[]
toArray()
Converts the IntIterable to a primitive int array.default int[]
toArray(int[] target)
Converts the IntIterable to a primitive int array.MutableIntBag
toBag()
Converts the IntIterable to a new MutableIntBag.MutableIntList
toList()
Converts the IntIterable to a new MutableIntList.MutableIntSet
toSet()
Converts the IntIterable to a new MutableIntSet.int[]
toSortedArray()
MutableIntList
toSortedList()
default MutableIntList
toSortedList(IntComparator comparator)
Converts the collection to a MutableIntList implementation sorted using the provided comparator.default <T> MutableIntList
toSortedListBy(IntToObjectFunction<T> function)
Converts the collection to a MutableIntListImplementation sorted based on the natural order of the key returned byfunction
.default <T> MutableIntList
toSortedListBy(IntToObjectFunction<T> function, java.util.Comparator<? super T> comparator)
Converts the collection to a MutableIntList implementation, which is sorted based on the key returned byfunction
using the providedcomparator
.-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, size, toString
-
-
-
-
Method Detail
-
intIterator
IntIterator intIterator()
Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.
-
toArray
int[] toArray()
Converts the IntIterable to a primitive int array.
-
toArray
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.
-
contains
boolean contains(int value)
Returns true if the value is contained in the IntIterable, and false if it is not.
-
containsAll
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.
-
containsAll
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.
-
containsAny
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
-
containsAny
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
-
containsNone
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
-
containsNone
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
-
forEach
default void forEach(IntProcedure procedure)
Applies the IntProcedure to each element in the IntIterable.
-
each
void each(IntProcedure procedure)
A synonym for forEach.- Since:
- 7.0.
-
tap
default IntIterable tap(IntProcedure procedure)
- Since:
- 9.0.
-
select
IntIterable select(IntPredicate predicate)
Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.
-
reject
IntIterable reject(IntPredicate predicate)
Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.
-
select
default <R extends MutableIntCollection> R select(IntPredicate predicate, R target)
Same asselect(IntPredicate)
, only the results are added to the target MutableIntCollection.- Since:
- 8.1.
-
reject
default <R extends MutableIntCollection> R reject(IntPredicate predicate, R target)
Same asreject(IntPredicate)
, only the results are added to the target MutableIntCollection.- Since:
- 8.1.
-
collect
<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.
-
collect
default <V,R extends java.util.Collection<V>> R collect(IntToObjectFunction<? extends V> function, R target)
Same ascollect(IntToObjectFunction)
, only the results are added to the target Collection.- Since:
- 8.1.
-
flatCollect
default <V,R extends java.util.Collection<V>> R flatCollect(IntToObjectFunction<? extends java.lang.Iterable<V>> function, R target)
flatCollect
is a special case ofcollect(IntToObjectFunction)
. Withcollect
, when theIntToObjectFunction
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.
-
collectBoolean
default <R extends MutableBooleanCollection> R collectBoolean(IntToBooleanFunction function, R target)
Returns the targetMutableBooleanCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectByte
default <R extends MutableByteCollection> R collectByte(IntToByteFunction function, R target)
Returns the targetMutableByteCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectChar
default <R extends MutableCharCollection> R collectChar(IntToCharFunction function, R target)
Returns the targetMutableCharCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectShort
default <R extends MutableShortCollection> R collectShort(IntToShortFunction function, R target)
Returns the targetMutableShortCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectInt
default <R extends MutableIntCollection> R collectInt(IntToIntFunction function, R target)
Returns the targetMutableIntCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectFloat
default <R extends MutableFloatCollection> R collectFloat(IntToFloatFunction function, R target)
Returns the targetMutableFloatCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectLong
default <R extends MutableLongCollection> R collectLong(IntToLongFunction function, R target)
Returns the targetMutableLongCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectDouble
default <R extends MutableDoubleCollection> R collectDouble(IntToDoubleFunction function, R target)
Returns the targetMutableDoubleCollection
with the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
detectIfNone
int detectIfNone(IntPredicate predicate, int ifNone)
-
count
int count(IntPredicate predicate)
Returns a count of the number of elements in the IntIterable that return true for the specified predicate.
-
anySatisfy
boolean anySatisfy(IntPredicate predicate)
Returns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.
-
allSatisfy
boolean allSatisfy(IntPredicate predicate)
Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.
-
noneSatisfy
default boolean noneSatisfy(IntPredicate predicate)
Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.
-
toList
MutableIntList toList()
Converts the IntIterable to a new MutableIntList.
-
toSet
MutableIntSet toSet()
Converts the IntIterable to a new MutableIntSet.
-
toBag
MutableIntBag toBag()
Converts the IntIterable to a new MutableIntBag.
-
asLazy
LazyIntIterable asLazy()
Returns a LazyIntIterable adapter wrapping the source IntIterable.
-
injectInto
<T> T injectInto(T injectedValue, ObjectIntToObjectFunction<? super T,? extends T> function)
-
injectIntoBoolean
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
-
injectIntoByte
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
-
injectIntoChar
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
-
injectIntoShort
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
-
injectIntoInt
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
-
injectIntoFloat
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
-
injectIntoLong
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
-
injectIntoDouble
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
-
reduceIfEmpty
default long reduceIfEmpty(LongIntToLongFunction accumulator, long defaultValue)
- Since:
- 10.0
- See Also:
reduce(LongIntToLongFunction)
-
reduce
default long reduce(LongIntToLongFunction accumulator)
- Since:
- 10.0
- See Also:
RichIterable.reduce(BinaryOperator)
-
chunk
default RichIterable<IntIterable> chunk(int size)
Partitions elements in fixed size chunks.- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingIntIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly. - Since:
- 9.2
-
sum
long sum()
-
summaryStatistics
default java.util.IntSummaryStatistics summaryStatistics()
- Since:
- 8.0
-
max
int max()
-
maxIfEmpty
int maxIfEmpty(int defaultValue)
-
min
int min()
-
minIfEmpty
int minIfEmpty(int defaultValue)
-
average
double average()
-
averageIfEmpty
default double averageIfEmpty(double defaultValue)
- Since:
- 9.0
-
median
double median()
-
medianIfEmpty
default double medianIfEmpty(double defaultValue)
- Since:
- 9.0
-
toSortedArray
int[] toSortedArray()
-
toSortedList
MutableIntList toSortedList()
-
toSortedList
default MutableIntList toSortedList(IntComparator comparator)
Converts the collection to a MutableIntList implementation sorted using the provided comparator.
-
toSortedListBy
default <T> MutableIntList toSortedListBy(IntToObjectFunction<T> function)
Converts the collection to a MutableIntListImplementation sorted based on the natural order of the key returned byfunction
.
-
toSortedListBy
default <T> MutableIntList toSortedListBy(IntToObjectFunction<T> function, java.util.Comparator<? super T> comparator)
Converts the collection to a MutableIntList implementation, which is sorted based on the key returned byfunction
using the providedcomparator
.
-
-