Top Description Methods
org.eclipse.collections.api

public Interface LongIterable

extends PrimitiveIterable
Known Direct Subinterfaces
org.eclipse.collections.api.bag.primitive.LongBag, org.eclipse.collections.api.collection.primitive.ImmutableLongCollection, org.eclipse.collections.api.collection.primitive.MutableLongCollection, org.eclipse.collections.api.map.primitive.ObjectLongMap, org.eclipse.collections.api.map.primitive.LongValuesMap, org.eclipse.collections.api.ordered.primitive.OrderedLongIterable, org.eclipse.collections.api.set.primitive.LongSet, org.eclipse.collections.api.LazyLongIterable
Imports
java.util.Collection, .NoSuchElementException, .LongSummaryStatistics, .Comparator, org.eclipse.collections.api.block.comparator.primitive.LongComparator, org.eclipse.collections.api.bag.primitive.MutableLongBag, org.eclipse.collections.api.block.function.primitive.LongToBooleanFunction, .LongToByteFunction, .LongToShortFunction, .LongToCharFunction, .LongToDoubleFunction, .LongToFloatFunction, .LongToIntFunction, .LongToLongFunction, .LongToObjectFunction, .BooleanLongToBooleanFunction, .ByteLongToByteFunction, .CharLongToCharFunction, .DoubleLongToDoubleFunction, .FloatLongToFloatFunction, .IntLongToIntFunction, .LongLongToLongFunction, .ObjectLongToObjectFunction, .ShortLongToShortFunction, org.eclipse.collections.api.block.predicate.primitive.LongPredicate, org.eclipse.collections.api.block.procedure.primitive.LongProcedure, org.eclipse.collections.api.collection.primitive.MutableBooleanCollection, .MutableByteCollection, .MutableCharCollection, .MutableDoubleCollection, .MutableFloatCollection, .MutableIntCollection, .MutableLongCollection, .MutableShortCollection, org.eclipse.collections.api.iterator.LongIterator, org.eclipse.collections.api.list.primitive.MutableLongList, org.eclipse.collections.api.set.primitive.LongSet, .MutableLongSet

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

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

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

public boolean
anySatisfy(LongPredicate predicate)

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

public LazyLongIterable
asLazy()

Returns a LazyLongIterable adapter wrapping the source LongIterable.

public double
public default double
averageIfEmpty(double defaultValue)

public default RichIterable<LongIterable>

Returns:

