BaseStream
Stream
and IntStream
, computing the sum of the weights of the red widgets:
int sum = widgets.stream()
.filter(w -> w.getColor() == RED)
.mapToInt(w -> w.getWeight())
.sum();
See the class documentation for Stream
and the package documentation
for java.util.stream for additional
specification of streams, stream operations, stream pipelines, and
parallelism, which governs the behavior of all stream types.
Stream
, IntStream
, LongStream
, DoubleStream
, java.util.stream
Modifier and Type | Method and Description |
---|---|
public void | close()
Redeclares java. Closes this stream, causing all close handlers for this stream pipeline to be called. |
public boolean | Returns: true if this stream would execute in parallel if executedReturns whether this stream, if a terminal operation were to be executed, would execute in parallel. |
public Iterator | Returns: the element iterator for this streamReturns an iterator for the elements of this stream. |
public S | |
public S | |
public S | |
public Spliterator | Returns: the element spliterator for this streamReturns a spliterator for the elements of this stream. |
public S |
close | back to summary |
---|---|
public void close() Redeclares java. Closes this stream, causing all close handlers for this stream pipeline to be called.
|
isParallel | back to summary |
---|---|
public boolean isParallel() Returns whether this stream, if a terminal operation were to be executed, would execute in parallel. Calling this method after invoking an terminal stream operation method may yield unpredictable results.
|
iterator | back to summary |
---|---|
public Iterator Returns an iterator for the elements of this stream. This is a terminal operation. API Note This operation is provided as an "escape hatch" to enable arbitrary client-controlled pipeline traversals in the event that the existing operations are not sufficient to the task.
|
onClose | back to summary |
---|---|
public S onClose(Runnable closeHandler) Returns an equivalent stream with an additional close handler. Close
handlers are run when the This is an intermediate operation.
|
parallel | back to summary |
---|---|
public S parallel() Returns an equivalent stream that is parallel. May return itself, either because the stream was already parallel, or because the underlying stream state was modified to be parallel. This is an intermediate operation.
|
sequential | back to summary |
---|---|
public S sequential() Returns an equivalent stream that is sequential. May return itself, either because the stream was already sequential, or because the underlying stream state was modified to be sequential. This is an intermediate operation.
|
spliterator | back to summary |
---|---|
public Spliterator Returns a spliterator for the elements of this stream. This is a terminal operation. API Note This operation is provided as an "escape hatch" to enable arbitrary client-controlled pipeline traversals in the event that the existing operations are not sufficient to the task. The returned spliterator should report the set of characteristics derived from the stream pipeline (namely the characteristics derived from the stream source spliterator and the intermediate operations). Implementations may report a sub-set of those characteristics. For example, it may be too expensive to compute the entire set for some or all possible stream pipelines.
|
unordered | back to summary |
---|---|
public S unordered() Returns an equivalent stream that is unordered. May return itself, either because the stream was already unordered, or because the underlying stream state was modified to be unordered. This is an intermediate operation.
|