TerminalOp
that searches
for an element in a stream pipeline, and terminates when it finds one.
Supported variants include find-first (find the first element in the
encounter order) and find-any (find any element, may not be the first in
encounter order.)
Modifier and Type | Class and Description |
---|---|
private static class | FindOps.FindOp<
the output type of the stream pipeline T, the result type of the find operation, typically an optional
type O>A short-circuiting |
private abstract static class | FindOps.FindSink<
The type of input element T, The result type, typically an optional type O>Implementation of |
private static class | FindOps.FindTask<
Input element type to the stream pipeline P_IN, Output element type from the stream pipeline P_OUT, Result type from the find operation O>
|
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static TerminalOp | Returns: aTerminalOp implementing the find operationwhether the mustFindFirst)TerminalOp must produce the
first element in the encounter orderConstructs a |
public static TerminalOp | Returns: aTerminalOp implementing the find operationwhether the mustFindFirst)TerminalOp must produce the
first element in the encounter orderConstructs a |
public static TerminalOp | Returns: aTerminalOp implementing the find operationwhether the mustFindFirst)TerminalOp must produce the
first element in the encounter orderConstructs a |
public static < the type of elements of the stream T> TerminalOp | Returns: aTerminalOp implementing the find operationwhether the mustFindFirst)TerminalOp must produce the
first element in the encounter orderConstructs a |
FindOps | back to summary |
---|---|
private FindOps() |
makeDouble | back to summary |
---|---|
public static TerminalOp Constructs a
|
makeInt | back to summary |
---|---|
public static TerminalOp Constructs a
|
makeLong | back to summary |
---|---|
public static TerminalOp Constructs a
|
makeRef | back to summary |
---|---|
public static <T> TerminalOp Constructs a
|
TerminalOp
that searches for an element in a
stream pipeline, and terminates when it finds one. Implements both
find-first (find the first element in the encounter order) and find-any
(find any element, may not be the first in encounter order.)
Modifier and Type | Field and Description |
---|---|
pack-priv final O | |
pack-priv final int | |
pack-priv final Predicate | |
private final StreamShape | |
pack-priv final Supplier |
Access | Constructor and Description |
---|---|
pack-priv | FindOp(boolean
if true, must find the first element in
encounter order, otherwise can find any element mustFindFirst, StreamShape stream shape of elements to search shape, O result value corresponding to "found nothing" emptyValue, Predicate<O> Predicate on result value
corresponding to "found something"supplier for a sinkSupplier)TerminalSink implementing
the matching functionalityConstructs a |
Modifier and Type | Method and Description |
---|---|
public <P_IN> O | evaluateParallel(PipelineHelper<T>
the pipeline helper helper, Spliterator<P_IN> the source spliterator spliterator)Overrides default java. PipelineHelper , which describes the upstream intermediate
operations.
|
public <S> O | evaluateSequential(PipelineHelper<T>
the pipeline helper helper, Spliterator<S> the source spliterator spliterator)Implements java. PipelineHelper , which describes the upstream intermediate
operations.
|
public int | getOpFlags()
Overrides default java. |
public StreamShape | inputShape()
Overrides default java. |
emptyValue | back to summary |
---|---|
pack-priv final O emptyValue |
opFlags | back to summary |
---|---|
pack-priv final int opFlags |
presentPredicate | back to summary |
---|---|
pack-priv final Predicate<O> presentPredicate |
shape | back to summary |
---|---|
private final StreamShape shape |
sinkSupplier | back to summary |
---|---|
pack-priv final Supplier<TerminalSink<T, O>> sinkSupplier |
FindOp | back to summary |
---|---|
pack-priv FindOp(boolean mustFindFirst, StreamShape shape, O emptyValue, Predicate<O> presentPredicate, Supplier<TerminalSink<T, O>> sinkSupplier) Constructs a
|
evaluateParallel | back to summary |
---|---|
public <P_IN> O evaluateParallel(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) Overrides default java. Doc from java. Performs a parallel evaluation of the operation using the specified
|
evaluateSequential | back to summary |
---|---|
public <S> O evaluateSequential(PipelineHelper<T> helper, Spliterator<S> spliterator) Implements java. Doc from java. Performs a sequential evaluation of the operation using the specified
|
getOpFlags | back to summary |
---|---|
public int getOpFlags() Overrides default java. Doc from java. Gets the stream flags of the operation. Terminal operations may set a
limited subset of the stream flags defined in
|
inputShape | back to summary |
---|---|
public StreamShape inputShape() Overrides default java. Doc from java. Gets the shape of the input type of this operation.
|
TerminalSink
that implements the find
functionality, requesting cancellation when something has been found
Modifier and Type | Class and Description |
---|---|
pack-priv static class | FindOps.FindSink.OfDouble
Specialization of |
pack-priv static class | FindOps.FindSink.OfInt
Specialization of |
pack-priv static class | FindOps.FindSink.OfLong
Specialization of |
pack-priv static class |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | accept(T
the input argument value)Implements java. |
public boolean | cancellationRequested()
Overrides default java. Sink does not wish to receive any more data.
|
hasValue | back to summary |
---|---|
pack-priv boolean hasValue |
value | back to summary |
---|---|
pack-priv T value |
FindSink | back to summary |
---|---|
pack-priv FindSink() |
accept | back to summary |
---|---|
public void accept(T value) Implements java. Doc from java. Performs this operation on the given argument.
|
cancellationRequested | back to summary |
---|---|
public boolean cancellationRequested() Overrides default java. Doc from java. Indicates that this
|
FindSink
for double streams
Modifier and Type | Field and Description |
---|---|
pack-priv static final TerminalOp | |
pack-priv static final TerminalOp |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | accept(double
the input argument value)Overrides java. Overrides default java. Implements java. |
public OptionalDouble |
OP_FIND_ANY | back to summary |
---|---|
pack-priv static final TerminalOp<Double, OptionalDouble> OP_FIND_ANY |
OP_FIND_FIRST | back to summary |
---|---|
pack-priv static final TerminalOp<Double, OptionalDouble> OP_FIND_FIRST |
OfDouble | back to summary |
---|---|
pack-priv OfDouble() |
accept | back to summary |
---|---|
public void accept(double value) Overrides java. Overrides default java. Implements java. Doc from java. Accepts a double value.
|
get | back to summary |
---|---|
public OptionalDouble get() Implements java. Doc from java. Gets a result.
|
FindSink
for int streams
Modifier and Type | Field and Description |
---|---|
pack-priv static final TerminalOp | |
pack-priv static final TerminalOp |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | accept(int
the input argument value)Overrides java. Overrides default java. Implements java. |
public OptionalInt |
OP_FIND_ANY | back to summary |
---|---|
pack-priv static final TerminalOp<Integer, OptionalInt> OP_FIND_ANY |
OP_FIND_FIRST | back to summary |
---|---|
pack-priv static final TerminalOp<Integer, OptionalInt> OP_FIND_FIRST |
OfInt | back to summary |
---|---|
pack-priv OfInt() |
accept | back to summary |
---|---|
public void accept(int value) Overrides java. Overrides default java. Implements java. Doc from java. Accepts an int value.
|
get | back to summary |
---|---|
public OptionalInt get() Implements java. Doc from java. Gets a result.
|
FindSink
for long streams
Modifier and Type | Field and Description |
---|---|
pack-priv static final TerminalOp | |
pack-priv static final TerminalOp |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | accept(long
the input argument value)Overrides java. Overrides default java. Implements java. |
public OptionalLong |
OP_FIND_ANY | back to summary |
---|---|
pack-priv static final TerminalOp<Long, OptionalLong> OP_FIND_ANY |
OP_FIND_FIRST | back to summary |
---|---|
pack-priv static final TerminalOp<Long, OptionalLong> OP_FIND_FIRST |
OfLong | back to summary |
---|---|
pack-priv OfLong() |
accept | back to summary |
---|---|
public void accept(long value) Overrides java. Overrides default java. Implements java. Doc from java. Accepts a long value.
|
get | back to summary |
---|---|
public OptionalLong get() Implements java. Doc from java. Gets a result.
|
FindSink
for reference streams
Modifier and Type | Field and Description |
---|---|
pack-priv static final TerminalOp | |
pack-priv static final TerminalOp |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public Optional |
OP_FIND_ANY | back to summary |
---|---|
pack-priv static final TerminalOp<?, ?> OP_FIND_ANY |
OP_FIND_FIRST | back to summary |
---|---|
pack-priv static final TerminalOp<?, ?> OP_FIND_FIRST |
OfRef | back to summary |
---|---|
pack-priv OfRef() |
get | back to summary |
---|---|
public Optional Implements java. Doc from java. Gets a result. |
ForkJoinTask
implementing parallel short-circuiting search
Modifier and Type | Field and Description |
---|---|
private final boolean | |
private final FindOps. |
Access | Constructor and Description |
---|---|
pack-priv | FindTask(FindOps.
|
pack-priv |
Modifier and Type | Method and Description |
---|---|
protected O | doLeaf()
Implements abstract java. |
private void | |
protected O | getEmptyResult()
Implements abstract java. |
protected FindOps. | makeChild(Spliterator<P_IN>
Spliterator describing the subtree rooted at
this node, obtained by splitting the parent Spliterator Implements abstract java. |
public void | onCompletion(CountedCompleter<?>
the task invoking this method (which may
be this task itself) caller)Overrides java. tryComplete is invoked
and the pending count is zero, or when the unconditional
method complete is invoked.
|
mustFindFirst | back to summary |
---|---|
private final boolean mustFindFirst |
op | back to summary |
---|---|
private final FindOps. |
FindTask | back to summary |
---|---|
pack-priv FindTask(FindOps. |
FindTask | back to summary |
---|---|
pack-priv FindTask(FindOps. |
doLeaf | back to summary |
---|---|
protected O doLeaf() Implements abstract java. Doc from java. Computes the result associated with a leaf node. Will be called by
|
foundResult | back to summary |
---|---|
private void foundResult(O answer) |
getEmptyResult | back to summary |
---|---|
protected O getEmptyResult() Implements abstract java. Doc from java. Returns the value indicating the computation completed with no task
finding a short-circuitable result. For example, for a "find" operation,
this might be null or an empty
|
makeChild | back to summary |
---|---|
protected FindOps. Implements abstract java. Doc from java. Constructs a new node of type T whose parent is the receiver; must call the AbstractTask(T, Spliterator) constructor with the receiver and the provided Spliterator.
|
onCompletion | back to summary |
---|---|
public void onCompletion(CountedCompleter<?> caller) Overrides java. Doc from java. Performs an action when method
|