Package org.eclipse.collections.api
Interface LongIterable
-
- All Superinterfaces:
PrimitiveIterable
- All Known Subinterfaces:
ByteLongMap
,CharLongMap
,DoubleLongMap
,FloatLongMap
,ImmutableByteLongMap
,ImmutableCharLongMap
,ImmutableDoubleLongMap
,ImmutableFloatLongMap
,ImmutableIntLongMap
,ImmutableLongBag
,ImmutableLongCollection
,ImmutableLongList
,ImmutableLongLongMap
,ImmutableLongSet
,ImmutableLongStack
,ImmutableObjectLongMap<K>
,ImmutableShortLongMap
,IntLongMap
,LazyLongIterable
,LongBag
,LongList
,LongLongMap
,LongSet
,LongStack
,LongValuesMap
,MutableByteLongMap
,MutableCharLongMap
,MutableDoubleLongMap
,MutableFloatLongMap
,MutableIntLongMap
,MutableLongBag
,MutableLongCollection
,MutableLongList
,MutableLongLongMap
,MutableLongSet
,MutableLongStack
,MutableLongValuesMap
,MutableObjectLongMap<K>
,MutableShortLongMap
,ObjectLongMap<K>
,OrderedLongIterable
,ReversibleLongIterable
,ShortLongMap
- All Known Implementing Classes:
AbstractImmutableLongSet
,AbstractImmutableObjectLongMap
,AbstractLazyLongIterable
,AbstractLongIterable
,AbstractLongSet
,AbstractLongStack
,AbstractMutableLongKeySet
,AbstractMutableLongValuesMap
,AbstractMutableLongValuesMap.AbstractLongValuesCollection
,AbstractSynchronizedLongCollection
,AbstractUnmodifiableLongCollection
,ByteLongHashMap
,ByteLongHashMap.ValuesCollection
,CharLongHashMap
,CharLongHashMap.ValuesCollection
,CollectBooleanToLongIterable
,CollectByteToLongIterable
,CollectCharToLongIterable
,CollectDoubleToLongIterable
,CollectFloatToLongIterable
,CollectIntToLongIterable
,CollectLongIterable
,CollectLongToLongIterable
,CollectShortToLongIterable
,DoubleLongHashMap
,DoubleLongHashMap.ValuesCollection
,FloatLongHashMap
,FloatLongHashMap.ValuesCollection
,ImmutableByteLongEmptyMap
,ImmutableByteLongHashMap
,ImmutableByteLongSingletonMap
,ImmutableCharLongEmptyMap
,ImmutableCharLongHashMap
,ImmutableCharLongSingletonMap
,ImmutableDoubleLongEmptyMap
,ImmutableDoubleLongHashMap
,ImmutableDoubleLongSingletonMap
,ImmutableFloatLongEmptyMap
,ImmutableFloatLongHashMap
,ImmutableFloatLongSingletonMap
,ImmutableIntLongEmptyMap
,ImmutableIntLongHashMap
,ImmutableIntLongSingletonMap
,ImmutableLongArrayList
,ImmutableLongArrayStack
,ImmutableLongEmptyBag
,ImmutableLongEmptyList
,ImmutableLongEmptySet
,ImmutableLongEmptyStack
,ImmutableLongHashBag
,ImmutableLongLongEmptyMap
,ImmutableLongLongHashMap
,ImmutableLongLongMapKeySet
,ImmutableLongLongSingletonMap
,ImmutableLongMapKeySet
,ImmutableLongSingletonBag
,ImmutableLongSingletonList
,ImmutableLongSingletonSet
,ImmutableLongSingletonStack
,ImmutableObjectLongEmptyMap
,ImmutableObjectLongHashMap
,ImmutableObjectLongSingletonMap
,ImmutableShortLongEmptyMap
,ImmutableShortLongHashMap
,ImmutableShortLongSingletonMap
,IntLongHashMap
,IntLongHashMap.ValuesCollection
,LazyLongIterableAdapter
,LongArrayList
,LongArrayStack
,LongBooleanHashMap.KeySet
,LongBooleanHashMap.KeysView
,LongByteHashMap.KeySet
,LongByteHashMap.KeysView
,LongCharHashMap.KeySet
,LongCharHashMap.KeysView
,LongDoubleHashMap.KeySet
,LongDoubleHashMap.KeysView
,LongFloatHashMap.KeySet
,LongFloatHashMap.KeysView
,LongHashBag
,LongHashSet
,LongHashSet.ImmutableLongHashSet
,LongInterval
,LongIntHashMap.KeySet
,LongIntHashMap.KeysView
,LongLongHashMap
,LongLongHashMap.KeySet
,LongLongHashMap.KeysView
,LongLongHashMap.ValuesCollection
,LongObjectHashMap.KeySet
,LongObjectHashMap.KeysView
,LongShortHashMap.KeySet
,LongShortHashMap.KeysView
,ObjectLongHashMap
,ObjectLongHashMap.ValuesCollection
,ObjectLongHashMapWithHashingStrategy
,ObjectLongHashMapWithHashingStrategy.ValuesCollection
,ReverseLongIterable
,SelectLongIterable
,ShortLongHashMap
,ShortLongHashMap.ValuesCollection
,SynchronizedByteLongMap
,SynchronizedCharLongMap
,SynchronizedDoubleLongMap
,SynchronizedFloatLongMap
,SynchronizedIntLongMap
,SynchronizedLongBag
,SynchronizedLongCollection
,SynchronizedLongIterable
,SynchronizedLongList
,SynchronizedLongLongMap
,SynchronizedLongSet
,SynchronizedLongStack
,SynchronizedObjectLongMap
,SynchronizedShortLongMap
,TapLongIterable
,UnmodifiableByteLongMap
,UnmodifiableCharLongMap
,UnmodifiableDoubleLongMap
,UnmodifiableFloatLongMap
,UnmodifiableIntLongMap
,UnmodifiableLongBag
,UnmodifiableLongCollection
,UnmodifiableLongList
,UnmodifiableLongLongMap
,UnmodifiableLongSet
,UnmodifiableLongStack
,UnmodifiableObjectLongMap
,UnmodifiableShortLongMap
public interface LongIterable extends PrimitiveIterable
LongIterable is an interface which is memory-optimized for long 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 LongIterator. LongIterator helps iterate over the LongIterable 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(LongPredicate predicate)
Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(LongPredicate predicate)
Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.LazyLongIterable
asLazy()
Returns a LazyLongIterable adapter wrapping the source LongIterable.double
average()
default double
averageIfEmpty(double defaultValue)
default RichIterable<LongIterable>
chunk(int size)
Partitions elements in fixed size chunks.<V> RichIterable<V>
collect(LongToObjectFunction<? 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(LongToObjectFunction<? extends V> function, R target)
Same ascollect(LongToObjectFunction)
, only the results are added to the target Collection.default <R extends MutableBooleanCollection>
RcollectBoolean(LongToBooleanFunction 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(LongToByteFunction 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(LongToCharFunction 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(LongToDoubleFunction 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(LongToFloatFunction 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(LongToIntFunction 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(LongToLongFunction 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(LongToShortFunction function, R target)
Returns the targetMutableShortCollection
with the results of applying the specified function on each element of the source collection.boolean
contains(long value)
Returns true if the value is contained in the LongIterable, and false if it is not.default boolean
containsAll(long... source)
Returns true if all of the values specified in the source array are contained in the LongIterable, and false if they are not.default boolean
containsAll(LongIterable source)
Returns true if all of the values specified in the source LongIterable are contained in the LongIterable, and false if they are not.default boolean
containsAny(long... source)
Returns true if any of the values specified in the source array are contained in the LongIterable, and false if they are not.default boolean
containsAny(LongIterable source)
Returns true if any of the values specified in the source LongIterable are contained in the LongIterable, and false if they are not.default boolean
containsNone(long... source)
Returns true if none of the values specified in the source array are contained in the LongIterable, and false if they are.default boolean
containsNone(LongIterable source)
Returns true if none of the values specified in the source LongIterable are contained in the LongIterable, and false if they are.int
count(LongPredicate predicate)
Returns a count of the number of elements in the LongIterable that return true for the specified predicate.long
detectIfNone(LongPredicate predicate, long ifNone)
void
each(LongProcedure procedure)
A synonym for forEach.default <V,R extends java.util.Collection<V>>
RflatCollect(LongToObjectFunction<? extends java.lang.Iterable<V>> function, R target)
flatCollect
is a special case ofcollect(LongToObjectFunction)
.default void
forEach(LongProcedure procedure)
Applies the LongProcedure to each element in the LongIterable.<T> T
injectInto(T injectedValue, ObjectLongToObjectFunction<? super T,? extends T> function)
default boolean
injectIntoBoolean(boolean injectedValue, BooleanLongToBooleanFunction 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, ByteLongToByteFunction 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, CharLongToCharFunction 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, DoubleLongToDoubleFunction 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, FloatLongToFloatFunction 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, IntLongToIntFunction 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, LongLongToLongFunction 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, ShortLongToShortFunction function)
Returns the final short result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.LongIterator
longIterator()
Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.long
max()
long
maxIfEmpty(long defaultValue)
double
median()
default double
medianIfEmpty(double defaultValue)
long
min()
long
minIfEmpty(long defaultValue)
default boolean
noneSatisfy(LongPredicate predicate)
Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.default long
reduce(LongLongToLongFunction accumulator)
default long
reduceIfEmpty(LongLongToLongFunction accumulator, long defaultValue)
LongIterable
reject(LongPredicate predicate)
Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.default <R extends MutableLongCollection>
Rreject(LongPredicate predicate, R target)
Same asreject(LongPredicate)
, only the results are added to the target MutableLongCollection.LongIterable
select(LongPredicate predicate)
Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.default <R extends MutableLongCollection>
Rselect(LongPredicate predicate, R target)
Same asselect(LongPredicate)
, only the results are added to the target MutableLongCollection.long
sum()
default java.util.LongSummaryStatistics
summaryStatistics()
default LongIterable
tap(LongProcedure procedure)
long[]
toArray()
Converts the LongIterable to a primitive long array.default long[]
toArray(long[] target)
Converts the LongIterable to a primitive long array.MutableLongBag
toBag()
Converts the LongIterable to a new MutableLongBag.MutableLongList
toList()
Converts the LongIterable to a new MutableLongList.MutableLongSet
toSet()
Converts the LongIterable to a new MutableLongSet.long[]
toSortedArray()
MutableLongList
toSortedList()
default MutableLongList
toSortedList(LongComparator comparator)
Converts the collection to a MutableLongList implementation sorted using the provided comparator.default <T> MutableLongList
toSortedListBy(LongToObjectFunction<T> function)
Converts the collection to a MutableLongListImplementation sorted based on the natural order of the key returned byfunction
.default <T> MutableLongList
toSortedListBy(LongToObjectFunction<T> function, java.util.Comparator<? super T> comparator)
Converts the collection to a MutableLongList 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
-
longIterator
LongIterator longIterator()
Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.
-
toArray
long[] toArray()
Converts the LongIterable to a primitive long array.
-
toArray
default long[] toArray(long[] target)
Converts the LongIterable to a primitive long 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(long value)
Returns true if the value is contained in the LongIterable, and false if it is not.
-
containsAll
default boolean containsAll(long... source)
Returns true if all of the values specified in the source array are contained in the LongIterable, and false if they are not.
-
containsAll
default boolean containsAll(LongIterable source)
Returns true if all of the values specified in the source LongIterable are contained in the LongIterable, and false if they are not.
-
containsAny
default boolean containsAny(long... source)
Returns true if any of the values specified in the source array are contained in the LongIterable, and false if they are not.- Since:
- 11.0
-
containsAny
default boolean containsAny(LongIterable source)
Returns true if any of the values specified in the source LongIterable are contained in the LongIterable, and false if they are not.- Since:
- 11.0
-
containsNone
default boolean containsNone(long... source)
Returns true if none of the values specified in the source array are contained in the LongIterable, and false if they are.- Since:
- 11.0
-
containsNone
default boolean containsNone(LongIterable source)
Returns true if none of the values specified in the source LongIterable are contained in the LongIterable, and false if they are.- Since:
- 11.0
-
forEach
default void forEach(LongProcedure procedure)
Applies the LongProcedure to each element in the LongIterable.
-
each
void each(LongProcedure procedure)
A synonym for forEach.- Since:
- 7.0.
-
tap
default LongIterable tap(LongProcedure procedure)
- Since:
- 9.0.
-
select
LongIterable select(LongPredicate predicate)
Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.
-
reject
LongIterable reject(LongPredicate predicate)
Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.
-
select
default <R extends MutableLongCollection> R select(LongPredicate predicate, R target)
Same asselect(LongPredicate)
, only the results are added to the target MutableLongCollection.- Since:
- 8.1.
-
reject
default <R extends MutableLongCollection> R reject(LongPredicate predicate, R target)
Same asreject(LongPredicate)
, only the results are added to the target MutableLongCollection.- Since:
- 8.1.
-
collect
<V> RichIterable<V> collect(LongToObjectFunction<? 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(LongToObjectFunction<? extends V> function, R target)
Same ascollect(LongToObjectFunction)
, only the results are added to the target Collection.- Since:
- 8.1.
-
flatCollect
default <V,R extends java.util.Collection<V>> R flatCollect(LongToObjectFunction<? extends java.lang.Iterable<V>> function, R target)
flatCollect
is a special case ofcollect(LongToObjectFunction)
. Withcollect
, when theLongToObjectFunction
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(LongToBooleanFunction 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(LongToByteFunction 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(LongToCharFunction 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(LongToShortFunction 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(LongToIntFunction 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(LongToFloatFunction 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(LongToLongFunction 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(LongToDoubleFunction 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
long detectIfNone(LongPredicate predicate, long ifNone)
-
count
int count(LongPredicate predicate)
Returns a count of the number of elements in the LongIterable that return true for the specified predicate.
-
anySatisfy
boolean anySatisfy(LongPredicate predicate)
Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.
-
allSatisfy
boolean allSatisfy(LongPredicate predicate)
Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.
-
noneSatisfy
default boolean noneSatisfy(LongPredicate predicate)
Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.
-
toList
MutableLongList toList()
Converts the LongIterable to a new MutableLongList.
-
toSet
MutableLongSet toSet()
Converts the LongIterable to a new MutableLongSet.
-
toBag
MutableLongBag toBag()
Converts the LongIterable to a new MutableLongBag.
-
asLazy
LazyLongIterable asLazy()
Returns a LazyLongIterable adapter wrapping the source LongIterable.
-
injectInto
<T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T,? extends T> function)
-
injectIntoBoolean
default boolean injectIntoBoolean(boolean injectedValue, BooleanLongToBooleanFunction 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, ByteLongToByteFunction 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, CharLongToCharFunction 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, ShortLongToShortFunction 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, IntLongToIntFunction 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, FloatLongToFloatFunction 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, LongLongToLongFunction 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, DoubleLongToDoubleFunction 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(LongLongToLongFunction accumulator, long defaultValue)
- Since:
- 10.0
- See Also:
reduce(LongLongToLongFunction)
-
reduce
default long reduce(LongLongToLongFunction accumulator)
- Since:
- 10.0
- See Also:
RichIterable.reduce(BinaryOperator)
-
chunk
default RichIterable<LongIterable> chunk(int size)
Partitions elements in fixed size chunks.- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingLongIterable
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.LongSummaryStatistics summaryStatistics()
- Since:
- 8.0
-
max
long max()
-
maxIfEmpty
long maxIfEmpty(long defaultValue)
-
min
long min()
-
minIfEmpty
long minIfEmpty(long 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
long[] toSortedArray()
-
toSortedList
MutableLongList toSortedList()
-
toSortedList
default MutableLongList toSortedList(LongComparator comparator)
Converts the collection to a MutableLongList implementation sorted using the provided comparator.
-
toSortedListBy
default <T> MutableLongList toSortedListBy(LongToObjectFunction<T> function)
Converts the collection to a MutableLongListImplementation sorted based on the natural order of the key returned byfunction
.
-
toSortedListBy
default <T> MutableLongList toSortedListBy(LongToObjectFunction<T> function, java.util.Comparator<? super T> comparator)
Converts the collection to a MutableLongList implementation, which is sorted based on the key returned byfunction
using the providedcomparator
.
-
-