APIdia Launch Partner
Top Description Inners Constructors Methods
java.util.stream

pack-priv final Class SliceOps

extends Object
Class Inheritance
Imports
java.util.Spliterator, java.util.concurrent.CountedCompleter, java.util.function.IntFunction

Factory for instances of a short-circuiting stateful intermediate operations that produce subsequences of their input stream.
Since
1.8

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SliceOps.SliceTask<
Input element type to the stream pipeline
P_IN
,
Output element type from the stream pipeline
P_OUT
>

ForkJoinTask implementing slice computation.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static long

Returns:

the sliced size
calcSize
(long
the current size
size
,
long
the number of elements to skip, assumed to be >= 0
skip
,
long
the number of elements to limit, assumed to be >= 0, with a value of Long.MAX_VALUE if there is no limit
limit
)

Calculates the sliced size given the current size, number of elements skip, and the number of elements to limit.

private static long

Returns:

the slice fence.
calcSliceFence
(long
the number of elements to skip, assumed to be >= 0
skip
,
long
the number of elements to limit, assumed to be >= 0, with a value of Long.MAX_VALUE if there is no limit
limit
)

Calculates the slice fence, which is one past the index of the slice range

private static int
flags(long limit)

public static DoubleStream
makeDouble(AbstractPipeline<?, Double, ?>
A DoubleStream
upstream
,
long
The number of elements to skip. Must be >= 0.
skip
,
long
The maximum size of the resulting stream, or -1 if no limit is to be imposed
limit
)

Appends a "slice" operation to the provided DoubleStream.

public static IntStream
makeInt(AbstractPipeline<?, Integer, ?>
An IntStream
upstream
,
long
The number of elements to skip. Must be >= 0.
skip
,
long
The maximum size of the resulting stream, or -1 if no limit is to be imposed
limit
)

Appends a "slice" operation to the provided IntStream.

public static LongStream
makeLong(AbstractPipeline<?, Long, ?>
A LongStream
upstream
,
long
The number of elements to skip. Must be >= 0.
skip
,
long
The maximum size of the resulting stream, or -1 if no limit is to be imposed
limit
)

Appends a "slice" operation to the provided LongStream.

public static <
the type of both input and output elements
T
>
Stream<T>
makeRef(AbstractPipeline<?, T, ?>
a reference stream with element type T
upstream
,
long
the number of elements to skip. Must be >= 0.
skip
,
long
the maximum size of the resulting stream, or -1 if no limit is to be imposed
limit
)

Appends a "slice" operation to the provided stream.

private static <P_IN> Spliterator<P_IN>
sliceSpliterator(StreamShape shape, Spliterator<P_IN> s, long skip, long limit)

Creates a slice spliterator given a stream shape governing the spliterator type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SliceOpsback to summary
private SliceOps()

Method Detail

calcSizeback to summary
private static long calcSize(long size, long skip, long limit)

Calculates the sliced size given the current size, number of elements skip, and the number of elements to limit.

Parameters
size:long

the current size

skip:long

the number of elements to skip, assumed to be >= 0

limit:long

the number of elements to limit, assumed to be >= 0, with a value of Long.MAX_VALUE if there is no limit

Returns:long

the sliced size

calcSliceFenceback to summary
private static long calcSliceFence(long skip, long limit)

Calculates the slice fence, which is one past the index of the slice range

Parameters
skip:long

the number of elements to skip, assumed to be >= 0

limit:long

the number of elements to limit, assumed to be >= 0, with a value of Long.MAX_VALUE if there is no limit

Returns:long

the slice fence.

flagsback to summary
private static int flags(long limit)
makeDoubleback to summary
public static DoubleStream makeDouble(AbstractPipeline<?, Double, ?> upstream, long skip, long limit)

Appends a "slice" operation to the provided DoubleStream. The slice operation may be may be skip-only, limit-only, or skip-and-limit.

