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,AbstractSynchronizedLongCollection,AbstractUnmodifiableLongCollection,ByteLongHashMap,CharLongHashMap,CollectBooleanToLongIterable,CollectByteToLongIterable,CollectCharToLongIterable,CollectDoubleToLongIterable,CollectFloatToLongIterable,CollectIntToLongIterable,CollectLongIterable,CollectLongToLongIterable,CollectShortToLongIterable,DoubleLongHashMap,FloatLongHashMap,IntLongHashMap,LazyLongIterableAdapter,LongArrayList,LongArrayStack,LongHashBag,LongHashSet,LongInterval,LongLongHashMap,ObjectLongHashMap,ObjectLongHashMapWithHashingStrategy,ReverseLongIterable,SelectLongIterable,ShortLongHashMap,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
Modifier and Type Method Description booleanallSatisfy(LongPredicate predicate)Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(LongPredicate predicate)Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.LazyLongIterableasLazy()Returns a LazyLongIterable adapter wrapping the source LongIterable.doubleaverage()default doubleaverageIfEmpty(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 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 targetMutableBooleanCollectionwith 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 targetMutableByteCollectionwith 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 targetMutableCharCollectionwith 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 targetMutableDoubleCollectionwith 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 targetMutableFloatCollectionwith 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 targetMutableIntCollectionwith 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 targetMutableLongCollectionwith 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 targetMutableShortCollectionwith the results of applying the specified function on each element of the source collection.booleancontains(long value)Returns true if the value is contained in the LongIterable, and false if it is not.booleancontainsAll(long... source)Returns true if the all of the values specified in the source array are contained in the LongIterable, and false if they are not.booleancontainsAll(LongIterable source)Returns true if the all of the values specified in the source LongIterable are contained in the LongIterable, and false if they are not.intcount(LongPredicate predicate)Returns a count of the number of elements in the LongIterable that return true for the specified predicate.longdetectIfNone(LongPredicate predicate, long ifNone)voideach(LongProcedure procedure)A synonym for forEach.default <V, R extends Collection<V>>
RflatCollect(LongToObjectFunction<? extends Iterable<V>> function, R target)flatCollectis a special case ofcollect(LongToObjectFunction).voidforEach(LongProcedure procedure)Applies the LongProcedure to each element in the LongIterable.<T> TinjectInto(T injectedValue, ObjectLongToObjectFunction<? super T,? extends T> function)LongIteratorlongIterator()Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.longmax()longmaxIfEmpty(long defaultValue)doublemedian()default doublemedianIfEmpty(double defaultValue)longmin()longminIfEmpty(long defaultValue)booleannoneSatisfy(LongPredicate predicate)Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.default longreduce(LongLongToLongFunction accumulator)default longreduceIfEmpty(LongLongToLongFunction accumulator, long defaultValue)LongIterablereject(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.LongIterableselect(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.longsum()default LongSummaryStatisticssummaryStatistics()default LongIterabletap(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.MutableLongBagtoBag()Converts the LongIterable to a new MutableLongBag.MutableLongListtoList()Converts the LongIterable to a new MutableLongList.MutableLongSettoSet()Converts the LongIterable to a new MutableLongSet.long[]toSortedArray()MutableLongListtoSortedList()Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, size, toString
-
Method Details
-
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
boolean containsAll(long... source)Returns true if the all of the values specified in the source array are contained in the LongIterable, and false if they are not. -
containsAll
Returns true if the all of the values specified in the source LongIterable are contained in the LongIterable, and false if they are not. -
forEach
Applies the LongProcedure to each element in the LongIterable. -
each
A synonym for forEach.- Since:
- 7.0.
-
tap
- Since:
- 9.0.
-
select
Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate. -
reject
Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate. -
select
Same asselect(LongPredicate), only the results are added to the target MutableLongCollection.- Since:
- 8.1.
-
reject
Same asreject(LongPredicate), only the results are added to the target MutableLongCollection.- Since:
- 8.1.
-
collect
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 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 Collection<V>> R flatCollect(LongToObjectFunction<? extends Iterable<V>> function, R target)flatCollectis a special case ofcollect(LongToObjectFunction). Withcollect, when theLongToObjectFunctionreturns a collection, the result is a collection of collections.flatCollectoutputs 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 targetMutableBooleanCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectByte
Returns the targetMutableByteCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectChar
Returns the targetMutableCharCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectShort
Returns the targetMutableShortCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectInt
Returns the targetMutableIntCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectFloat
Returns the targetMutableFloatCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectLong
Returns the targetMutableLongCollectionwith 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 targetMutableDoubleCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
detectIfNone
-
count
Returns a count of the number of elements in the LongIterable that return true for the specified predicate. -
anySatisfy
Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false. -
allSatisfy
Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false. -
noneSatisfy
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
-
reduceIfEmpty
- Since:
- 10.0
- See Also:
reduce(LongLongToLongFunction)
-
reduce
- Since:
- 10.0
- See Also:
RichIterable.reduce(BinaryOperator)
-
chunk
Partitions elements in fixed size chunks.- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingLongIterables of sizesize, except the last will be truncated if the elements don't divide evenly. - Since:
- 9.2
-
sum
long sum() -
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()
-