public interface DistributedLongStream extends java.util.stream.LongStream
LongStream
to support distributed stream operations by replacing
functional interfaces with their serializable equivalents.java.util.stream.LongStream.Builder
Modifier and Type | Method and Description |
---|---|
default boolean |
allMatch(Distributed.LongPredicate predicate)
Returns whether all elements of this stream match the provided predicate.
|
boolean |
allMatch(java.util.function.LongPredicate predicate) |
default boolean |
anyMatch(Distributed.LongPredicate predicate)
Returns whether any elements of this stream match the provided
predicate.
|
boolean |
anyMatch(java.util.function.LongPredicate predicate) |
DistributedDoubleStream |
asDoubleStream()
Returns a
DoubleStream consisting of the elements of this stream,
converted to double . |
DistributedStream<Long> |
boxed()
Returns a
Stream consisting of the elements of this stream,
each boxed to a Long . |
default <R> R |
collect(Distributed.Supplier<R> supplier,
Distributed.ObjLongConsumer<R> accumulator,
Distributed.BiConsumer<R,R> combiner)
Performs a mutable
reduction operation on the elements of this stream.
|
<R> R |
collect(java.util.function.Supplier<R> supplier,
java.util.function.ObjLongConsumer<R> accumulator,
java.util.function.BiConsumer<R,R> combiner) |
DistributedLongStream |
distinct()
Returns a stream consisting of the distinct elements of this stream.
|
default DistributedLongStream |
filter(Distributed.LongPredicate predicate)
Returns a stream consisting of the elements of this stream that match
the given predicate.
|
DistributedLongStream |
filter(java.util.function.LongPredicate predicate) |
default DistributedLongStream |
flatMap(Distributed.LongFunction<? extends java.util.stream.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.
|
DistributedLongStream |
flatMap(java.util.function.LongFunction<? extends java.util.stream.LongStream> mapper) |
default void |
forEach(Distributed.LongConsumer action)
Performs an action for each element of this stream.
|
void |
forEach(java.util.function.LongConsumer action) |
default void |
forEachOrdered(Distributed.LongConsumer action)
Performs an action for each element of this stream, guaranteeing that
each element is processed in encounter order for streams that have a
defined encounter order.
|
void |
forEachOrdered(java.util.function.LongConsumer action) |
DistributedLongStream |
limit(long maxSize)
Returns a stream consisting of the elements of this stream, truncated
to be no longer than
maxSize in length. |
default DistributedLongStream |
map(Distributed.LongUnaryOperator mapper)
Returns a stream consisting of the results of applying the given
function to the elements of this stream.
|
DistributedLongStream |
map(java.util.function.LongUnaryOperator mapper) |
default DistributedDoubleStream |
mapToDouble(Distributed.LongToDoubleFunction mapper)
Returns a
DoubleStream consisting of the results of applying the
given function to the elements of this stream. |
DistributedDoubleStream |
mapToDouble(java.util.function.LongToDoubleFunction mapper) |
default DistributedIntStream |
mapToInt(Distributed.LongToIntFunction mapper)
Returns an
IntStream consisting of the results of applying the
given function to the elements of this stream. |
DistributedIntStream |
mapToInt(java.util.function.LongToIntFunction mapper) |
default <U> DistributedStream<U> |
mapToObj(Distributed.LongFunction<? extends U> mapper)
Returns an object-valued
Stream consisting of the results of
applying the given function to the elements of this stream. |
<U> DistributedStream<U> |
mapToObj(java.util.function.LongFunction<? extends U> mapper) |
default boolean |
noneMatch(Distributed.LongPredicate predicate)
Returns whether no elements of this stream match the provided predicate.
|
boolean |
noneMatch(java.util.function.LongPredicate predicate) |
DistributedLongStream |
parallel()
Returns an equivalent stream that is parallel.
|
default DistributedLongStream |
peek(Distributed.LongConsumer action)
Returns a stream consisting of the elements of this stream, additionally
performing the provided action on each element as elements are consumed
from the resulting stream.
|
DistributedLongStream |
peek(java.util.function.LongConsumer action) |
default OptionalLong |
reduce(Distributed.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. |
OptionalLong |
reduce(java.util.function.LongBinaryOperator op) |
default long |
reduce(long identity,
Distributed.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.
|
long |
reduce(long identity,
java.util.function.LongBinaryOperator op) |
DistributedLongStream |
sequential()
Returns an equivalent stream that is sequential.
|
DistributedLongStream |
skip(long n)
Returns a stream consisting of the remaining elements of this stream
after discarding the first
n elements of the stream. |
DistributedLongStream |
sorted()
Returns a stream consisting of the elements of this stream in sorted
order.
|
average, builder, concat, count, empty, findAny, findFirst, generate, iterate, iterator, max, min, of, of, range, rangeClosed, spliterator, sum, summaryStatistics, toArray
close, isParallel, onClose, unordered
default DistributedLongStream filter(Distributed.LongPredicate predicate)
This is an intermediate operation.
predicate
- a non-interfering,
stateless
predicate to apply to each element to determine if it
should be includeddefault DistributedLongStream map(Distributed.LongUnaryOperator mapper)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementdefault <U> DistributedStream<U> mapToObj(Distributed.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 elementdefault DistributedIntStream mapToInt(Distributed.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 elementdefault DistributedDoubleStream mapToDouble(Distributed.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 elementdefault DistributedLongStream flatMap(Distributed.LongFunction<? extends java.util.stream.LongStream> mapper)
closed
after its contents
have been placed into this stream. (If a mapped stream is null
an empty stream is used, instead.)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each element which produces a
LongStream
of new valuesDistributedStream.flatMap(Distributed.Function)
DistributedLongStream distinct()
This is a stateful intermediate operation.
distinct
in interface java.util.stream.LongStream
DistributedLongStream sorted()
This is a stateful intermediate operation.
sorted
in interface java.util.stream.LongStream
default DistributedLongStream peek(Distributed.LongConsumer action)
This is an intermediate operation.
For parallel stream pipelines, the action may be called at whatever time and in whatever thread the element is made available by the upstream operation. If the action modifies shared state, it is responsible for providing the required synchronization.
action
- a
non-interfering action to perform on the elements as
they are consumed from the streamDistributedLongStream limit(long maxSize)
maxSize
in length.
This is a short-circuiting stateful intermediate operation.
limit
in interface java.util.stream.LongStream
maxSize
- the number of elements the stream should be limited toIllegalArgumentException
- if maxSize
is negativeDistributedLongStream skip(long n)
n
elements of the stream.
If this stream contains fewer than n
elements then an
empty stream will be returned.
This is a stateful intermediate operation.
skip
in interface java.util.stream.LongStream
n
- the number of leading elements to skipIllegalArgumentException
- if n
is negativedefault void forEach(Distributed.LongConsumer action)
This is a terminal operation.
For parallel stream pipelines, this operation does not guarantee to respect the encounter order of the stream, as doing so would sacrifice the benefit of parallelism. For any given element, the action may be performed at whatever time and in whatever thread the library chooses. If the action accesses shared state, it is responsible for providing the required synchronization.
action
- a
non-interfering action to perform on the elementsdefault void forEachOrdered(Distributed.LongConsumer action)
This is a terminal operation.
action
- a
non-interfering action to perform on the elementsforEach(LongConsumer)
default long reduce(long identity, Distributed.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 valuesLongStream.sum()
,
LongStream.min()
,
LongStream.max()
,
LongStream.average()
default OptionalLong reduce(Distributed.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)
default <R> R collect(Distributed.Supplier<R> supplier, Distributed.ObjLongConsumer<R> accumulator, Distributed.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)
default boolean anyMatch(Distributed.LongPredicate predicate)
false
is returned and the predicate is not evaluated.
This is a short-circuiting terminal operation.
predicate
- a non-interfering,
stateless
predicate to apply to elements of this streamtrue
if any elements of the stream match the provided
predicate, otherwise false
default boolean allMatch(Distributed.LongPredicate predicate)
true
is
returned and the predicate is not evaluated.
This is a short-circuiting terminal operation.
predicate
- a non-interfering,
stateless
predicate to apply to elements of this streamtrue
if either all elements of the stream match the
provided predicate or the stream is empty, otherwise false
default boolean noneMatch(Distributed.LongPredicate predicate)
true
is
returned and the predicate is not evaluated.
This is a short-circuiting terminal operation.
predicate
- a non-interfering,
stateless
predicate to apply to elements of this streamtrue
if either no elements of the stream match the
provided predicate or the stream is empty, otherwise false
DistributedDoubleStream asDoubleStream()
DoubleStream
consisting of the elements of this stream,
converted to double
.
This is an intermediate operation.
asDoubleStream
in interface java.util.stream.LongStream
DoubleStream
consisting of the elements of this stream,
converted to double
DistributedStream<Long> boxed()
Stream
consisting of the elements of this stream,
each boxed to a Long
.
This is an intermediate operation.
boxed
in interface java.util.stream.LongStream
Stream
consistent of the elements of this stream,
each boxed to Long
DistributedLongStream sequential()
This is an intermediate operation.
sequential
in interface java.util.stream.BaseStream<Long,java.util.stream.LongStream>
sequential
in interface java.util.stream.LongStream
DistributedLongStream parallel()
This is an intermediate operation.
parallel
in interface java.util.stream.BaseStream<Long,java.util.stream.LongStream>
parallel
in interface java.util.stream.LongStream
DistributedLongStream filter(java.util.function.LongPredicate predicate)
filter
in interface java.util.stream.LongStream
DistributedLongStream map(java.util.function.LongUnaryOperator mapper)
map
in interface java.util.stream.LongStream
<U> DistributedStream<U> mapToObj(java.util.function.LongFunction<? extends U> mapper)
mapToObj
in interface java.util.stream.LongStream
DistributedIntStream mapToInt(java.util.function.LongToIntFunction mapper)
mapToInt
in interface java.util.stream.LongStream
DistributedDoubleStream mapToDouble(java.util.function.LongToDoubleFunction mapper)
mapToDouble
in interface java.util.stream.LongStream
DistributedLongStream flatMap(java.util.function.LongFunction<? extends java.util.stream.LongStream> mapper)
flatMap
in interface java.util.stream.LongStream
DistributedLongStream peek(java.util.function.LongConsumer action)
peek
in interface java.util.stream.LongStream
void forEach(java.util.function.LongConsumer action)
forEach
in interface java.util.stream.LongStream
void forEachOrdered(java.util.function.LongConsumer action)
forEachOrdered
in interface java.util.stream.LongStream
long reduce(long identity, java.util.function.LongBinaryOperator op)
reduce
in interface java.util.stream.LongStream
OptionalLong reduce(java.util.function.LongBinaryOperator op)
reduce
in interface java.util.stream.LongStream
<R> R collect(java.util.function.Supplier<R> supplier, java.util.function.ObjLongConsumer<R> accumulator, java.util.function.BiConsumer<R,R> combiner)
collect
in interface java.util.stream.LongStream
boolean anyMatch(java.util.function.LongPredicate predicate)
anyMatch
in interface java.util.stream.LongStream
boolean allMatch(java.util.function.LongPredicate predicate)
allMatch
in interface java.util.stream.LongStream
boolean noneMatch(java.util.function.LongPredicate predicate)
noneMatch
in interface java.util.stream.LongStream
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.