A RichIterable containing LongIterables 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(LongToObjectFunction<? 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(LongToObjectFunction<? extends V> function, R target)

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

public default <R extends MutableBooleanCollection> R
collectBoolean(LongToBooleanFunction 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(LongToByteFunction 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(LongToCharFunction 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(LongToDoubleFunction 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(LongToFloatFunction 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(LongToIntFunction 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(LongToLongFunction 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(LongToShortFunction 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(long value)

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

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

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

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

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

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

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

public int
count(LongPredicate predicate)

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

public long
detectIfNone(LongPredicate predicate, long ifNone)

public void
each(LongProcedure procedure)

A synonym for forEach.

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

flatCollect is a special case of collect(LongToObjectFunction).

public default void
forEach(LongProcedure procedure)

Applies the LongProcedure to each element in the LongIterable.

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

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

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

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

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

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

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

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

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

public LongIterator
longIterator()

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

public long
max()

public long
maxIfEmpty(long defaultValue)

public double
public default double
medianIfEmpty(double defaultValue)

public long
min()

public long
minIfEmpty(long defaultValue)

public default boolean
noneSatisfy(LongPredicate predicate)

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

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

public LongIterable
reject(LongPredicate predicate)

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

public default <R extends MutableLongCollection> R
reject(LongPredicate predicate, R target)

Same as reject(LongPredicate) , only the results are added to the target MutableLongCollection.

public LongIterable
select(LongPredicate predicate)

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

public default <R extends MutableLongCollection> R
select(LongPredicate predicate, R target)

Same as select(LongPredicate) , only the results are added to the target MutableLongCollection.

public long
sum()

public default LongSummaryStatistics
public default LongIterable
tap(LongProcedure procedure)

public long[]
toArray()

Converts the LongIterable to a primitive long array.

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

Converts the LongIterable to a primitive long array.

public MutableLongBag
toBag()

Converts the LongIterable to a new MutableLongBag.

public MutableLongList
toList()

Converts the LongIterable to a new MutableLongList.

public MutableLongSet
toSet()

Converts the LongIterable to a new MutableLongSet.

public long[]
public MutableLongList
public default MutableLongList
toSortedList(LongComparator comparator)

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

public default <T> MutableLongList
toSortedListBy(LongToObjectFunction<T> function)

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

public default <T> MutableLongList
toSortedListBy(LongToObjectFunction<T> function, Comparator<? super T> comparator)

Converts the collection to a MutableLongList 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(LongPredicate predicate)

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

anySatisfyback to summary
public boolean anySatisfy(LongPredicate predicate)

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

asLazyback to summary
public LazyLongIterable asLazy()

Returns a LazyLongIterable adapter wrapping the source LongIterable.

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

Partitions elements in fixed size chunks.

Parameters
size:int

the number of elements per chunk

Returns:RichIterable<LongIterable>

A RichIterable containing LongIterables 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(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.

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

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

Since
8.1.
collectBooleanback to summary
public default <R extends MutableBooleanCollection> R collectBoolean(LongToBooleanFunction 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(LongToByteFunction 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(LongToCharFunction 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(LongToDoubleFunction 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(LongToFloatFunction 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(LongToIntFunction 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(LongToLongFunction 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(LongToShortFunction 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(long value)

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

containsAllback to summary
public 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.

containsAllback to summary
public 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.

containsAnyback to summary
public 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
containsAnyback to summary
public 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
containsNoneback to summary
public 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
containsNoneback to summary
public 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
countback to summary
public int count(LongPredicate predicate)

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

detectIfNoneback to summary
public long detectIfNone(LongPredicate predicate, long ifNone)
eachback to summary
public void each(LongProcedure procedure)

A synonym for forEach.

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

flatCollect is a special case of collect(LongToObjectFunction). With collect, when the LongToObjectFunction 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(LongProcedure procedure)

Applies the LongProcedure to each element in the LongIterable.

injectIntoback to summary
public <T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T, ? extends T> function)
injectIntoBooleanback to summary
public 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
injectIntoByteback to summary
public 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
injectIntoCharback to summary
public 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
injectIntoDoubleback to summary
public 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
injectIntoFloatback to summary
public 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
injectIntoIntback to summary
public 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
injectIntoLongback to summary
public 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
injectIntoShortback to summary
public 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
longIteratorback to summary
public LongIterator longIterator()

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

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

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

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

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

rejectback to summary
public default <R extends MutableLongCollection> R reject(LongPredicate predicate, R target)

Same as reject(LongPredicate) , only the results are added to the target MutableLongCollection.

Since
8.1.
selectback to summary
public LongIterable select(LongPredicate predicate)

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

selectback to summary
public default <R extends MutableLongCollection> R select(LongPredicate predicate, R target)

Same as select(LongPredicate) , only the results are added to the target MutableLongCollection.

Since
8.1.
sumback to summary
public long sum()
summaryStatisticsback to summary
public default LongSummaryStatistics summaryStatistics()
Since
8.0
tapback to summary
public default LongIterable tap(LongProcedure procedure)
Since
9.0.
toArrayback to summary
public long[] toArray()

Converts the LongIterable to a primitive long array.

toArrayback to summary
public 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.

toBagback to summary
public MutableLongBag toBag()

Converts the LongIterable to a new MutableLongBag.

toListback to summary
public MutableLongList toList()

Converts the LongIterable to a new MutableLongList.

toSetback to summary
public MutableLongSet toSet()

Converts the LongIterable to a new MutableLongSet.

toSortedArrayback to summary
public long[] toSortedArray()
toSortedListback to summary
public MutableLongList toSortedList()
toSortedListback to summary
public default MutableLongList toSortedList(LongComparator comparator)

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

toSortedListByback to summary
public default <T> MutableLongList toSortedListBy(LongToObjectFunction<T> function)

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

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

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