E_IN
- type of elements in the upstream sourceE_OUT
- type of elements in produced by this stagepublic static class ReferencePipeline.Head<E_IN,E_OUT> extends ReferencePipeline<E_IN,E_OUT>
ReferencePipeline.Head<E_IN,E_OUT>, ReferencePipeline.StatefulOp<E_IN,E_OUT>, ReferencePipeline.StatelessOp<E_IN,E_OUT>
Stream.Builder<T>
sourceOrOpFlags
Constructor and Description |
---|
Head(Spliterator<?> source,
int sourceFlags,
boolean parallel)
Constructor for the source stage of a Stream.
|
Head(Supplier<? extends Spliterator<?>> source,
int sourceFlags,
boolean parallel)
Constructor for the source stage of a Stream.
|
Modifier and Type | Method and Description |
---|---|
void |
forEach(Consumer<? super E_OUT> action)
Performs an action for each element of this stream.
|
void |
forEachOrdered(Consumer<? super E_OUT> action)
Performs an action for each element of this stream, in the encounter
order of the stream if the stream has a defined encounter order.
|
boolean |
opIsStateful()
Returns whether this operation is stateful or not.
|
Sink<E_IN> |
opWrapSink(int flags,
Sink<E_OUT> sink)
Accepts a
Sink which will receive the results of this operation,
and return a Sink which accepts elements of the input type of
this operation and which performs the operation, passing the results to
the provided Sink . |
allMatch, anyMatch, collect, collect, count, distinct, evaluateToNode, filter, findAny, findFirst, flatMap, flatMapToDouble, flatMapToInt, flatMapToLong, forEachWithCancel, getOutputShape, iterator, lazySpliterator, limit, makeNodeBuilder, map, mapToDouble, mapToInt, mapToLong, max, min, noneMatch, peek, reduce, reduce, reduce, skip, sorted, sorted, toArray, toArray, unordered, wrap
close, evaluate, evaluateToArrayNode, getStreamAndOpFlags, getStreamFlags, isParallel, onClose, opEvaluateParallel, opEvaluateParallelLazy, parallel, sequential, spliterator, wrapSink
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, concat, empty, generate, iterate, of, of
close, isParallel, onClose, parallel, sequential, spliterator
public Head(Supplier<? extends Spliterator<?>> source, int sourceFlags, boolean parallel)
source
- Supplier<Spliterator>
describing the stream
sourcesourceFlags
- the source flags for the stream source, described
in StreamOpFlag
public Head(Spliterator<?> source, int sourceFlags, boolean parallel)
source
- Spliterator
describing the stream sourcesourceFlags
- the source flags for the stream source, described
in StreamOpFlag
public final boolean opIsStateful()
AbstractPipeline
AbstractPipeline.opEvaluateParallel(PipelineHelper, java.util.Spliterator, java.util.function.IntFunction)
must be overridden.opIsStateful
in class AbstractPipeline<E_IN,E_OUT,Stream<E_OUT>>
true
if this operation is statefulpublic final Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink)
AbstractPipeline
Sink
which will receive the results of this operation,
and return a Sink
which accepts elements of the input type of
this operation and which performs the operation, passing the results to
the provided Sink
.opWrapSink
in class AbstractPipeline<E_IN,E_OUT,Stream<E_OUT>>
flags
- The combined stream and operation flags up to, but not
including, this operationsink
- sink to which elements should be sent after processingSink
.public void forEach(Consumer<? super E_OUT> action)
Stream
This is a terminal operation.
The behavior of this operation is explicitly nondeterministic. 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.
forEach
in interface Stream<E_OUT>
forEach
in class ReferencePipeline<E_IN,E_OUT>
action
- a
non-interfering action to perform on the elementspublic void forEachOrdered(Consumer<? super E_OUT> action)
Stream
This is a terminal operation.
This operation processes the elements one at a time, in encounter order if one exists. Performing the action for one element happens-before performing the action for subsequent elements, but for any given element, the action may be performed in whatever thread the library chooses.
forEachOrdered
in interface Stream<E_OUT>
forEachOrdered
in class ReferencePipeline<E_IN,E_OUT>
action
- a
non-interfering action to perform on the elementsStream.forEach(Consumer)