T
- the type of elements.public interface Node<T>
T
.
A Node
contains a fixed number of elements, which can be accessed
via the count()
, spliterator()
, forEach(java.util.function.Consumer<? super T>)
,
asArray(java.util.function.IntFunction<T[]>)
, or copyInto(T[], int)
methods. A Node
may have zero
or more child Node
s; if it has no children (accessed via
getChildCount()
and getChild(int)
, it is considered flat
or a leaf; if it has children, it is considered an
internal node. The size of an internal node is the sum of sizes of
its children.
Modifier and Type | Interface and Description |
---|---|
static interface |
Node.Builder<T>
A mutable builder for a
Node that implements Sink , which
builds a flat node containing the elements that have been pushed to it. |
static interface |
Node.OfDouble
Specialized
Node for double elements |
static interface |
Node.OfInt
Specialized
Node for int elements |
static interface |
Node.OfLong
Specialized
Node for long elements |
static interface |
Node.OfPrimitive<T,T_CONS,T_ARR,T_SPLITR extends Spliterator.OfPrimitive<T,T_CONS,T_SPLITR>,T_NODE extends Node.OfPrimitive<T,T_CONS,T_ARR,T_SPLITR,T_NODE>> |
Modifier and Type | Method and Description |
---|---|
T[] |
asArray(IntFunction<T[]> generator)
Provides an array view of the contents of this node.
|
void |
copyInto(T[] array,
int offset)
Copies the content of this
Node into an array, starting at a
given offset into the array. |
long |
count()
Returns the number of elements contained in this node.
|
void |
forEach(Consumer<? super T> consumer)
Traverses the elements of this node, and invoke the provided
Consumer with each element. |
default Node<T> |
getChild(int i)
Retrieves the child
Node at a given index. |
default int |
getChildCount()
Returns the number of child nodes of this node.
|
default StreamShape |
getShape()
Gets the
StreamShape associated with this Node . |
Spliterator<T> |
spliterator()
Returns a
Spliterator describing the elements contained in this
Node . |
default Node<T> |
truncate(long from,
long to,
IntFunction<T[]> generator)
Return a node describing a subsequence of the elements of this node,
starting at the given inclusive start offset and ending at the given
exclusive end offset.
|
Spliterator<T> spliterator()
Spliterator
describing the elements contained in this
Node
.Spliterator
describing the elements contained in this
Node
void forEach(Consumer<? super T> consumer)
Consumer
with each element. Elements are provided in encounter
order if the source for the Node
has a defined encounter order.consumer
- a Consumer
that is to be invoked with each
element in this Node
default int getChildCount()
default Node<T> getChild(int i)
Node
at a given index.i
- the index to the child nodeIndexOutOfBoundsException
- if the index is less than 0 or greater
than or equal to the number of child nodesdefault Node<T> truncate(long from, long to, IntFunction<T[]> generator)
from
- The (inclusive) starting offset of elements to include, must
be in range 0..count().to
- The (exclusive) end offset of elements to include, must be
in range 0..count().generator
- A function to be used to create a new array, if needed,
for reference nodes.T[] asArray(IntFunction<T[]> generator)
Depending on the underlying implementation, this may return a
reference to an internal array rather than a copy. Since the returned
array may be shared, the returned array should not be modified. The
generator
function may be consulted to create the array if a new
array needs to be created.
generator
- a factory function which takes an integer parameter and
returns a new, empty array of that size and of the appropriate
array typeNode
void copyInto(T[] array, int offset)
Node
into an array, starting at a
given offset into the array. It is the caller's responsibility to ensure
there is sufficient room in the array, otherwise unspecified behaviour
will occur if the array length is less than the number of elements
contained in this node.array
- the array into which to copy the contents of this
Node
offset
- the starting offset within the arrayIndexOutOfBoundsException
- if copying would cause access of data
outside array boundsNullPointerException
- if array
is null
default StreamShape getShape()
StreamShape
associated with this Node
.long count()