public abstract class LongStream
extends java.lang.Object
long
primitive specialization of
Stream
.
The following example illustrates an aggregate operation using
Stream
and LongStream
, computing the sum of the weights of the
red widgets:
long sum = widgets.stream()
.filter(w -> w.getColor() == RED)
.mapToLong(w -> w.getWeight())
.sum();
See the class documentation for Stream
and the package documentation
for java.util.stream for additional
specification of streams, stream operations, stream pipelines, and
parallelism.Stream
,
java.util.streamModifier and Type | Class and Description |
---|---|
static class |
LongStream.LongStreamEx |
BaseStream.Splitor
Modifier and Type | Method and Description |
---|---|
<R> R |
__(Function<? super LongStream,R> transfer) |
abstract <E extends java.lang.Exception> |
allMatch(Try.LongPredicate<E> predicate) |
abstract <E extends java.lang.Exception> |
anyMatch(Try.LongPredicate<E> predicate) |
abstract DoubleStream |
asDoubleStream()
Returns a
DoubleStream consisting of the elements of this stream,
converted to double . |
abstract FloatStream |
asFloatStream()
Returns a
FloatStream consisting of the elements of this stream,
converted to double . |
abstract OptionalDouble |
average()
Returns an
OptionalDouble describing the arithmetic mean of elements of
this stream, or an empty optional if this stream is empty. |
abstract Stream<java.lang.Long> |
boxed()
Returns a
Stream consisting of the elements of this stream,
each boxed to a Long . |
S |
carry(C action)
Same as
peek |
void |
close()
Closes this stream, causing all close handlers for this stream pipeline
to be called.
|
abstract LongStream |
collapse(LongBiPredicate collapsible,
LongBiFunction<java.lang.Long> mergeFunction) |
abstract <R> R |
collect(Supplier<R> supplier,
ObjLongConsumer<R> accumulator) |
abstract <R> R |
collect(Supplier<R> supplier,
ObjLongConsumer<R> accumulator,
BiConsumer<R,R> combiner)
Performs a mutable
reduction operation on the elements of this stream.
|
static LongStream |
concat(java.util.Collection<? extends LongStream> c) |
static LongStream |
concat(long[]... a) |
static LongStream |
concat(LongIterator... a) |
static LongStream |
concat(LongStream... a) |
static LongStream |
empty() |
abstract <E extends java.lang.Exception> |
findAny(Try.LongPredicate<E> predicate) |
abstract <E extends java.lang.Exception> |
findFirst(Try.LongPredicate<E> predicate) |
abstract <E extends java.lang.Exception,E2 extends java.lang.Exception> |
findFirstOrLast(Try.LongPredicate<E> predicateForFirst,
Try.LongPredicate<E> predicateForLast) |
abstract <E extends java.lang.Exception> |
findLast(Try.LongPredicate<E> predicate) |
abstract LongStream |
flatMap(LongFunction<? extends LongStream> mapper)
Returns a stream consisting of the results of replacing each element of
this stream with the contents of a mapped stream produced by applying
the provided mapping function to each element.
|
abstract DoubleStream |
flatMapToDouble(LongFunction<? extends DoubleStream> mapper) |
abstract FloatStream |
flatMapToFloat(LongFunction<? extends FloatStream> mapper) |
abstract IntStream |
flatMapToInt(LongFunction<? extends IntStream> mapper) |
abstract <T> Stream<T> |
flatMapToObj(LongFunction<? extends Stream<T>> mapper) |
abstract LongStream |
flattMap(LongFunction<long[]> mapper) |
abstract <T> Stream<T> |
flattMapToObj(LongFunction<? extends java.util.Collection<T>> mapper) |
abstract <E extends java.lang.Exception> |
forEach(Try.LongConsumer<E> action) |
static LongStream |
generate(LongSupplier s) |
abstract OptionalLong |
head()
Head and tail should be used by pair.
|
abstract Pair<OptionalLong,LongStream> |
headAndTail() |
abstract Pair<LongStream,OptionalLong> |
headAndTaill() |
abstract LongStream |
headd()
Head2 and tail2 should be used by pair.
|
static LongStream |
interval(long intervalInMillis) |
static LongStream |
interval(long delayInMillis,
long intervalInMillis)
Generates the long value by the specified period: [0, 1, 2, 3...]
|
static LongStream |
interval(long delay,
long interval,
java.util.concurrent.TimeUnit unit)
Generates the long value by the specified period: [0, 1, 2, 3...]
|
boolean |
isParallel()
Returns whether this stream, if a terminal operation were to be executed,
would execute in parallel.
|
static LongStream |
iterate(BooleanSupplier hasNext,
LongSupplier next) |
static LongStream |
iterate(long seed,
BooleanSupplier hasNext,
LongUnaryOperator f) |
static LongStream |
iterate(long seed,
LongPredicate hasNext,
LongUnaryOperator f) |
static LongStream |
iterate(long seed,
LongUnaryOperator f) |
LongIterator |
iterator()
Returns an iterator for the elements of this stream.
|
abstract OptionalLong |
kthLargest(int k) |
abstract LongStream |
map(LongUnaryOperator mapper)
Returns a stream consisting of the results of applying the given
function to the elements of this stream.
|
abstract DoubleStream |
mapToDouble(LongToDoubleFunction mapper)
Returns a
DoubleStream consisting of the results of applying the
given function to the elements of this stream. |
abstract FloatStream |
mapToFloat(LongToFloatFunction mapper)
Returns a
FloatStream consisting of the results of applying the
given function to the elements of this stream. |
abstract IntStream |
mapToInt(LongToIntFunction mapper)
Returns an
IntStream consisting of the results of applying the
given function to the elements of this stream. |
abstract <U> Stream<U> |
mapToObj(LongFunction<? extends U> mapper)
Returns an object-valued
Stream consisting of the results of
applying the given function to the elements of this stream. |
abstract OptionalLong |
max()
Returns an
OptionalLong describing the maximum element of this
stream, or an empty optional if this stream is empty. |
int |
maxThreadNum()
Return the underlying
maxThreadNum if the stream is parallel, otherwise 1 is returned. |
S |
maxThreadNum(int maxThreadNum)
Returns a parallel stream with the specified
maxThreadNum . |
static LongStream |
merge(java.util.Collection<? extends LongStream> c,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static LongStream |
merge(long[] a,
long[] b,
long[] c,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static LongStream |
merge(long[] a,
long[] b,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static LongStream |
merge(LongIterator a,
LongIterator b,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static LongStream |
merge(LongIterator a,
LongIterator b,
LongIterator c,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
abstract LongStream |
merge(LongStream b,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static LongStream |
merge(LongStream a,
LongStream b,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static LongStream |
merge(LongStream a,
LongStream b,
LongStream c,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
abstract OptionalLong |
min()
Returns an
OptionalLong describing the minimum element of this
stream, or an empty optional if this stream is empty. |
abstract <E extends java.lang.Exception> |
noneMatch(Try.LongPredicate<E> predicate) |
static LongStream |
of(java.util.Collection<java.lang.Long> c) |
static LongStream |
of(long... a) |
static LongStream |
of(java.lang.Long[] a) |
static LongStream |
of(long[][] a) |
static LongStream |
of(long[][][] a) |
static LongStream |
of(long[] a,
int startIndex,
int endIndex) |
static LongStream |
of(java.lang.Long[] a,
int startIndex,
int endIndex) |
static LongStream |
of(LongIterator iterator) |
static LongStream |
of(java.util.stream.LongStream stream) |
static LongStream |
of(Supplier<LongList> supplier)
Lazy evaluation.
|
S |
parallel()
Returns an equivalent stream that is parallel.
|
S |
parallel(BaseStream.Splitor splitor)
Returns an equivalent stream that is parallel.
|
S |
parallel(int maxThreadNum)
Returns an equivalent stream that is parallel.
|
static LongStream |
parallelMerge(java.util.Collection<? extends LongStream> c,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static LongStream |
parallelMerge(java.util.Collection<? extends LongStream> c,
LongBiFunction<com.landawn.abacus.util.Nth> nextSelector,
int maxThreadNum) |
void |
println() |
static LongStream |
random() |
static LongStream |
range(long startInclusive,
long endExclusive) |
static LongStream |
range(long startInclusive,
long endExclusive,
long by) |
static LongStream |
rangeClosed(long startInclusive,
long endInclusive) |
static LongStream |
rangeClosed(long startInclusive,
long endInclusive,
long by) |
abstract OptionalLong |
reduce(LongBinaryOperator op)
Performs a reduction on the
elements of this stream, using an
associative accumulation
function, and returns an
OptionalLong describing the reduced value,
if any. |
abstract long |
reduce(long identity,
LongBinaryOperator op)
Performs a reduction on the
elements of this stream, using the provided identity value and an
associative
accumulation function, and returns the reduced value.
|
static LongStream |
repeat(long element,
long n) |
abstract LongStream |
scan(LongBiFunction<java.lang.Long> accumulator)
Returns a
Stream produced by iterative application of a accumulation function
to an initial element seed and next element of the current stream. |
abstract LongStream |
scan(long seed,
LongBiFunction<java.lang.Long> accumulator)
Returns a
Stream produced by iterative application of a accumulation function
to an initial element seed and next element of the current stream. |
S |
sequential()
Returns an equivalent stream that is sequential.
|
S |
shuffled()
This method only run sequentially, even in parallel stream and all elements will be loaded to memory. |
Stream<S> |
sliding(int windowSize) |
Stream<PL> |
slidingToList(int windowSize) |
BaseStream.Splitor |
splitor()
Return the underlying
splitor if the stream is parallel, otherwise the default value splitor.ITERATOR is returned. |
S |
splitor(BaseStream.Splitor splitor)
Returns a parallel stream with the specified
splitor . |
abstract long |
sum()
Returns the sum of elements in this stream.
|
abstract LongSummaryStatistics |
summarize() |
abstract Pair<LongSummaryStatistics,Optional<java.util.Map<com.landawn.abacus.util.Percentage,java.lang.Long>>> |
summarizze() |
abstract LongStream |
tail()
Head and tail should be used by pair.
|
abstract OptionalLong |
taill()
Head2 and tail2 should be used by pair.
|
ImmutableList<T> |
toImmutableList() |
ImmutableSet<T> |
toImmutableSet() |
abstract java.util.stream.LongStream |
toJdkStream() |
abstract LongList |
toLongList() |
abstract <K,A,D> java.util.Map<K,D> |
toMap(LongFunction<? extends K> classifier,
Collector<java.lang.Long,A,D> downstream) |
abstract <K,A,D,M extends java.util.Map<K,D>> |
toMap(LongFunction<? extends K> classifier,
Collector<java.lang.Long,A,D> downstream,
Supplier<M> mapFactory) |
abstract <K,U> java.util.Map<K,U> |
toMap(LongFunction<? extends K> keyExtractor,
LongFunction<? extends U> valueMapper) |
abstract <K,U> java.util.Map<K,U> |
toMap(LongFunction<? extends K> keyExtractor,
LongFunction<? extends U> valueMapper,
BinaryOperator<U> mergeFunction) |
abstract <K,U,M extends java.util.Map<K,U>> |
toMap(LongFunction<? extends K> keyExtractor,
LongFunction<? extends U> valueMapper,
BinaryOperator<U> mergeFunction,
Supplier<M> mapFactory) |
abstract <K,U,M extends java.util.Map<K,U>> |
toMap(LongFunction<? extends K> keyExtractor,
LongFunction<? extends U> valueMapper,
Supplier<M> mapFactory) |
abstract LongMatrix |
toMatrix() |
abstract LongStream |
top(int n)
This method only run sequentially, even in parallel stream. |
abstract LongStream |
top(int n,
java.util.Comparator<? super java.lang.Long> comparator)
This method only run sequentially, even in parallel stream. |
Try<S> |
tried() |
static LongStream |
zip(java.util.Collection<? extends LongStream> c,
long[] valuesForNone,
LongNFunction<java.lang.Long> zipFunction)
Zip together the iterators until all of them runs out of values.
|
static LongStream |
zip(java.util.Collection<? extends LongStream> c,
LongNFunction<java.lang.Long> zipFunction)
Zip together the iterators until one of them runs out of values.
|
static LongStream |
zip(long[] a,
long[] b,
long[] c,
long valueForNoneA,
long valueForNoneB,
long valueForNoneC,
LongTriFunction<java.lang.Long> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static LongStream |
zip(long[] a,
long[] b,
long[] c,
LongTriFunction<java.lang.Long> zipFunction)
Zip together the "a", "b" and "c" arrays until one of them runs out of values.
|
static LongStream |
zip(long[] a,
long[] b,
LongBiFunction<java.lang.Long> zipFunction)
Zip together the "a" and "b" arrays until one of them runs out of values.
|
static LongStream |
zip(long[] a,
long[] b,
long valueForNoneA,
long valueForNoneB,
LongBiFunction<java.lang.Long> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static LongStream |
zip(LongIterator a,
LongIterator b,
LongBiFunction<java.lang.Long> zipFunction)
Zip together the "a" and "b" iterators until one of them runs out of values.
|
static LongStream |
zip(LongIterator a,
LongIterator b,
LongIterator c,
long valueForNoneA,
long valueForNoneB,
long valueForNoneC,
LongTriFunction<java.lang.Long> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static LongStream |
zip(LongIterator a,
LongIterator b,
LongIterator c,
LongTriFunction<java.lang.Long> zipFunction)
Zip together the "a", "b" and "c" iterators until one of them runs out of values.
|
static LongStream |
zip(LongIterator a,
LongIterator b,
long valueForNoneA,
long valueForNoneB,
LongBiFunction<java.lang.Long> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static LongStream |
zip(LongStream a,
LongStream b,
LongBiFunction<java.lang.Long> zipFunction)
Zip together the "a" and "b" streams until one of them runs out of values.
|
static LongStream |
zip(LongStream a,
LongStream b,
long valueForNoneA,
long valueForNoneB,
LongBiFunction<java.lang.Long> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static LongStream |
zip(LongStream a,
LongStream b,
LongStream c,
long valueForNoneA,
long valueForNoneB,
long valueForNoneC,
LongTriFunction<java.lang.Long> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static LongStream |
zip(LongStream a,
LongStream b,
LongStream c,
LongTriFunction<java.lang.Long> zipFunction)
Zip together the "a", "b" and "c" streams until one of them runs out of values.
|
abstract LongStream |
zipWith(LongStream b,
LongBiFunction<java.lang.Long> zipFunction) |
abstract LongStream |
zipWith(LongStream b,
long valueForNoneA,
long valueForNoneB,
LongBiFunction<java.lang.Long> zipFunction) |
abstract LongStream |
zipWith(LongStream b,
LongStream c,
long valueForNoneA,
long valueForNoneB,
long valueForNoneC,
LongTriFunction<java.lang.Long> zipFunction) |
abstract LongStream |
zipWith(LongStream b,
LongStream c,
LongTriFunction<java.lang.Long> zipFunction) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
append, cached, count, difference, distinct, dropWhile, dropWhile, filter, first, indexed, intersection, join, join, last, limit, onClose, parallel, peek, percentiles, prepend, removeIf, removeIf, reversed, reverseSorted, rotated, shuffled, skip, skip, sliding, slidingToList, sorted, split, split, split, splitAt, splitBy, splitToList, splitToList, splitToList, step, symmetricDifference, takeWhile, toArray, toCollection, toList, toLongMultiset, toLongMultiset, toMultiset, toMultiset, toSet
public abstract LongStream map(LongUnaryOperator mapper)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract IntStream mapToInt(LongToIntFunction mapper)
IntStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract FloatStream mapToFloat(LongToFloatFunction mapper)
FloatStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract DoubleStream mapToDouble(LongToDoubleFunction mapper)
DoubleStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract <U> Stream<U> mapToObj(LongFunction<? extends U> mapper)
Stream
consisting of the results of
applying the given function to the elements of this stream.
This is an intermediate operation.
U
- the element type of the new streammapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract LongStream flatMap(LongFunction<? extends LongStream> mapper)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each element which produces a
LongStream
of new valuesStream.flatMap(Function)
public abstract LongStream flattMap(LongFunction<long[]> mapper)
public abstract IntStream flatMapToInt(LongFunction<? extends IntStream> mapper)
public abstract FloatStream flatMapToFloat(LongFunction<? extends FloatStream> mapper)
public abstract DoubleStream flatMapToDouble(LongFunction<? extends DoubleStream> mapper)
public abstract <T> Stream<T> flatMapToObj(LongFunction<? extends Stream<T>> mapper)
public abstract <T> Stream<T> flattMapToObj(LongFunction<? extends java.util.Collection<T>> mapper)
public abstract LongStream collapse(LongBiPredicate collapsible, LongBiFunction<java.lang.Long> mergeFunction)
public abstract LongStream scan(LongBiFunction<java.lang.Long> accumulator)
Stream
produced by iterative application of a accumulation function
to an initial element seed
and next element of the current stream.
Produces a Stream
consisting of seed
, acc(seed, value1)
,
acc(acc(seed, value1), value2)
, etc.
This is an intermediate operation.
Example:
accumulator: (a, b) -> a + b stream: [1, 2, 3, 4, 5] result: [1, 3, 6, 10, 15]
accumulator
- the accumulation functionpublic abstract LongStream scan(long seed, LongBiFunction<java.lang.Long> accumulator)
Stream
produced by iterative application of a accumulation function
to an initial element seed
and next element of the current stream.
Produces a Stream
consisting of seed
, acc(seed, value1)
,
acc(acc(seed, value1), value2)
, etc.
This is an intermediate operation.
Example:
seed:10 accumulator: (a, b) -> a + b stream: [1, 2, 3, 4, 5] result: [11, 13, 16, 20, 25]
seed
- the initial value. it's only used once by accumulator
to calculate the fist element in the returned stream.
It will be ignored if this stream is empty and won't be the first element of the returned stream.accumulator
- the accumulation functionpublic abstract LongStream top(int n)
n
- public abstract LongStream top(int n, java.util.Comparator<? super java.lang.Long> comparator)
n
- public abstract LongList toLongList()
public abstract <K,U> java.util.Map<K,U> toMap(LongFunction<? extends K> keyExtractor, LongFunction<? extends U> valueMapper)
keyExtractor
- valueMapper
- Collectors.toMap(Function, Function)
public abstract <K,U,M extends java.util.Map<K,U>> M toMap(LongFunction<? extends K> keyExtractor, LongFunction<? extends U> valueMapper, Supplier<M> mapFactory)
keyExtractor
- valueMapper
- mapFactory
- Collectors.toMap(Function, Function, Supplier)
public abstract <K,U> java.util.Map<K,U> toMap(LongFunction<? extends K> keyExtractor, LongFunction<? extends U> valueMapper, BinaryOperator<U> mergeFunction)
keyExtractor
- valueMapper
- mergeFunction
- Collectors.toMap(Function, Function, BinaryOperator)
public abstract <K,U,M extends java.util.Map<K,U>> M toMap(LongFunction<? extends K> keyExtractor, LongFunction<? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapFactory)
keyExtractor
- valueMapper
- mergeFunction
- mapFactory
- Collectors.toMap(Function, Function, BinaryOperator, Supplier)
public abstract <K,A,D> java.util.Map<K,D> toMap(LongFunction<? extends K> classifier, Collector<java.lang.Long,A,D> downstream)
classifier
- downstream
- Collectors.groupingBy(Function, Collector)
public abstract <K,A,D,M extends java.util.Map<K,D>> M toMap(LongFunction<? extends K> classifier, Collector<java.lang.Long,A,D> downstream, Supplier<M> mapFactory)
classifier
- downstream
- mapFactory
- Collectors.groupingBy(Function, Collector, Supplier)
public abstract LongMatrix toMatrix()
public abstract long reduce(long identity, LongBinaryOperator op)
long result = identity;
for (long element : this stream)
result = accumulator.applyAsLong(result, element)
return result;
but is not constrained to execute sequentially.
The identity
value must be an identity for the accumulator
function. This means that for all x
,
accumulator.apply(identity, x)
is equal to x
.
The accumulator
function must be an
associative function.
This is a terminal operation.
identity
- the identity value for the accumulating functionop
- an associative,
non-interfering,
stateless
function for combining two valuessum()
,
min()
,
max()
,
average()
public abstract OptionalLong reduce(LongBinaryOperator op)
OptionalLong
describing the reduced value,
if any. This is equivalent to:
boolean foundAny = false;
long result = null;
for (long element : this stream) {
if (!foundAny) {
foundAny = true;
result = element;
}
else
result = accumulator.applyAsLong(result, element);
}
return foundAny ? OptionalLong.of(result) : OptionalLong.empty();
but is not constrained to execute sequentially.
The accumulator
function must be an
associative function.
This is a terminal operation.
op
- an associative,
non-interfering,
stateless
function for combining two valuesreduce(long, LongBinaryOperator)
public abstract <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R,R> combiner)
ArrayList
, and elements are incorporated by updating
the state of the result rather than by replacing the result. This
produces a result equivalent to:
R result = supplier.get();
for (long element : this stream)
accumulator.accept(result, element);
return result;
Like reduce(long, LongBinaryOperator)
, collect
operations
can be parallelized without requiring additional synchronization.
This is a terminal operation.
R
- type of the resultsupplier
- a function that creates a new result container. For a
parallel execution, this function may be called
multiple times and must return a fresh value each time.accumulator
- an associative,
non-interfering,
stateless
function for incorporating an additional element into a resultcombiner
- an associative,
non-interfering,
stateless
function for combining two values, which must be
compatible with the accumulator functionStream.collect(Supplier, BiConsumer, BiConsumer)
public abstract <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator)
supplier
- accumulator
- public abstract <E extends java.lang.Exception> void forEach(Try.LongConsumer<E> action) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract <E extends java.lang.Exception> boolean anyMatch(Try.LongPredicate<E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract <E extends java.lang.Exception> boolean allMatch(Try.LongPredicate<E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract <E extends java.lang.Exception> boolean noneMatch(Try.LongPredicate<E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract <E extends java.lang.Exception> OptionalLong findFirst(Try.LongPredicate<E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract <E extends java.lang.Exception> OptionalLong findLast(Try.LongPredicate<E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract <E extends java.lang.Exception,E2 extends java.lang.Exception> OptionalLong findFirstOrLast(Try.LongPredicate<E> predicateForFirst, Try.LongPredicate<E> predicateForLast) throws E extends java.lang.Exception, E2 extends java.lang.Exception
E extends java.lang.Exception
public abstract <E extends java.lang.Exception> OptionalLong findAny(Try.LongPredicate<E> predicate) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract OptionalLong head()
public abstract LongStream tail()
public abstract LongStream headd()
public abstract OptionalLong taill()
public abstract Pair<OptionalLong,LongStream> headAndTail()
public abstract Pair<LongStream,OptionalLong> headAndTaill()
public abstract OptionalLong min()
OptionalLong
describing the minimum element of this
stream, or an empty optional if this stream is empty. This is a special
case of a reduction
and is equivalent to:
return reduce(Long::min);
This is a terminal operation.
OptionalLong
containing the minimum element of this
stream, or an empty OptionalLong
if the stream is emptypublic abstract OptionalLong max()
OptionalLong
describing the maximum element of this
stream, or an empty optional if this stream is empty. This is a special
case of a reduction
and is equivalent to:
return reduce(Long::max);
This is a terminal operation.
OptionalLong
containing the maximum element of this
stream, or an empty OptionalLong
if the stream is emptypublic abstract OptionalLong kthLargest(int k)
k
- public abstract long sum()
return reduce(0, Long::sum);
This is a terminal operation.
public abstract OptionalDouble average()
OptionalDouble
describing the arithmetic mean of elements of
this stream, or an empty optional if this stream is empty. This is a
special case of a
reduction.
This is a terminal operation.
OptionalDouble
containing the average element of this
stream, or an empty optional if the stream is emptypublic abstract LongSummaryStatistics summarize()
public abstract Pair<LongSummaryStatistics,Optional<java.util.Map<com.landawn.abacus.util.Percentage,java.lang.Long>>> summarizze()
public abstract LongStream merge(LongStream b, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public abstract LongStream zipWith(LongStream b, LongBiFunction<java.lang.Long> zipFunction)
public abstract LongStream zipWith(LongStream b, LongStream c, LongTriFunction<java.lang.Long> zipFunction)
public abstract LongStream zipWith(LongStream b, long valueForNoneA, long valueForNoneB, LongBiFunction<java.lang.Long> zipFunction)
public abstract LongStream zipWith(LongStream b, LongStream c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<java.lang.Long> zipFunction)
public abstract FloatStream asFloatStream()
FloatStream
consisting of the elements of this stream,
converted to double
.
This is an intermediate operation.
FloatStream
consisting of the elements of this stream,
converted to double
public abstract DoubleStream asDoubleStream()
DoubleStream
consisting of the elements of this stream,
converted to double
.
This is an intermediate operation.
DoubleStream
consisting of the elements of this stream,
converted to double
public abstract java.util.stream.LongStream toJdkStream()
public abstract Stream<java.lang.Long> boxed()
Stream
consisting of the elements of this stream,
each boxed to a Long
.
This is an intermediate operation.
Stream
consistent of the elements of this stream,
each boxed to Long
public LongIterator iterator()
BaseStream
public <R> R __(Function<? super LongStream,R> transfer)
public static LongStream empty()
@SafeVarargs public static LongStream of(long... a)
public static LongStream of(long[] a, int startIndex, int endIndex)
public static LongStream of(long[][] a)
public static LongStream of(long[][][] a)
public static LongStream of(java.lang.Long[] a)
public static LongStream of(java.lang.Long[] a, int startIndex, int endIndex)
public static LongStream of(java.util.Collection<java.lang.Long> c)
public static LongStream of(LongIterator iterator)
public static LongStream of(Supplier<LongList> supplier)
supplier
- public static LongStream of(java.util.stream.LongStream stream)
public static LongStream range(long startInclusive, long endExclusive)
public static LongStream range(long startInclusive, long endExclusive, long by)
public static LongStream rangeClosed(long startInclusive, long endInclusive)
public static LongStream rangeClosed(long startInclusive, long endInclusive, long by)
public static LongStream repeat(long element, long n)
public static LongStream random()
public static LongStream iterate(BooleanSupplier hasNext, LongSupplier next)
public static LongStream iterate(long seed, BooleanSupplier hasNext, LongUnaryOperator f)
public static LongStream iterate(long seed, LongPredicate hasNext, LongUnaryOperator f)
seed
- hasNext
- test if has next by hasNext.test(seed) for first time and hasNext.test(f.apply(previous)) for remaining.f
- public static LongStream iterate(long seed, LongUnaryOperator f)
public static LongStream generate(LongSupplier s)
public static LongStream interval(long intervalInMillis)
intervalInMillis
- public static LongStream interval(long delayInMillis, long intervalInMillis)
delayInMillis
- intervalInMillis
- public static LongStream interval(long delay, long interval, java.util.concurrent.TimeUnit unit)
delay
- interval
- unit
- @SafeVarargs public static LongStream concat(long[]... a)
@SafeVarargs public static LongStream concat(LongIterator... a)
@SafeVarargs public static LongStream concat(LongStream... a)
public static LongStream concat(java.util.Collection<? extends LongStream> c)
public static LongStream zip(long[] a, long[] b, LongBiFunction<java.lang.Long> zipFunction)
a
- b
- public static LongStream zip(long[] a, long[] b, long[] c, LongTriFunction<java.lang.Long> zipFunction)
a
- b
- public static LongStream zip(LongIterator a, LongIterator b, LongBiFunction<java.lang.Long> zipFunction)
a
- b
- public static LongStream zip(LongIterator a, LongIterator b, LongIterator c, LongTriFunction<java.lang.Long> zipFunction)
a
- b
- public static LongStream zip(LongStream a, LongStream b, LongBiFunction<java.lang.Long> zipFunction)
a
- b
- public static LongStream zip(LongStream a, LongStream b, LongStream c, LongTriFunction<java.lang.Long> zipFunction)
a
- b
- public static LongStream zip(java.util.Collection<? extends LongStream> c, LongNFunction<java.lang.Long> zipFunction)
c
- zipFunction
- public static LongStream zip(long[] a, long[] b, long valueForNoneA, long valueForNoneB, LongBiFunction<java.lang.Long> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static LongStream zip(long[] a, long[] b, long[] c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<java.lang.Long> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static LongStream zip(LongIterator a, LongIterator b, long valueForNoneA, long valueForNoneB, LongBiFunction<java.lang.Long> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static LongStream zip(LongIterator a, LongIterator b, LongIterator c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<java.lang.Long> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static LongStream zip(LongStream a, LongStream b, long valueForNoneA, long valueForNoneB, LongBiFunction<java.lang.Long> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static LongStream zip(LongStream a, LongStream b, LongStream c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<java.lang.Long> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static LongStream zip(java.util.Collection<? extends LongStream> c, long[] valuesForNone, LongNFunction<java.lang.Long> zipFunction)
c
- valuesForNone
- value to fill for any iterator runs out of values.zipFunction
- public static LongStream merge(long[] a, long[] b, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream merge(long[] a, long[] b, long[] c, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream merge(LongIterator a, LongIterator b, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream merge(LongIterator a, LongIterator b, LongIterator c, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream merge(LongStream a, LongStream b, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream merge(LongStream a, LongStream b, LongStream c, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream merge(java.util.Collection<? extends LongStream> c, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream parallelMerge(java.util.Collection<? extends LongStream> c, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static LongStream parallelMerge(java.util.Collection<? extends LongStream> c, LongBiFunction<com.landawn.abacus.util.Nth> nextSelector, int maxThreadNum)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.maxThreadNum
- public S carry(C action)
BaseStream
peek
carry
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
BaseStream.peek(Object)
public Stream<S> sliding(int windowSize)
sliding
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
BaseStream.sliding(int, int)
public Stream<PL> slidingToList(int windowSize)
slidingToList
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
BaseStream.sliding(int, int)
public S shuffled()
BaseStream
shuffled
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public ImmutableList<T> toImmutableList()
toImmutableList
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public ImmutableSet<T> toImmutableSet()
toImmutableSet
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public void println()
println
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public boolean isParallel()
BaseStream
isParallel
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
true
if this stream would execute in parallel if executedpublic S sequential()
BaseStream
sequential
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public S parallel()
BaseStream
parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
BaseStream.parallel(int, Splitor)
public S parallel(int maxThreadNum)
BaseStream
maxThreadNum
as the specified one.parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
BaseStream.parallel(int, Splitor)
public S parallel(BaseStream.Splitor splitor)
BaseStream
splitor
as the specified one.parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
BaseStream.parallel(int, Splitor)
public int maxThreadNum()
BaseStream
maxThreadNum
if the stream is parallel, otherwise 1
is returned.maxThreadNum
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public S maxThreadNum(int maxThreadNum)
BaseStream
maxThreadNum
. Or return
itself, either because the stream was already parallel with same maxThreadNum
, or because
it's a sequential stream.maxThreadNum
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public BaseStream.Splitor splitor()
BaseStream
splitor
if the stream is parallel, otherwise the default value splitor.ITERATOR
is returned.splitor
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public S splitor(BaseStream.Splitor splitor)
BaseStream
splitor
. Or return
itself, either because the stream was already parallel with same splitor
, or because
it's a sequential stream.splitor
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public Try<S> tried()
tried
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
public void close()
BaseStream
close
in interface BaseStream<T,A,P,C,PL,OT,IT,ITER,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,ITER,S>>
close
in interface java.lang.AutoCloseable
AutoCloseable.close()