Parameters
upstream:AbstractPipeline<?, Double, ?>

A DoubleStream

skip:long

The number of elements to skip. Must be >= 0.

limit:long

The maximum size of the resulting stream, or -1 if no limit is to be imposed

makeIntback to summary
public static IntStream makeInt(AbstractPipeline<?, Integer, ?> upstream, long skip, long limit)

Appends a "slice" operation to the provided IntStream. The slice operation may be may be skip-only, limit-only, or skip-and-limit.

Parameters
upstream:AbstractPipeline<?, Integer, ?>

An IntStream

skip:long

The number of elements to skip. Must be >= 0.

limit:long

The maximum size of the resulting stream, or -1 if no limit is to be imposed

makeLongback to summary
public static LongStream makeLong(AbstractPipeline<?, Long, ?> upstream, long skip, long limit)

Appends a "slice" operation to the provided LongStream. The slice operation may be may be skip-only, limit-only, or skip-and-limit.

Parameters
upstream:AbstractPipeline<?, Long, ?>

A LongStream

skip:long

The number of elements to skip. Must be >= 0.

limit:long

The maximum size of the resulting stream, or -1 if no limit is to be imposed

makeRefback to summary
public static <T> Stream<T> makeRef(AbstractPipeline<?, T, ?> upstream, long skip, long limit)

Appends a "slice" operation to the provided stream. The slice operation may be may be skip-only, limit-only, or skip-and-limit.

Parameters
<T>
the type of both input and output elements
upstream:AbstractPipeline<?, T, ?>

a reference stream with element type T

skip:long

the number of elements to skip. Must be >= 0.

limit:long

the maximum size of the resulting stream, or -1 if no limit is to be imposed

sliceSpliteratorback to summary
private static <P_IN> Spliterator<P_IN> sliceSpliterator(StreamShape shape, Spliterator<P_IN> s, long skip, long limit)

Creates a slice spliterator given a stream shape governing the spliterator type. Requires that the underlying Spliterator be SUBSIZED.

java.util.stream back to summary

private final Class SliceOps.SliceTask<P_IN, P_OUT>

extends AbstractShortCircuitTask<P_IN, P_OUT, Node<P_OUT>, SliceOps.SliceTask<P_IN, P_OUT>>
Class Inheritance
Annotations
@SuppressWarnings:serial
Type Parameters
<P_IN>
Input element type to the stream pipeline
<P_OUT>
Output element type from the stream pipeline

ForkJoinTask implementing slice computation.

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final IntFunction<P_OUT[]>
private final AbstractPipeline<P_OUT, P_OUT, ?>
private final long
private final long
private long
Inherited from java.util.stream.AbstractShortCircuitTask:
canceledsharedResult

Constructor Summary

AccessConstructor and Description
pack-priv
SliceTask(AbstractPipeline<P_OUT, P_OUT, ?> op, PipelineHelper<P_OUT> helper, Spliterator<P_IN> spliterator, IntFunction<P_OUT[]> generator, long offset, long size)

pack-priv
SliceTask(SliceOps.SliceTask<P_IN, P_OUT> parent, Spliterator<P_IN> spliterator)

Method Summary

Modifier and TypeMethod and Description
protected void
cancel()

Overrides java.util.stream.AbstractShortCircuitTask.cancel.

Mark this task as canceled

private long

Returns:

the number of completed elements
completedSize
(long
the target size
target
)

Compute the number of completed elements in this node.

protected final Node<P_OUT>
doLeaf()

Implements abstract java.util.stream.AbstractTask.doLeaf.

Computes the result associated with a leaf node.

private Node<P_OUT>
doTruncate(Node<P_OUT> input)

protected final Node<P_OUT>
getEmptyResult()

Implements abstract java.util.stream.AbstractShortCircuitTask.getEmptyResult.

Returns the value indicating the computation completed with no task finding a short-circuitable result.

private boolean

Returns:

