MarginaliaSearch/code/processes/test-data/resources/mock-crawl-data/javadoc/stream.html
Viktor Lofgren 1d34224416 (refac) Remove src/main from all source code paths.
Look, this will make the git history look funny, but trimming unnecessary depth from the source tree is a very necessary sanity-preserving measure when dealing with a super-modularized codebase like this one.

While it makes the project configuration a bit less conventional, it will save you several clicks every time you jump between modules.  Which you'll do a lot, because it's *modul*ar.  The src/main/java convention makes a lot of sense for a non-modular project though.  This ain't that.
2024-02-23 16:13:40 +01:00

1894 lines
156 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_45) on Fri Apr 10 10:17:57 PDT 2015 -->
<title>Stream (Java Platform SE 8 )</title>
<meta name="date" content="2015-04-10">
<meta name="keywords" content="java.util.stream.Stream interface">
<meta name="keywords" content="filter()">
<meta name="keywords" content="map()">
<meta name="keywords" content="mapToInt()">
<meta name="keywords" content="mapToLong()">
<meta name="keywords" content="mapToDouble()">
<meta name="keywords" content="flatMap()">
<meta name="keywords" content="flatMapToInt()">
<meta name="keywords" content="flatMapToLong()">
<meta name="keywords" content="flatMapToDouble()">
<meta name="keywords" content="distinct()">
<meta name="keywords" content="sorted()">
<meta name="keywords" content="peek()">
<meta name="keywords" content="limit()">
<meta name="keywords" content="skip()">
<meta name="keywords" content="forEach()">
<meta name="keywords" content="forEachOrdered()">
<meta name="keywords" content="toArray()">
<meta name="keywords" content="reduce()">
<meta name="keywords" content="collect()">
<meta name="keywords" content="min()">
<meta name="keywords" content="max()">
<meta name="keywords" content="count()">
<meta name="keywords" content="anyMatch()">
<meta name="keywords" content="allMatch()">
<meta name="keywords" content="noneMatch()">
<meta name="keywords" content="findFirst()">
<meta name="keywords" content="findAny()">
<meta name="keywords" content="builder()">
<meta name="keywords" content="empty()">
<meta name="keywords" content="of()">
<meta name="keywords" content="iterate()">
<meta name="keywords" content="generate()">
<meta name="keywords" content="concat()">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Stream (Java Platform SE 8 )";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6,"i2":17,"i3":6,"i4":6,"i5":17,"i6":6,"i7":6,"i8":17,"i9":6,"i10":6,"i11":6,"i12":6,"i13":6,"i14":6,"i15":6,"i16":6,"i17":6,"i18":17,"i19":17,"i20":6,"i21":6,"i22":6,"i23":6,"i24":6,"i25":6,"i26":6,"i27":6,"i28":17,"i29":17,"i30":6,"i31":6,"i32":6,"i33":6,"i34":6,"i35":6,"i36":6,"i37":6,"i38":6};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],16:["t5","Default Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Stream.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><strong>Java&trade;&nbsp;Platform<br>Standard&nbsp;Ed.&nbsp;8</strong></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../java/util/stream/LongStream.Builder.html" title="interface in java.util.stream"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../java/util/stream/Stream.Builder.html" title="interface in java.util.stream"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?java/util/stream/Stream.html" target="_top">Frames</a></li>
<li><a href="Stream.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">compact1, compact2, compact3</div>
<div class="subTitle">java.util.stream</div>
<h2 title="Interface Stream" class="title">Interface Stream&lt;T&gt;</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the type of the stream elements</dd>
</dl>
<dl>
<dt>All Superinterfaces:</dt>
<dd><a href="../../../java/lang/AutoCloseable.html" title="interface in java.lang">AutoCloseable</a>, <a href="../../../java/util/stream/BaseStream.html" title="interface in java.util.stream">BaseStream</a>&lt;T,<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&gt;</dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">Stream&lt;T&gt;</span>
extends <a href="../../../java/util/stream/BaseStream.html" title="interface in java.util.stream">BaseStream</a>&lt;T,<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&gt;</pre>
<div class="block">A sequence of elements supporting sequential and parallel aggregate
operations. The following example illustrates an aggregate operation using
<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream"><code>Stream</code></a> and <a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream"><code>IntStream</code></a>:
<pre><code>
int sum = widgets.stream()
.filter(w -&gt; w.getColor() == RED)
.mapToInt(w -&gt; w.getWeight())
.sum();
</code></pre>
In this example, <code>widgets</code> is a <code>Collection&lt;Widget&gt;</code>. We create
a stream of <code>Widget</code> objects via <a href="../../../java/util/Collection.html#stream--"><code>Collection.stream()</code></a>,
filter it to produce a stream containing only the red widgets, and then
transform it into a stream of <code>int</code> values representing the weight of
each red widget. Then this stream is summed to produce a total weight.
<p>In addition to <code>Stream</code>, which is a stream of object references,
there are primitive specializations for <a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream"><code>IntStream</code></a>, <a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream"><code>LongStream</code></a>,
and <a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream"><code>DoubleStream</code></a>, all of which are referred to as "streams" and
conform to the characteristics and restrictions described here.
<p>To perform a computation, stream
<a href="package-summary.html#StreamOps">operations</a> are composed into a
<em>stream pipeline</em>. A stream pipeline consists of a source (which
might be an array, a collection, a generator function, an I/O channel,
etc), zero or more <em>intermediate operations</em> (which transform a
stream into another stream, such as <a href="../../../java/util/stream/Stream.html#filter-java.util.function.Predicate-"><code>filter(Predicate)</code></a>), and a
<em>terminal operation</em> (which produces a result or side-effect, such
as <a href="../../../java/util/stream/Stream.html#count--"><code>count()</code></a> or <a href="../../../java/util/stream/Stream.html#forEach-java.util.function.Consumer-"><code>forEach(Consumer)</code></a>).
Streams are lazy; computation on the source data is only performed when the
terminal operation is initiated, and source elements are consumed only
as needed.
<p>Collections and streams, while bearing some superficial similarities,
have different goals. Collections are primarily concerned with the efficient
management of, and access to, their elements. By contrast, streams do not
provide a means to directly access or manipulate their elements, and are
instead concerned with declaratively describing their source and the
computational operations which will be performed in aggregate on that source.
However, if the provided stream operations do not offer the desired
functionality, the <a href="../../../java/util/stream/BaseStream.html#iterator--"><code>BaseStream.iterator()</code></a> and <a href="../../../java/util/stream/BaseStream.html#spliterator--"><code>BaseStream.spliterator()</code></a> operations
can be used to perform a controlled traversal.
<p>A stream pipeline, like the "widgets" example above, can be viewed as
a <em>query</em> on the stream source. Unless the source was explicitly
designed for concurrent modification (such as a <a href="../../../java/util/concurrent/ConcurrentHashMap.html" title="class in java.util.concurrent"><code>ConcurrentHashMap</code></a>),
unpredictable or erroneous behavior may result from modifying the stream
source while it is being queried.
<p>Most stream operations accept parameters that describe user-specified
behavior, such as the lambda expression <code>w -&gt; w.getWeight()</code> passed to
<code>mapToInt</code> in the example above. To preserve correct behavior,
these <em>behavioral parameters</em>:
<ul>
<li>must be <a href="package-summary.html#NonInterference">non-interfering</a>
(they do not modify the stream source); and</li>
<li>in most cases must be <a href="package-summary.html#Statelessness">stateless</a>
(their result should not depend on any state that might change during execution
of the stream pipeline).</li>
</ul>
<p>Such parameters are always instances of a
<a href="../function/package-summary.html">functional interface</a> such
as <a href="../../../java/util/function/Function.html" title="interface in java.util.function"><code>Function</code></a>, and are often lambda expressions or
method references. Unless otherwise specified these parameters must be
<em>non-null</em>.
<p>A stream should be operated on (invoking an intermediate or terminal stream
operation) only once. This rules out, for example, "forked" streams, where
the same source feeds two or more pipelines, or multiple traversals of the
same stream. A stream implementation may throw <a href="../../../java/lang/IllegalStateException.html" title="class in java.lang"><code>IllegalStateException</code></a>
if it detects that the stream is being reused. However, since some stream
operations may return their receiver rather than a new stream object, it may
not be possible to detect reuse in all cases.
<p>Streams have a <a href="../../../java/util/stream/BaseStream.html#close--"><code>BaseStream.close()</code></a> method and implement <a href="../../../java/lang/AutoCloseable.html" title="interface in java.lang"><code>AutoCloseable</code></a>,
but nearly all stream instances do not actually need to be closed after use.
Generally, only streams whose source is an IO channel (such as those returned
by <a href="../../../java/nio/file/Files.html#lines-java.nio.file.Path-java.nio.charset.Charset-"><code>Files.lines(Path, Charset)</code></a>) will require closing. Most streams
are backed by collections, arrays, or generating functions, which require no
special resource management. (If a stream does require closing, it can be
declared as a resource in a <code>try</code>-with-resources statement.)
<p>Stream pipelines may execute either sequentially or in
<a href="package-summary.html#Parallelism">parallel</a>. This
execution mode is a property of the stream. Streams are created
with an initial choice of sequential or parallel execution. (For example,
<a href="../../../java/util/Collection.html#stream--"><code>Collection.stream()</code></a> creates a sequential stream,
and <a href="../../../java/util/Collection.html#parallelStream--"><code>Collection.parallelStream()</code></a> creates
a parallel one.) This choice of execution mode may be modified by the
<a href="../../../java/util/stream/BaseStream.html#sequential--"><code>BaseStream.sequential()</code></a> or <a href="../../../java/util/stream/BaseStream.html#parallel--"><code>BaseStream.parallel()</code></a> methods, and may be queried with
the <a href="../../../java/util/stream/BaseStream.html#isParallel--"><code>BaseStream.isParallel()</code></a> method.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.8</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream"><code>IntStream</code></a>,
<a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream"><code>LongStream</code></a>,
<a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream"><code>DoubleStream</code></a>,
<a href="package-summary.html">java.util.stream</a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Interface and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static interface&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.Builder.html" title="interface in java.util.stream">Stream.Builder</a>&lt;<a href="../../../java/util/stream/Stream.Builder.html" title="type parameter in Stream.Builder">T</a>&gt;</span></code>
<div class="block">A mutable builder for a <code>Stream</code>.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t5" class="tableTab"><span><a href="javascript:show(16);">Default Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#allMatch-java.util.function.Predicate-">allMatch</a></span>(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</code>
<div class="block">Returns whether all elements of this stream match the provided predicate.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#anyMatch-java.util.function.Predicate-">anyMatch</a></span>(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</code>
<div class="block">Returns whether any elements of this stream match the provided
predicate.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.Builder.html" title="interface in java.util.stream">Stream.Builder</a>&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#builder--">builder</a></span>()</code>
<div class="block">Returns a builder for a <code>Stream</code>.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>&lt;R,A&gt;&nbsp;R</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#collect-java.util.stream.Collector-">collect</a></span>(<a href="../../../java/util/stream/Collector.html" title="interface in java.util.stream">Collector</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,A,R&gt;&nbsp;collector)</code>
<div class="block">Performs a <a href="package-summary.html#MutableReduction">mutable
reduction</a> operation on the elements of this stream using a
<code>Collector</code>.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>&lt;R&gt;&nbsp;R</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#collect-java.util.function.Supplier-java.util.function.BiConsumer-java.util.function.BiConsumer-">collect</a></span>(<a href="../../../java/util/function/Supplier.html" title="interface in java.util.function">Supplier</a>&lt;R&gt;&nbsp;supplier,
<a href="../../../java/util/function/BiConsumer.html" title="interface in java.util.function">BiConsumer</a>&lt;R,? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;accumulator,
<a href="../../../java/util/function/BiConsumer.html" title="interface in java.util.function">BiConsumer</a>&lt;R,R&gt;&nbsp;combiner)</code>
<div class="block">Performs a <a href="package-summary.html#MutableReduction">mutable
reduction</a> operation on the elements of this stream.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#concat-java.util.stream.Stream-java.util.stream.Stream-">concat</a></span>(<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;? extends T&gt;&nbsp;a,
<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;? extends T&gt;&nbsp;b)</code>
<div class="block">Creates a lazily concatenated stream whose elements are all the
elements of the first stream followed by all the elements of the
second stream.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#count--">count</a></span>()</code>
<div class="block">Returns the count of elements in this stream.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#distinct--">distinct</a></span>()</code>
<div class="block">Returns a stream consisting of the distinct elements (according to
<a href="../../../java/lang/Object.html#equals-java.lang.Object-"><code>Object.equals(Object)</code></a>) of this stream.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#empty--">empty</a></span>()</code>
<div class="block">Returns an empty sequential <code>Stream</code>.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#filter-java.util.function.Predicate-">filter</a></span>(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</code>
<div class="block">Returns a stream consisting of the elements of this stream that match
the given predicate.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#findAny--">findAny</a></span>()</code>
<div class="block">Returns an <a href="../../../java/util/Optional.html" title="class in java.util"><code>Optional</code></a> describing some element of the stream, or an
empty <code>Optional</code> if the stream is empty.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#findFirst--">findFirst</a></span>()</code>
<div class="block">Returns an <a href="../../../java/util/Optional.html" title="class in java.util"><code>Optional</code></a> describing the first element of this stream,
or an empty <code>Optional</code> if the stream is empty.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>&lt;R&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;R&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#flatMap-java.util.function.Function-">flatMap</a></span>(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;? extends R&gt;&gt;&nbsp;mapper)</code>
<div class="block">Returns a stream consisting of the results of replacing each element of
this stream with the contents of a mapped stream produced by applying
the provided mapping function to each element.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream">DoubleStream</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#flatMapToDouble-java.util.function.Function-">flatMapToDouble</a></span>(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream">DoubleStream</a>&gt;&nbsp;mapper)</code>
<div class="block">Returns an <code>DoubleStream</code> consisting of the results of replacing
each element of this stream with the contents of a mapped stream produced
by applying the provided mapping function to each element.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream">IntStream</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#flatMapToInt-java.util.function.Function-">flatMapToInt</a></span>(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream">IntStream</a>&gt;&nbsp;mapper)</code>
<div class="block">Returns an <code>IntStream</code> consisting of the results of replacing each
element of this stream with the contents of a mapped stream produced by
applying the provided mapping function to each element.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream">LongStream</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#flatMapToLong-java.util.function.Function-">flatMapToLong</a></span>(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream">LongStream</a>&gt;&nbsp;mapper)</code>
<div class="block">Returns an <code>LongStream</code> consisting of the results of replacing each
element of this stream with the contents of a mapped stream produced by
applying the provided mapping function to each element.</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#forEach-java.util.function.Consumer-">forEach</a></span>(<a href="../../../java/util/function/Consumer.html" title="interface in java.util.function">Consumer</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;action)</code>
<div class="block">Performs an action for each element of this stream.</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#forEachOrdered-java.util.function.Consumer-">forEachOrdered</a></span>(<a href="../../../java/util/function/Consumer.html" title="interface in java.util.function">Consumer</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;action)</code>
<div class="block">Performs an action for each element of this stream, in the encounter
order of the stream if the stream has a defined encounter order.</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#generate-java.util.function.Supplier-">generate</a></span>(<a href="../../../java/util/function/Supplier.html" title="interface in java.util.function">Supplier</a>&lt;T&gt;&nbsp;s)</code>
<div class="block">Returns an infinite sequential unordered stream where each element is
generated by the provided <code>Supplier</code>.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#iterate-T-java.util.function.UnaryOperator-">iterate</a></span>(T&nbsp;seed,
<a href="../../../java/util/function/UnaryOperator.html" title="interface in java.util.function">UnaryOperator</a>&lt;T&gt;&nbsp;f)</code>
<div class="block">Returns an infinite sequential ordered <code>Stream</code> produced by iterative
application of a function <code>f</code> to an initial element <code>seed</code>,
producing a <code>Stream</code> consisting of <code>seed</code>, <code>f(seed)</code>,
<code>f(f(seed))</code>, etc.</div>
</td>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#limit-long-">limit</a></span>(long&nbsp;maxSize)</code>
<div class="block">Returns a stream consisting of the elements of this stream, truncated
to be no longer than <code>maxSize</code> in length.</div>
</td>
</tr>
<tr id="i21" class="rowColor">
<td class="colFirst"><code>&lt;R&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;R&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#map-java.util.function.Function-">map</a></span>(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends R&gt;&nbsp;mapper)</code>
<div class="block">Returns a stream consisting of the results of applying the given
function to the elements of this stream.</div>
</td>
</tr>
<tr id="i22" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream">DoubleStream</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#mapToDouble-java.util.function.ToDoubleFunction-">mapToDouble</a></span>(<a href="../../../java/util/function/ToDoubleFunction.html" title="interface in java.util.function">ToDoubleFunction</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;mapper)</code>
<div class="block">Returns a <code>DoubleStream</code> consisting of the results of applying the
given function to the elements of this stream.</div>
</td>
</tr>
<tr id="i23" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream">IntStream</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#mapToInt-java.util.function.ToIntFunction-">mapToInt</a></span>(<a href="../../../java/util/function/ToIntFunction.html" title="interface in java.util.function">ToIntFunction</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;mapper)</code>
<div class="block">Returns an <code>IntStream</code> consisting of the results of applying the
given function to the elements of this stream.</div>
</td>
</tr>
<tr id="i24" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream">LongStream</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#mapToLong-java.util.function.ToLongFunction-">mapToLong</a></span>(<a href="../../../java/util/function/ToLongFunction.html" title="interface in java.util.function">ToLongFunction</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;mapper)</code>
<div class="block">Returns a <code>LongStream</code> consisting of the results of applying the
given function to the elements of this stream.</div>
</td>
</tr>
<tr id="i25" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#max-java.util.Comparator-">max</a></span>(<a href="../../../java/util/Comparator.html" title="interface in java.util">Comparator</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;comparator)</code>
<div class="block">Returns the maximum element of this stream according to the provided
<code>Comparator</code>.</div>
</td>
</tr>
<tr id="i26" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#min-java.util.Comparator-">min</a></span>(<a href="../../../java/util/Comparator.html" title="interface in java.util">Comparator</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;comparator)</code>
<div class="block">Returns the minimum element of this stream according to the provided
<code>Comparator</code>.</div>
</td>
</tr>
<tr id="i27" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#noneMatch-java.util.function.Predicate-">noneMatch</a></span>(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</code>
<div class="block">Returns whether no elements of this stream match the provided predicate.</div>
</td>
</tr>
<tr id="i28" class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#of-T...-">of</a></span>(T...&nbsp;values)</code>
<div class="block">Returns a sequential ordered stream whose elements are the specified values.</div>
</td>
</tr>
<tr id="i29" class="rowColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#of-T-">of</a></span>(T&nbsp;t)</code>
<div class="block">Returns a sequential <code>Stream</code> containing a single element.</div>
</td>
</tr>
<tr id="i30" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#peek-java.util.function.Consumer-">peek</a></span>(<a href="../../../java/util/function/Consumer.html" title="interface in java.util.function">Consumer</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;action)</code>
<div class="block">Returns a stream consisting of the elements of this stream, additionally
performing the provided action on each element as elements are consumed
from the resulting stream.</div>
</td>
</tr>
<tr id="i31" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#reduce-java.util.function.BinaryOperator-">reduce</a></span>(<a href="../../../java/util/function/BinaryOperator.html" title="interface in java.util.function">BinaryOperator</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;accumulator)</code>
<div class="block">Performs a <a href="package-summary.html#Reduction">reduction</a> on the
elements of this stream, using an
<a href="package-summary.html#Associativity">associative</a> accumulation
function, and returns an <code>Optional</code> describing the reduced value,
if any.</div>
</td>
</tr>
<tr id="i32" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#reduce-T-java.util.function.BinaryOperator-">reduce</a></span>(<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&nbsp;identity,
<a href="../../../java/util/function/BinaryOperator.html" title="interface in java.util.function">BinaryOperator</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;accumulator)</code>
<div class="block">Performs a <a href="package-summary.html#Reduction">reduction</a> on the
elements of this stream, using the provided identity value and an
<a href="package-summary.html#Associativity">associative</a>
accumulation function, and returns the reduced value.</div>
</td>
</tr>
<tr id="i33" class="rowColor">
<td class="colFirst"><code>&lt;U&gt;&nbsp;U</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#reduce-U-java.util.function.BiFunction-java.util.function.BinaryOperator-">reduce</a></span>(U&nbsp;identity,
<a href="../../../java/util/function/BiFunction.html" title="interface in java.util.function">BiFunction</a>&lt;U,? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,U&gt;&nbsp;accumulator,
<a href="../../../java/util/function/BinaryOperator.html" title="interface in java.util.function">BinaryOperator</a>&lt;U&gt;&nbsp;combiner)</code>
<div class="block">Performs a <a href="package-summary.html#Reduction">reduction</a> on the
elements of this stream, using the provided identity, accumulation and
combining functions.</div>
</td>
</tr>
<tr id="i34" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#skip-long-">skip</a></span>(long&nbsp;n)</code>
<div class="block">Returns a stream consisting of the remaining elements of this stream
after discarding the first <code>n</code> elements of the stream.</div>
</td>
</tr>
<tr id="i35" class="rowColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#sorted--">sorted</a></span>()</code>
<div class="block">Returns a stream consisting of the elements of this stream, sorted
according to natural order.</div>
</td>
</tr>
<tr id="i36" class="altColor">
<td class="colFirst"><code><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#sorted-java.util.Comparator-">sorted</a></span>(<a href="../../../java/util/Comparator.html" title="interface in java.util">Comparator</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;comparator)</code>
<div class="block">Returns a stream consisting of the elements of this stream, sorted
according to the provided <code>Comparator</code>.</div>
</td>
</tr>
<tr id="i37" class="rowColor">
<td class="colFirst"><code><a href="../../../java/lang/Object.html" title="class in java.lang">Object</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#toArray--">toArray</a></span>()</code>
<div class="block">Returns an array containing the elements of this stream.</div>
</td>
</tr>
<tr id="i38" class="altColor">
<td class="colFirst"><code>&lt;A&gt;&nbsp;A[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../java/util/stream/Stream.html#toArray-java.util.function.IntFunction-">toArray</a></span>(<a href="../../../java/util/function/IntFunction.html" title="interface in java.util.function">IntFunction</a>&lt;A[]&gt;&nbsp;generator)</code>
<div class="block">Returns an array containing the elements of this stream, using the
provided <code>generator</code> function to allocate the returned array, as
well as any additional arrays that might be required for a partitioned
execution or for resizing.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.util.stream.BaseStream">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;java.util.stream.<a href="../../../java/util/stream/BaseStream.html" title="interface in java.util.stream">BaseStream</a></h3>
<code><a href="../../../java/util/stream/BaseStream.html#close--">close</a>, <a href="../../../java/util/stream/BaseStream.html#isParallel--">isParallel</a>, <a href="../../../java/util/stream/BaseStream.html#iterator--">iterator</a>, <a href="../../../java/util/stream/BaseStream.html#onClose-java.lang.Runnable-">onClose</a>, <a href="../../../java/util/stream/BaseStream.html#parallel--">parallel</a>, <a href="../../../java/util/stream/BaseStream.html#sequential--">sequential</a>, <a href="../../../java/util/stream/BaseStream.html#spliterator--">spliterator</a>, <a href="../../../java/util/stream/BaseStream.html#unordered--">unordered</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="filter-java.util.function.Predicate-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>filter</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;filter(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</pre>
<div class="block">Returns a stream consisting of the elements of this stream that match
the given predicate.
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>predicate</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
predicate to apply to each element to determine if it
should be included</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="map-java.util.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>map</h4>
<pre>&lt;R&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;R&gt;&nbsp;map(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends R&gt;&nbsp;mapper)</pre>
<div class="block">Returns a stream consisting of the results of applying the given
function to the elements of this stream.
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>R</code> - The element type of the new stream</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="mapToInt-java.util.function.ToIntFunction-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mapToInt</h4>
<pre><a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream">IntStream</a>&nbsp;mapToInt(<a href="../../../java/util/function/ToIntFunction.html" title="interface in java.util.function">ToIntFunction</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;mapper)</pre>
<div class="block">Returns an <code>IntStream</code> consisting of the results of applying the
given function to the elements of this stream.
<p>This is an <a href="package-summary.html#StreamOps">
intermediate operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="mapToLong-java.util.function.ToLongFunction-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mapToLong</h4>
<pre><a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream">LongStream</a>&nbsp;mapToLong(<a href="../../../java/util/function/ToLongFunction.html" title="interface in java.util.function">ToLongFunction</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;mapper)</pre>
<div class="block">Returns a <code>LongStream</code> consisting of the results of applying the
given function to the elements of this stream.
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="mapToDouble-java.util.function.ToDoubleFunction-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mapToDouble</h4>
<pre><a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream">DoubleStream</a>&nbsp;mapToDouble(<a href="../../../java/util/function/ToDoubleFunction.html" title="interface in java.util.function">ToDoubleFunction</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;mapper)</pre>
<div class="block">Returns a <code>DoubleStream</code> consisting of the results of applying the
given function to the elements of this stream.
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="flatMap-java.util.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>flatMap</h4>
<pre>&lt;R&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;R&gt;&nbsp;flatMap(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;? extends R&gt;&gt;&nbsp;mapper)</pre>
<div class="block">Returns a stream consisting of the results of replacing each element of
this stream with the contents of a mapped stream produced by applying
the provided mapping function to each element. Each mapped stream is
<a href="../../../java/util/stream/BaseStream.html#close--"><code>closed</code></a> after its contents
have been placed into this stream. (If a mapped stream is <code>null</code>
an empty stream is used, instead.)
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>The <code>flatMap()</code> operation has the effect of applying a one-to-many
transformation to the elements of the stream, and then flattening the
resulting elements into a new stream.
<p><b>Examples.</b>
<p>If <code>orders</code> is a stream of purchase orders, and each purchase
order contains a collection of line items, then the following produces a
stream containing all the line items in all the orders:
<pre><code>
orders.flatMap(order -&gt; order.getLineItems().stream())...
</code></pre>
<p>If <code>path</code> is the path to a file, then the following produces a
stream of the <code>words</code> contained in that file:
<pre><code>
Stream&lt;String&gt; lines = Files.lines(path, StandardCharsets.UTF_8);
Stream&lt;String&gt; words = lines.flatMap(line -&gt; Stream.of(line.split(" +")));
</code></pre>
The <code>mapper</code> function passed to <code>flatMap</code> splits a line,
using a simple regular expression, into an array of words, and then
creates a stream of words from that array.</dd>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>R</code> - The element type of the new stream</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element which produces a stream
of new values</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="flatMapToInt-java.util.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>flatMapToInt</h4>
<pre><a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream">IntStream</a>&nbsp;flatMapToInt(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/IntStream.html" title="interface in java.util.stream">IntStream</a>&gt;&nbsp;mapper)</pre>
<div class="block">Returns an <code>IntStream</code> consisting of the results of replacing each
element of this stream with the contents of a mapped stream produced by
applying the provided mapping function to each element. Each mapped
stream is <a href="../../../java/util/stream/BaseStream.html#close--"><code>closed</code></a> after its
contents have been placed into this stream. (If a mapped stream is
<code>null</code> an empty stream is used, instead.)
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element which produces a stream
of new values</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#flatMap-java.util.function.Function-"><code>flatMap(Function)</code></a></dd>
</dl>
</li>
</ul>
<a name="flatMapToLong-java.util.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>flatMapToLong</h4>
<pre><a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream">LongStream</a>&nbsp;flatMapToLong(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/LongStream.html" title="interface in java.util.stream">LongStream</a>&gt;&nbsp;mapper)</pre>
<div class="block">Returns an <code>LongStream</code> consisting of the results of replacing each
element of this stream with the contents of a mapped stream produced by
applying the provided mapping function to each element. Each mapped
stream is <a href="../../../java/util/stream/BaseStream.html#close--"><code>closed</code></a> after its
contents have been placed into this stream. (If a mapped stream is
<code>null</code> an empty stream is used, instead.)
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element which produces a stream
of new values</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#flatMap-java.util.function.Function-"><code>flatMap(Function)</code></a></dd>
</dl>
</li>
</ul>
<a name="flatMapToDouble-java.util.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>flatMapToDouble</h4>
<pre><a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream">DoubleStream</a>&nbsp;flatMapToDouble(<a href="../../../java/util/function/Function.html" title="interface in java.util.function">Function</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,? extends <a href="../../../java/util/stream/DoubleStream.html" title="interface in java.util.stream">DoubleStream</a>&gt;&nbsp;mapper)</pre>
<div class="block">Returns an <code>DoubleStream</code> consisting of the results of replacing
each element of this stream with the contents of a mapped stream produced
by applying the provided mapping function to each element. Each mapped
stream is <a href="../../../java/util/stream/BaseStream.html#close--"><code>closed</code></a> after its
contents have placed been into this stream. (If a mapped stream is
<code>null</code> an empty stream is used, instead.)
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function to apply to each element which produces a stream
of new values</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#flatMap-java.util.function.Function-"><code>flatMap(Function)</code></a></dd>
</dl>
</li>
</ul>
<a name="distinct--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>distinct</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;distinct()</pre>
<div class="block">Returns a stream consisting of the distinct elements (according to
<a href="../../../java/lang/Object.html#equals-java.lang.Object-"><code>Object.equals(Object)</code></a>) of this stream.
<p>For ordered streams, the selection of distinct elements is stable
(for duplicated elements, the element appearing first in the encounter
order is preserved.) For unordered streams, no stability guarantees
are made.
<p>This is a <a href="package-summary.html#StreamOps">stateful
intermediate operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>Preserving stability for <code>distinct()</code> in parallel pipelines is
relatively expensive (requires that the operation act as a full barrier,
with substantial buffering overhead), and stability is often not needed.
Using an unordered stream source (such as <a href="../../../java/util/stream/Stream.html#generate-java.util.function.Supplier-"><code>generate(Supplier)</code></a>)
or removing the ordering constraint with <a href="../../../java/util/stream/BaseStream.html#unordered--"><code>BaseStream.unordered()</code></a> may result
in significantly more efficient execution for <code>distinct()</code> in parallel
pipelines, if the semantics of your situation permit. If consistency
with encounter order is required, and you are experiencing poor performance
or memory utilization with <code>distinct()</code> in parallel pipelines,
switching to sequential execution with <a href="../../../java/util/stream/BaseStream.html#sequential--"><code>BaseStream.sequential()</code></a> may improve
performance.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="sorted--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sorted</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;sorted()</pre>
<div class="block">Returns a stream consisting of the elements of this stream, sorted
according to natural order. If the elements of this stream are not
<code>Comparable</code>, a <code>java.lang.ClassCastException</code> may be thrown
when the terminal operation is executed.
<p>For ordered streams, the sort is stable. For unordered streams, no
stability guarantees are made.
<p>This is a <a href="package-summary.html#StreamOps">stateful
intermediate operation</a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="sorted-java.util.Comparator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sorted</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;sorted(<a href="../../../java/util/Comparator.html" title="interface in java.util">Comparator</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;comparator)</pre>
<div class="block">Returns a stream consisting of the elements of this stream, sorted
according to the provided <code>Comparator</code>.
<p>For ordered streams, the sort is stable. For unordered streams, no
stability guarantees are made.
<p>This is a <a href="package-summary.html#StreamOps">stateful
intermediate operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>comparator</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
<code>Comparator</code> to be used to compare stream elements</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="peek-java.util.function.Consumer-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>peek</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;peek(<a href="../../../java/util/function/Consumer.html" title="interface in java.util.function">Consumer</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;action)</pre>
<div class="block">Returns a stream consisting of the elements of this stream, additionally
performing the provided action on each element as elements are consumed
from the resulting stream.
<p>This is an <a href="package-summary.html#StreamOps">intermediate
operation</a>.
<p>For parallel stream pipelines, the action may be called at
whatever time and in whatever thread the element is made available by the
upstream operation. If the action modifies shared state,
it is responsible for providing the required synchronization.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>This method exists mainly to support debugging, where you want
to see the elements as they flow past a certain point in a pipeline:
<pre><code>
Stream.of("one", "two", "three", "four")
.filter(e -&gt; e.length() &gt; 3)
.peek(e -&gt; System.out.println("Filtered value: " + e))
.map(String::toUpperCase)
.peek(e -&gt; System.out.println("Mapped value: " + e))
.collect(Collectors.toList());
</code></pre></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>action</code> - a <a href="package-summary.html#NonInterference">
non-interfering</a> action to perform on the elements as
they are consumed from the stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="limit-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>limit</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;limit(long&nbsp;maxSize)</pre>
<div class="block">Returns a stream consisting of the elements of this stream, truncated
to be no longer than <code>maxSize</code> in length.
<p>This is a <a href="package-summary.html#StreamOps">short-circuiting
stateful intermediate operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>While <code>limit()</code> is generally a cheap operation on sequential
stream pipelines, it can be quite expensive on ordered parallel pipelines,
especially for large values of <code>maxSize</code>, since <code>limit(n)</code>
is constrained to return not just any <em>n</em> elements, but the
<em>first n</em> elements in the encounter order. Using an unordered
stream source (such as <a href="../../../java/util/stream/Stream.html#generate-java.util.function.Supplier-"><code>generate(Supplier)</code></a>) or removing the
ordering constraint with <a href="../../../java/util/stream/BaseStream.html#unordered--"><code>BaseStream.unordered()</code></a> may result in significant
speedups of <code>limit()</code> in parallel pipelines, if the semantics of
your situation permit. If consistency with encounter order is required,
and you are experiencing poor performance or memory utilization with
<code>limit()</code> in parallel pipelines, switching to sequential execution
with <a href="../../../java/util/stream/BaseStream.html#sequential--"><code>BaseStream.sequential()</code></a> may improve performance.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>maxSize</code> - the number of elements the stream should be limited to</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</a></code> - if <code>maxSize</code> is negative</dd>
</dl>
</li>
</ul>
<a name="skip-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>skip</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;skip(long&nbsp;n)</pre>
<div class="block">Returns a stream consisting of the remaining elements of this stream
after discarding the first <code>n</code> elements of the stream.
If this stream contains fewer than <code>n</code> elements then an
empty stream will be returned.
<p>This is a <a href="package-summary.html#StreamOps">stateful
intermediate operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>While <code>skip()</code> is generally a cheap operation on sequential
stream pipelines, it can be quite expensive on ordered parallel pipelines,
especially for large values of <code>n</code>, since <code>skip(n)</code>
is constrained to skip not just any <em>n</em> elements, but the
<em>first n</em> elements in the encounter order. Using an unordered
stream source (such as <a href="../../../java/util/stream/Stream.html#generate-java.util.function.Supplier-"><code>generate(Supplier)</code></a>) or removing the
ordering constraint with <a href="../../../java/util/stream/BaseStream.html#unordered--"><code>BaseStream.unordered()</code></a> may result in significant
speedups of <code>skip()</code> in parallel pipelines, if the semantics of
your situation permit. If consistency with encounter order is required,
and you are experiencing poor performance or memory utilization with
<code>skip()</code> in parallel pipelines, switching to sequential execution
with <a href="../../../java/util/stream/BaseStream.html#sequential--"><code>BaseStream.sequential()</code></a> may improve performance.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - the number of leading elements to skip</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</a></code> - if <code>n</code> is negative</dd>
</dl>
</li>
</ul>
<a name="forEach-java.util.function.Consumer-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>forEach</h4>
<pre>void&nbsp;forEach(<a href="../../../java/util/function/Consumer.html" title="interface in java.util.function">Consumer</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;action)</pre>
<div class="block">Performs an action for each element of this stream.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.
<p>The behavior of this operation is explicitly nondeterministic.
For parallel stream pipelines, this operation does <em>not</em>
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.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>action</code> - a <a href="package-summary.html#NonInterference">
non-interfering</a> action to perform on the elements</dd>
</dl>
</li>
</ul>
<a name="forEachOrdered-java.util.function.Consumer-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>forEachOrdered</h4>
<pre>void&nbsp;forEachOrdered(<a href="../../../java/util/function/Consumer.html" title="interface in java.util.function">Consumer</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;action)</pre>
<div class="block">Performs an action for each element of this stream, in the encounter
order of the stream if the stream has a defined encounter order.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.
<p>This operation processes the elements one at a time, in encounter
order if one exists. Performing the action for one element
<a href="../concurrent/package-summary.html#MemoryVisibility"><i>happens-before</i></a>
performing the action for subsequent elements, but for any given element,
the action may be performed in whatever thread the library chooses.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>action</code> - a <a href="package-summary.html#NonInterference">
non-interfering</a> action to perform on the elements</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#forEach-java.util.function.Consumer-"><code>forEach(Consumer)</code></a></dd>
</dl>
</li>
</ul>
<a name="toArray--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toArray</h4>
<pre><a href="../../../java/lang/Object.html" title="class in java.lang">Object</a>[]&nbsp;toArray()</pre>
<div class="block">Returns an array containing the elements of this stream.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an array containing the elements of this stream</dd>
</dl>
</li>
</ul>
<a name="toArray-java.util.function.IntFunction-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toArray</h4>
<pre>&lt;A&gt;&nbsp;A[]&nbsp;toArray(<a href="../../../java/util/function/IntFunction.html" title="interface in java.util.function">IntFunction</a>&lt;A[]&gt;&nbsp;generator)</pre>
<div class="block">Returns an array containing the elements of this stream, using the
provided <code>generator</code> function to allocate the returned array, as
well as any additional arrays that might be required for a partitioned
execution or for resizing.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>The generator function takes an integer, which is the size of the
desired array, and produces an array of the desired size. This can be
concisely expressed with an array constructor reference:
<pre><code>
Person[] men = people.stream()
.filter(p -&gt; p.getGender() == MALE)
.toArray(Person[]::new);
</code></pre></dd>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>A</code> - the element type of the resulting array</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>generator</code> - a function which produces a new array of the desired
type and the provided length</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an array containing the elements in this stream</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/ArrayStoreException.html" title="class in java.lang">ArrayStoreException</a></code> - if the runtime type of the array returned
from the array generator is not a supertype of the runtime type of every
element in this stream</dd>
</dl>
</li>
</ul>
<a name="reduce-java.lang.Object-java.util.function.BinaryOperator-">
<!-- -->
</a><a name="reduce-T-java.util.function.BinaryOperator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reduce</h4>
<pre><a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&nbsp;reduce(<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&nbsp;identity,
<a href="../../../java/util/function/BinaryOperator.html" title="interface in java.util.function">BinaryOperator</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;accumulator)</pre>
<div class="block">Performs a <a href="package-summary.html#Reduction">reduction</a> on the
elements of this stream, using the provided identity value and an
<a href="package-summary.html#Associativity">associative</a>
accumulation function, and returns the reduced value. This is equivalent
to:
<pre><code>
T result = identity;
for (T element : this stream)
result = accumulator.apply(result, element)
return result;
</code></pre>
but is not constrained to execute sequentially.
<p>The <code>identity</code> value must be an identity for the accumulator
function. This means that for all <code>t</code>,
<code>accumulator.apply(identity, t)</code> is equal to <code>t</code>.
The <code>accumulator</code> function must be an
<a href="package-summary.html#Associativity">associative</a> function.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>Sum, min, max, average, and string concatenation are all special
cases of reduction. Summing a stream of numbers can be expressed as:
<pre><code>
Integer sum = integers.reduce(0, (a, b) -&gt; a+b);
</code></pre>
or:
<pre><code>
Integer sum = integers.reduce(0, Integer::sum);
</code></pre>
<p>While this may seem a more roundabout way to perform an aggregation
compared to simply mutating a running total in a loop, reduction
operations parallelize more gracefully, without needing additional
synchronization and with greatly reduced risk of data races.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>identity</code> - the identity value for the accumulating function</dd>
<dd><code>accumulator</code> - an <a href="package-summary.html#Associativity">associative</a>,
<a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function for combining two values</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the result of the reduction</dd>
</dl>
</li>
</ul>
<a name="reduce-java.util.function.BinaryOperator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reduce</h4>
<pre><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;reduce(<a href="../../../java/util/function/BinaryOperator.html" title="interface in java.util.function">BinaryOperator</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;accumulator)</pre>
<div class="block">Performs a <a href="package-summary.html#Reduction">reduction</a> on the
elements of this stream, using an
<a href="package-summary.html#Associativity">associative</a> accumulation
function, and returns an <code>Optional</code> describing the reduced value,
if any. This is equivalent to:
<pre><code>
boolean foundAny = false;
T result = null;
for (T element : this stream) {
if (!foundAny) {
foundAny = true;
result = element;
}
else
result = accumulator.apply(result, element);
}
return foundAny ? Optional.of(result) : Optional.empty();
</code></pre>
but is not constrained to execute sequentially.
<p>The <code>accumulator</code> function must be an
<a href="package-summary.html#Associativity">associative</a> function.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>accumulator</code> - an <a href="package-summary.html#Associativity">associative</a>,
<a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function for combining two values</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an <a href="../../../java/util/Optional.html" title="class in java.util"><code>Optional</code></a> describing the result of the reduction</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - if the result of the reduction is null</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#reduce-T-java.util.function.BinaryOperator-"><code>reduce(Object, BinaryOperator)</code></a>,
<a href="../../../java/util/stream/Stream.html#min-java.util.Comparator-"><code>min(Comparator)</code></a>,
<a href="../../../java/util/stream/Stream.html#max-java.util.Comparator-"><code>max(Comparator)</code></a></dd>
</dl>
</li>
</ul>
<a name="reduce-java.lang.Object-java.util.function.BiFunction-java.util.function.BinaryOperator-">
<!-- -->
</a><a name="reduce-U-java.util.function.BiFunction-java.util.function.BinaryOperator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reduce</h4>
<pre>&lt;U&gt;&nbsp;U&nbsp;reduce(U&nbsp;identity,
<a href="../../../java/util/function/BiFunction.html" title="interface in java.util.function">BiFunction</a>&lt;U,? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,U&gt;&nbsp;accumulator,
<a href="../../../java/util/function/BinaryOperator.html" title="interface in java.util.function">BinaryOperator</a>&lt;U&gt;&nbsp;combiner)</pre>
<div class="block">Performs a <a href="package-summary.html#Reduction">reduction</a> on the
elements of this stream, using the provided identity, accumulation and
combining functions. This is equivalent to:
<pre><code>
U result = identity;
for (T element : this stream)
result = accumulator.apply(result, element)
return result;
</code></pre>
but is not constrained to execute sequentially.
<p>The <code>identity</code> value must be an identity for the combiner
function. This means that for all <code>u</code>, <code>combiner(identity, u)</code>
is equal to <code>u</code>. Additionally, the <code>combiner</code> function
must be compatible with the <code>accumulator</code> function; for all
<code>u</code> and <code>t</code>, the following must hold:
<pre><code>
combiner.apply(u, accumulator.apply(identity, t)) == accumulator.apply(u, t)
</code></pre>
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>Many reductions using this form can be represented more simply
by an explicit combination of <code>map</code> and <code>reduce</code> operations.
The <code>accumulator</code> function acts as a fused mapper and accumulator,
which can sometimes be more efficient than separate mapping and reduction,
such as when knowing the previously reduced value allows you to avoid
some computation.</dd>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>U</code> - The type of the result</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>identity</code> - the identity value for the combiner function</dd>
<dd><code>accumulator</code> - an <a href="package-summary.html#Associativity">associative</a>,
<a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function for incorporating an additional element into a result</dd>
<dd><code>combiner</code> - an <a href="package-summary.html#Associativity">associative</a>,
<a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function for combining two values, which must be
compatible with the accumulator function</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the result of the reduction</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#reduce-java.util.function.BinaryOperator-"><code>reduce(BinaryOperator)</code></a>,
<a href="../../../java/util/stream/Stream.html#reduce-T-java.util.function.BinaryOperator-"><code>reduce(Object, BinaryOperator)</code></a></dd>
</dl>
</li>
</ul>
<a name="collect-java.util.function.Supplier-java.util.function.BiConsumer-java.util.function.BiConsumer-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>collect</h4>
<pre>&lt;R&gt;&nbsp;R&nbsp;collect(<a href="../../../java/util/function/Supplier.html" title="interface in java.util.function">Supplier</a>&lt;R&gt;&nbsp;supplier,
<a href="../../../java/util/function/BiConsumer.html" title="interface in java.util.function">BiConsumer</a>&lt;R,? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;accumulator,
<a href="../../../java/util/function/BiConsumer.html" title="interface in java.util.function">BiConsumer</a>&lt;R,R&gt;&nbsp;combiner)</pre>
<div class="block">Performs a <a href="package-summary.html#MutableReduction">mutable
reduction</a> operation on the elements of this stream. A mutable
reduction is one in which the reduced value is a mutable result container,
such as an <code>ArrayList</code>, and elements are incorporated by updating
the state of the result rather than by replacing the result. This
produces a result equivalent to:
<pre><code>
R result = supplier.get();
for (T element : this stream)
accumulator.accept(result, element);
return result;
</code></pre>
<p>Like <a href="../../../java/util/stream/Stream.html#reduce-T-java.util.function.BinaryOperator-"><code>reduce(Object, BinaryOperator)</code></a>, <code>collect</code> operations
can be parallelized without requiring additional synchronization.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>There are many existing classes in the JDK whose signatures are
well-suited for use with method references as arguments to <code>collect()</code>.
For example, the following will accumulate strings into an <code>ArrayList</code>:
<pre><code>
List&lt;String&gt; asList = stringStream.collect(ArrayList::new, ArrayList::add,
ArrayList::addAll);
</code></pre>
<p>The following will take a stream of strings and concatenates them into a
single string:
<pre><code>
String concat = stringStream.collect(StringBuilder::new, StringBuilder::append,
StringBuilder::append)
.toString();
</code></pre></dd>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>R</code> - type of the result</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>supplier</code> - a function that creates a new result container. For a
parallel execution, this function may be called
multiple times and must return a fresh value each time.</dd>
<dd><code>accumulator</code> - an <a href="package-summary.html#Associativity">associative</a>,
<a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function for incorporating an additional element into a result</dd>
<dd><code>combiner</code> - an <a href="package-summary.html#Associativity">associative</a>,
<a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
function for combining two values, which must be
compatible with the accumulator function</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the result of the reduction</dd>
</dl>
</li>
</ul>
<a name="collect-java.util.stream.Collector-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>collect</h4>
<pre>&lt;R,A&gt;&nbsp;R&nbsp;collect(<a href="../../../java/util/stream/Collector.html" title="interface in java.util.stream">Collector</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>,A,R&gt;&nbsp;collector)</pre>
<div class="block">Performs a <a href="package-summary.html#MutableReduction">mutable
reduction</a> operation on the elements of this stream using a
<code>Collector</code>. A <code>Collector</code>
encapsulates the functions used as arguments to
<a href="../../../java/util/stream/Stream.html#collect-java.util.function.Supplier-java.util.function.BiConsumer-java.util.function.BiConsumer-"><code>collect(Supplier, BiConsumer, BiConsumer)</code></a>, allowing for reuse of
collection strategies and composition of collect operations such as
multiple-level grouping or partitioning.
<p>If the stream is parallel, and the <code>Collector</code>
is <a href="../../../java/util/stream/Collector.Characteristics.html#CONCURRENT"><code>concurrent</code></a>, and
either the stream is unordered or the collector is
<a href="../../../java/util/stream/Collector.Characteristics.html#UNORDERED"><code>unordered</code></a>,
then a concurrent reduction will be performed (see <a href="../../../java/util/stream/Collector.html" title="interface in java.util.stream"><code>Collector</code></a> for
details on concurrent reduction.)
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.
<p>When executed in parallel, multiple intermediate results may be
instantiated, populated, and merged so as to maintain isolation of
mutable data structures. Therefore, even when executed in parallel
with non-thread-safe data structures (such as <code>ArrayList</code>), no
additional synchronization is needed for a parallel reduction.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>The following will accumulate strings into an ArrayList:
<pre><code>
List&lt;String&gt; asList = stringStream.collect(Collectors.toList());
</code></pre>
<p>The following will classify <code>Person</code> objects by city:
<pre><code>
Map&lt;String, List&lt;Person&gt;&gt; peopleByCity
= personStream.collect(Collectors.groupingBy(Person::getCity));
</code></pre>
<p>The following will classify <code>Person</code> objects by state and city,
cascading two <code>Collector</code>s together:
<pre><code>
Map&lt;String, Map&lt;String, List&lt;Person&gt;&gt;&gt; peopleByStateAndCity
= personStream.collect(Collectors.groupingBy(Person::getState,
Collectors.groupingBy(Person::getCity)));
</code></pre></dd>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>R</code> - the type of the result</dd>
<dd><code>A</code> - the intermediate accumulation type of the <code>Collector</code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>collector</code> - the <code>Collector</code> describing the reduction</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the result of the reduction</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#collect-java.util.function.Supplier-java.util.function.BiConsumer-java.util.function.BiConsumer-"><code>collect(Supplier, BiConsumer, BiConsumer)</code></a>,
<a href="../../../java/util/stream/Collectors.html" title="class in java.util.stream"><code>Collectors</code></a></dd>
</dl>
</li>
</ul>
<a name="min-java.util.Comparator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>min</h4>
<pre><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;min(<a href="../../../java/util/Comparator.html" title="interface in java.util">Comparator</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;comparator)</pre>
<div class="block">Returns the minimum element of this stream according to the provided
<code>Comparator</code>. This is a special case of a
<a href="package-summary.html#Reduction">reduction</a>.
<p>This is a <a href="package-summary.html#StreamOps">terminal operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>comparator</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
<code>Comparator</code> to compare elements of this stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an <code>Optional</code> describing the minimum element of this stream,
or an empty <code>Optional</code> if the stream is empty</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - if the minimum element is null</dd>
</dl>
</li>
</ul>
<a name="max-java.util.Comparator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>max</h4>
<pre><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;max(<a href="../../../java/util/Comparator.html" title="interface in java.util">Comparator</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;comparator)</pre>
<div class="block">Returns the maximum element of this stream according to the provided
<code>Comparator</code>. This is a special case of a
<a href="package-summary.html#Reduction">reduction</a>.
<p>This is a <a href="package-summary.html#StreamOps">terminal
operation</a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>comparator</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
<code>Comparator</code> to compare elements of this stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an <code>Optional</code> describing the maximum element of this stream,
or an empty <code>Optional</code> if the stream is empty</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - if the maximum element is null</dd>
</dl>
</li>
</ul>
<a name="count--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>count</h4>
<pre>long&nbsp;count()</pre>
<div class="block">Returns the count of elements in this stream. This is a special case of
a <a href="package-summary.html#Reduction">reduction</a> and is
equivalent to:
<pre><code>
return mapToLong(e -&gt; 1L).sum();
</code></pre>
<p>This is a <a href="package-summary.html#StreamOps">terminal operation</a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the count of elements in this stream</dd>
</dl>
</li>
</ul>
<a name="anyMatch-java.util.function.Predicate-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>anyMatch</h4>
<pre>boolean&nbsp;anyMatch(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</pre>
<div class="block">Returns whether any elements of this stream match the provided
predicate. May not evaluate the predicate on all elements if not
necessary for determining the result. If the stream is empty then
<code>false</code> is returned and the predicate is not evaluated.
<p>This is a <a href="package-summary.html#StreamOps">short-circuiting
terminal operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>This method evaluates the <em>existential quantification</em> of the
predicate over the elements of the stream (for some x P(x)).</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>predicate</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
predicate to apply to elements of this stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if any elements of the stream match the provided
predicate, otherwise <code>false</code></dd>
</dl>
</li>
</ul>
<a name="allMatch-java.util.function.Predicate-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>allMatch</h4>
<pre>boolean&nbsp;allMatch(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</pre>
<div class="block">Returns whether all elements of this stream match the provided predicate.
May not evaluate the predicate on all elements if not necessary for
determining the result. If the stream is empty then <code>true</code> is
returned and the predicate is not evaluated.
<p>This is a <a href="package-summary.html#StreamOps">short-circuiting
terminal operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>This method evaluates the <em>universal quantification</em> of the
predicate over the elements of the stream (for all x P(x)). If the
stream is empty, the quantification is said to be <em>vacuously
satisfied</em> and is always <code>true</code> (regardless of P(x)).</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>predicate</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
predicate to apply to elements of this stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if either all elements of the stream match the
provided predicate or the stream is empty, otherwise <code>false</code></dd>
</dl>
</li>
</ul>
<a name="noneMatch-java.util.function.Predicate-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>noneMatch</h4>
<pre>boolean&nbsp;noneMatch(<a href="../../../java/util/function/Predicate.html" title="interface in java.util.function">Predicate</a>&lt;? super <a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;predicate)</pre>
<div class="block">Returns whether no elements of this stream match the provided predicate.
May not evaluate the predicate on all elements if not necessary for
determining the result. If the stream is empty then <code>true</code> is
returned and the predicate is not evaluated.
<p>This is a <a href="package-summary.html#StreamOps">short-circuiting
terminal operation</a>.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>This method evaluates the <em>universal quantification</em> of the
negated predicate over the elements of the stream (for all x ~P(x)). If
the stream is empty, the quantification is said to be vacuously satisfied
and is always <code>true</code>, regardless of P(x).</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>predicate</code> - a <a href="package-summary.html#NonInterference">non-interfering</a>,
<a href="package-summary.html#Statelessness">stateless</a>
predicate to apply to elements of this stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if either no elements of the stream match the
provided predicate or the stream is empty, otherwise <code>false</code></dd>
</dl>
</li>
</ul>
<a name="findFirst--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>findFirst</h4>
<pre><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;findFirst()</pre>
<div class="block">Returns an <a href="../../../java/util/Optional.html" title="class in java.util"><code>Optional</code></a> describing the first element of this stream,
or an empty <code>Optional</code> if the stream is empty. If the stream has
no encounter order, then any element may be returned.
<p>This is a <a href="package-summary.html#StreamOps">short-circuiting
terminal operation</a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an <code>Optional</code> describing the first element of this stream,
or an empty <code>Optional</code> if the stream is empty</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - if the element selected is null</dd>
</dl>
</li>
</ul>
<a name="findAny--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>findAny</h4>
<pre><a href="../../../java/util/Optional.html" title="class in java.util">Optional</a>&lt;<a href="../../../java/util/stream/Stream.html" title="type parameter in Stream">T</a>&gt;&nbsp;findAny()</pre>
<div class="block">Returns an <a href="../../../java/util/Optional.html" title="class in java.util"><code>Optional</code></a> describing some element of the stream, or an
empty <code>Optional</code> if the stream is empty.
<p>This is a <a href="package-summary.html#StreamOps">short-circuiting
terminal operation</a>.
<p>The behavior of this operation is explicitly nondeterministic; it is
free to select any element in the stream. This is to allow for maximal
performance in parallel operations; the cost is that multiple invocations
on the same source may not return the same result. (If a stable result
is desired, use <a href="../../../java/util/stream/Stream.html#findFirst--"><code>findFirst()</code></a> instead.)</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an <code>Optional</code> describing some element of this stream, or an
empty <code>Optional</code> if the stream is empty</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - if the element selected is null</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../java/util/stream/Stream.html#findFirst--"><code>findFirst()</code></a></dd>
</dl>
</li>
</ul>
<a name="builder--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>builder</h4>
<pre>static&nbsp;&lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.Builder.html" title="interface in java.util.stream">Stream.Builder</a>&lt;T&gt;&nbsp;builder()</pre>
<div class="block">Returns a builder for a <code>Stream</code>.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - type of elements</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a stream builder</dd>
</dl>
</li>
</ul>
<a name="empty--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>empty</h4>
<pre>static&nbsp;&lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&nbsp;empty()</pre>
<div class="block">Returns an empty sequential <code>Stream</code>.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the type of stream elements</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an empty sequential stream</dd>
</dl>
</li>
</ul>
<a name="of-java.lang.Object-">
<!-- -->
</a><a name="of-T-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>of</h4>
<pre>static&nbsp;&lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&nbsp;of(T&nbsp;t)</pre>
<div class="block">Returns a sequential <code>Stream</code> containing a single element.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the type of stream elements</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>t</code> - the single element</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a singleton sequential stream</dd>
</dl>
</li>
</ul>
<a name="of-java.lang.Object:A-">
<!-- -->
</a><a name="of-T...-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>of</h4>
<pre><a href="../../../java/lang/SafeVarargs.html" title="annotation in java.lang">@SafeVarargs</a>
static&nbsp;&lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&nbsp;of(T...&nbsp;values)</pre>
<div class="block">Returns a sequential ordered stream whose elements are the specified values.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the type of stream elements</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - the elements of the new stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the new stream</dd>
</dl>
</li>
</ul>
<a name="iterate-java.lang.Object-java.util.function.UnaryOperator-">
<!-- -->
</a><a name="iterate-T-java.util.function.UnaryOperator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>iterate</h4>
<pre>static&nbsp;&lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&nbsp;iterate(T&nbsp;seed,
<a href="../../../java/util/function/UnaryOperator.html" title="interface in java.util.function">UnaryOperator</a>&lt;T&gt;&nbsp;f)</pre>
<div class="block">Returns an infinite sequential ordered <code>Stream</code> produced by iterative
application of a function <code>f</code> to an initial element <code>seed</code>,
producing a <code>Stream</code> consisting of <code>seed</code>, <code>f(seed)</code>,
<code>f(f(seed))</code>, etc.
<p>The first element (position <code>0</code>) in the <code>Stream</code> will be
the provided <code>seed</code>. For <code>n &gt; 0</code>, the element at position
<code>n</code>, will be the result of applying the function <code>f</code> to the
element at position <code>n - 1</code>.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the type of stream elements</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>seed</code> - the initial element</dd>
<dd><code>f</code> - a function to be applied to to the previous element to produce
a new element</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a new sequential <code>Stream</code></dd>
</dl>
</li>
</ul>
<a name="generate-java.util.function.Supplier-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>generate</h4>
<pre>static&nbsp;&lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&nbsp;generate(<a href="../../../java/util/function/Supplier.html" title="interface in java.util.function">Supplier</a>&lt;T&gt;&nbsp;s)</pre>
<div class="block">Returns an infinite sequential unordered stream where each element is
generated by the provided <code>Supplier</code>. This is suitable for
generating constant streams, streams of random elements, etc.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the type of stream elements</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>s</code> - the <code>Supplier</code> of generated elements</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a new infinite sequential unordered <code>Stream</code></dd>
</dl>
</li>
</ul>
<a name="concat-java.util.stream.Stream-java.util.stream.Stream-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>concat</h4>
<pre>static&nbsp;&lt;T&gt;&nbsp;<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;T&gt;&nbsp;concat(<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;? extends T&gt;&nbsp;a,
<a href="../../../java/util/stream/Stream.html" title="interface in java.util.stream">Stream</a>&lt;? extends T&gt;&nbsp;b)</pre>
<div class="block">Creates a lazily concatenated stream whose elements are all the
elements of the first stream followed by all the elements of the
second stream. The resulting stream is ordered if both
of the input streams are ordered, and parallel if either of the input
streams is parallel. When the resulting stream is closed, the close
handlers for both input streams are invoked.</div>
<dl>
<dt><span class="simpleTagLabel">Implementation Note:</span></dt>
<dd>Use caution when constructing streams from repeated concatenation.
Accessing an element of a deeply concatenated stream can result in deep
call chains, or even <code>StackOverflowException</code>.</dd>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - The type of stream elements</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - the first stream</dd>
<dd><code>b</code> - the second stream</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the concatenation of the two input streams</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Stream.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><strong>Java&trade;&nbsp;Platform<br>Standard&nbsp;Ed.&nbsp;8</strong></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../java/util/stream/LongStream.Builder.html" title="interface in java.util.stream"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../java/util/stream/Stream.Builder.html" title="interface in java.util.stream"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?java/util/stream/Stream.html" target="_top">Frames</a></li>
<li><a href="Stream.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small><font size="-1"> <a href="http://bugreport.sun.com/bugreport/">Submit a bug or feature</a> <br>For further API reference and developer documentation, see <a href="https://docs.oracle.com/javase/8/docs/index.html" target="_blank">Java SE Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.<br> <a href="../../../../legal/cpyr.html">Copyright</a> &#x00a9; 1993, 2015, Oracle and/or its affiliates. All rights reserved. </font></small></p>
</body>
</html>