true if the number of elements is greater than or equal to the target size, otherwise false.
isLeftCompleted
(long
the target size
target
)

Determine if the number of completed elements in this node and nodes to the left of this node is greater than or equal to the target size.

protected SliceOps.SliceTask<P_IN, P_OUT>
makeChild(Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.AbstractTask.makeChild.

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.

public final void
onCompletion(CountedCompleter<?> caller)

Overrides java.util.stream.AbstractTask.onCompletion.

Performs an action when method tryComplete is invoked and the pending count is zero, or when the unconditional method complete is invoked.

Inherited from java.util.stream.AbstractShortCircuitTask:
cancelLaterNodescomputegetLocalResultgetRawResultsetLocalResultshortCircuittaskCanceled

Field Detail

completedback to summary
private volatile boolean completed
generatorback to summary
private final IntFunction<P_OUT[]> generator
opback to summary
private final AbstractPipeline<P_OUT, P_OUT, ?> op
targetOffsetback to summary
private final long targetOffset
targetSizeback to summary
private final long targetSize

Hides java.util.stream.AbstractTask.targetSize.

thisNodeSizeback to summary
private long thisNodeSize

Constructor Detail

SliceTaskback to summary
pack-priv SliceTask(AbstractPipeline<P_OUT, P_OUT, ?> op, PipelineHelper<P_OUT> helper, Spliterator<P_IN> spliterator, IntFunction<P_OUT[]> generator, long offset, long size)
SliceTaskback to summary
pack-priv SliceTask(SliceOps.SliceTask<P_IN, P_OUT> parent, Spliterator<P_IN> spliterator)

Method Detail

cancelback to summary
protected void cancel()

Overrides java.util.stream.AbstractShortCircuitTask.cancel.

Doc from java.util.stream.AbstractShortCircuitTask.cancel.

Mark this task as canceled

Annotations
@Override
completedSizeback to summary
private long completedSize(long target)

Compute the number of completed elements in this node.

Computation terminates if all nodes have been processed or the number of completed elements is greater than or equal to the target size.

Parameters
target:long

the target size

Returns:long

the number of completed elements

doLeafback to summary
protected final Node<P_OUT> doLeaf()

Implements abstract java.util.stream.AbstractTask.doLeaf.

Doc from java.util.stream.AbstractTask.doLeaf.

Computes the result associated with a leaf node. Will be called by compute() and the result passed to setLocalResult()

Annotations
@Override
doTruncateback to summary
private Node<P_OUT> doTruncate(Node<P_OUT> input)
getEmptyResultback to summary
protected final Node<P_OUT> getEmptyResult()

Implements abstract java.util.stream.AbstractShortCircuitTask.getEmptyResult.

Doc from java.util.stream.AbstractShortCircuitTask.getEmptyResult.

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 Optional.

Annotations
@Override
isLeftCompletedback to summary
private boolean isLeftCompleted(long target)

Determine if the number of completed elements in this node and nodes to the left of this node is greater than or equal to the target size.

Parameters
target:long

the target size

Returns:boolean

true if the number of elements is greater than or equal to the target size, otherwise false.

makeChildback to summary
protected SliceOps.SliceTask<P_IN, P_OUT> makeChild(Spliterator<P_IN> spliterator)

Implements abstract java.util.stream.AbstractTask.makeChild.

Doc from java.util.stream.AbstractTask.makeChild.

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.

Annotations
@Override
onCompletionback to summary
public final void onCompletion(CountedCompleter<?> caller)

Overrides java.util.stream.AbstractTask.onCompletion.

Doc from java.util.stream.AbstractTask.onCompletion.

Performs an action when method tryComplete is invoked and the pending count is zero, or when the unconditional method complete is invoked. By default, this method does nothing. You can distinguish cases by checking the identity of the given caller argument. If not equal to this, then it is typically a subtask that may contain results (and/or links to other results) to combine.

Annotations
@Override