OpenJDK / lambda / lambda / jdk
changeset 8090:e8eea7e26b32
Break up Streams.java into Streams and StreamSupport
line wrap: on
line diff
--- a/src/share/classes/java/io/BufferedReader.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/io/BufferedReader.java Thu Apr 11 20:37:23 2013 -0400 @@ -31,7 +31,7 @@ import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Stream; -import java.util.stream.Streams; +import java.util.stream.StreamSupport; /** * Reads text from a character-input stream, buffering characters so as to @@ -584,6 +584,6 @@ } } }; - return Streams.stream(Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED)); + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED)); } }
--- a/src/share/classes/java/lang/CharSequence.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/lang/CharSequence.java Thu Apr 11 20:37:23 2013 -0400 @@ -31,7 +31,7 @@ import java.util.Spliterators; import java.util.function.IntConsumer; import java.util.stream.IntStream; -import java.util.stream.Streams; +import java.util.stream.StreamSupport; /** * A <tt>CharSequence</tt> is a readable sequence of <code>char</code> values. This @@ -143,8 +143,8 @@ } } - return Streams.intStream(() -> Spliterators.spliterator(new CharIterator(), length(), Spliterator.ORDERED), - Spliterator.SUBSIZED | Spliterator.SIZED | Spliterator.ORDERED); + return StreamSupport.intStream(() -> Spliterators.spliterator(new CharIterator(), length(), Spliterator.ORDERED), + Spliterator.SUBSIZED | Spliterator.SIZED | Spliterator.ORDERED); } /** @@ -190,7 +190,7 @@ } } - return Streams.intStream(() -> Spliterators.spliteratorUnknownSize(new CodePointIterator(), Spliterator.ORDERED), - Spliterator.SUBSIZED | Spliterator.SIZED | Spliterator.ORDERED); + return StreamSupport.intStream(() -> Spliterators.spliteratorUnknownSize(new CodePointIterator(), Spliterator.ORDERED), + Spliterator.SUBSIZED | Spliterator.SIZED | Spliterator.ORDERED); } }
--- a/src/share/classes/java/nio/file/DirectoryStream.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/nio/file/DirectoryStream.java Thu Apr 11 20:37:23 2013 -0400 @@ -31,7 +31,7 @@ import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Stream; -import java.util.stream.Streams; +import java.util.stream.StreamSupport; /** * An object to iterate over the entries in a directory. A directory stream @@ -174,6 +174,6 @@ * @since 1.8 */ default Stream<T> entries() { - return Streams.stream(Spliterators.spliteratorUnknownSize(iterator(), Spliterator.DISTINCT)); + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator(), Spliterator.DISTINCT)); } }
--- a/src/share/classes/java/nio/file/Files.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/nio/file/Files.java Thu Apr 11 20:37:23 2013 -0400 @@ -45,7 +45,7 @@ import java.util.stream.CloseableStream; import java.util.stream.DelegatingStream; import java.util.stream.Stream; -import java.util.stream.Streams; +import java.util.stream.StreamSupport; import java.security.AccessController; import java.security.PrivilegedAction; import java.nio.charset.Charset; @@ -3222,8 +3222,8 @@ }; return new DelegatingCloseableStream<>(ds, - Streams.stream(Spliterators.spliteratorUnknownSize(it, - Spliterator.DISTINCT))); + StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, + Spliterator.DISTINCT))); } /** @@ -3314,7 +3314,7 @@ FileTreeIterator itor = FileTreeIterator.iterator(start, maxDepth, options); return new DelegatingCloseableStream<>(itor, - Streams.stream(Spliterators.spliteratorUnknownSize(itor, Spliterator.DISTINCT)) + StreamSupport.stream(Spliterators.spliteratorUnknownSize(itor, Spliterator.DISTINCT)) .map(entry -> entry.getPath())); } @@ -3411,7 +3411,7 @@ } FileTreeIterator itor = FileTreeIterator.iterator(start, maxDepth, options); return new DelegatingCloseableStream<>(itor, - Streams.stream(Spliterators.spliteratorUnknownSize(itor, Spliterator.DISTINCT)) + StreamSupport.stream(Spliterators.spliteratorUnknownSize(itor, Spliterator.DISTINCT)) .filter(entry -> matcher.test(entry.getPath(), entry.getFileAttributes())) .map(entry -> entry.getPath())); }
--- a/src/share/classes/java/util/Arrays.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/util/Arrays.java Thu Apr 11 20:37:23 2013 -0400 @@ -39,6 +39,7 @@ import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; +import java.util.stream.StreamSupport; import java.util.stream.Streams; /** @@ -4820,7 +4821,7 @@ * @since 1.8 */ public static <T> Stream<T> stream(T[] array, int fromIndex, int toIndex) { - return Streams.stream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.stream(spliterator(array, fromIndex, toIndex)); } /** @@ -4852,7 +4853,7 @@ * @since 1.8 */ public static IntStream stream(int[] array, int fromIndex, int toIndex) { - return Streams.intStream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.intStream(spliterator(array, fromIndex, toIndex)); } /** @@ -4884,7 +4885,7 @@ * @since 1.8 */ public static LongStream stream(long[] array, int fromIndex, int toIndex) { - return Streams.longStream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.longStream(spliterator(array, fromIndex, toIndex)); } /** @@ -4916,7 +4917,7 @@ * @since 1.8 */ public static DoubleStream stream(double[] array, int fromIndex, int toIndex) { - return Streams.doubleStream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.doubleStream(spliterator(array, fromIndex, toIndex)); } /** @@ -4950,7 +4951,7 @@ * @since 1.8 */ public static <T> Stream<T> parallelStream(T[] array, int fromIndex, int toIndex) { - return Streams.parallelStream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.parallelStream(spliterator(array, fromIndex, toIndex)); } /** @@ -4982,7 +4983,7 @@ * @since 1.8 */ public static IntStream parallelStream(int[] array, int fromIndex, int toIndex) { - return Streams.intParallelStream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.intParallelStream(spliterator(array, fromIndex, toIndex)); } /** @@ -5014,7 +5015,7 @@ * @since 1.8 */ public static LongStream parallelStream(long[] array, int fromIndex, int toIndex) { - return Streams.longParallelStream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.longParallelStream(spliterator(array, fromIndex, toIndex)); } /** @@ -5046,6 +5047,6 @@ * @since 1.8 */ public static DoubleStream parallelStream(double[] array, int fromIndex, int toIndex) { - return Streams.doubleParallelStream(spliterator(array, fromIndex, toIndex)); + return StreamSupport.doubleParallelStream(spliterator(array, fromIndex, toIndex)); } }
--- a/src/share/classes/java/util/BitSet.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/util/BitSet.java Thu Apr 11 20:37:23 2013 -0400 @@ -30,7 +30,7 @@ import java.nio.ByteOrder; import java.nio.LongBuffer; import java.util.stream.IntStream; -import java.util.stream.Streams; +import java.util.stream.StreamSupport; /** * This class implements a vector of bits that grows as needed. Each @@ -1222,10 +1222,10 @@ } } - return Streams.intStream(() -> Spliterators.spliterator(new BitSetIterator(), cardinality(), Spliterator.ORDERED | - Spliterator.DISTINCT | - Spliterator.SORTED), - Spliterator.SIZED | Spliterator.SUBSIZED | - Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED); + return StreamSupport.intStream(() -> Spliterators.spliterator(new BitSetIterator(), cardinality(), Spliterator.ORDERED | + Spliterator.DISTINCT | + Spliterator.SORTED), + Spliterator.SIZED | Spliterator.SUBSIZED | + Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED); } }
--- a/src/share/classes/java/util/Collection.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/util/Collection.java Thu Apr 11 20:37:23 2013 -0400 @@ -27,7 +27,7 @@ import java.util.function.Predicate; import java.util.stream.Stream; -import java.util.stream.Streams; +import java.util.stream.StreamSupport; /** * The root interface in the <i>collection hierarchy</i>. A collection @@ -553,7 +553,7 @@ * @since 1.8 */ default Stream<E> stream() { - return Streams.stream(spliterator()); + return StreamSupport.stream(spliterator()); } /** @@ -573,7 +573,7 @@ * @since 1.8 */ default Stream<E> parallelStream() { - return Streams.parallelStream(spliterator()); + return StreamSupport.parallelStream(spliterator()); } }
--- a/src/share/classes/java/util/regex/Pattern.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/util/regex/Pattern.java Thu Apr 11 20:37:23 2013 -0400 @@ -25,9 +25,6 @@ package java.util.regex; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.text.CharacterIterator; import java.text.Normalizer; import java.util.Locale; import java.util.Iterator; @@ -38,10 +35,9 @@ import java.util.NoSuchElementException; import java.util.Spliterator; import java.util.Spliterators; -import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Stream; -import java.util.stream.Streams; +import java.util.stream.StreamSupport; /** @@ -5835,7 +5831,7 @@ * */ public Stream<String> splitAsStream(final CharSequence input) { - return Streams.stream(Spliterators.spliteratorUnknownSize(new MatcherIterator(input, matcher(input)), - Spliterator.ORDERED | Spliterator.NONNULL)); + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new MatcherIterator(input, matcher(input)), + Spliterator.ORDERED | Spliterator.NONNULL)); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/util/stream/StreamSupport.java Thu Apr 11 20:37:23 2013 -0400 @@ -0,0 +1,508 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.util.stream; + +import java.util.Objects; +import java.util.Spliterator; +import java.util.function.Supplier; + +/** + * Low-level utility methods for creating and manipulating streams. + * + * <p>This class is mostly for library writers presenting stream views + * of their data structures; most static stream methods for end users are in + * {@link Streams}. + * + * <p> Unless otherwise stated, streams are created as sequential + * streams. A sequential stream can be transformed into a parallel stream by + * calling the {@code parallel()} method on the created stream. + * + * @since 1.8 + */ +public class StreamSupport { + /** + * Creates a new sequential {@code Stream} from a {@code Spliterator}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator} describing the stream elements + * @param <T> The type of stream elements + * @return A new sequential {@code Stream} + */ + public static<T> Stream<T> stream(Spliterator<T> spliterator) { + Objects.requireNonNull(spliterator); + return new ReferencePipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + false); + } + + /** + * Creates a new parallel {@code Stream} from a {@code Spliterator}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator} describing the stream elements + * @param <T> The type of stream elements + * @return A new parallel {@code Stream} + */ + public static<T> Stream<T> parallelStream(Spliterator<T> spliterator) { + Objects.requireNonNull(spliterator); + return new ReferencePipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + true); + } + + /** + * Creates a new sequential {@code Stream} from a {@code Supplier} of + * {@code Spliterator}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #stream(java.util.Spliterator)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @param <T> The type of stream elements + * @return A new sequential {@code Stream} + * @see #stream(Spliterator) + */ + public static<T> Stream<T> stream(Supplier<? extends Spliterator<T>> supplier, + int characteristics) { + Objects.requireNonNull(supplier); + return new ReferencePipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + false); + } + + /** + * Creates a new parallel {@code Stream} from a {@code Supplier} of + * {@code Spliterator}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #stream(Spliterator)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @param <T> The type of stream elements + * @return A new parallel {@code Stream} + * @see #parallelStream(Spliterator) + */ + public static<T> Stream<T> parallelStream(Supplier<? extends Spliterator<T>> supplier, + int characteristics) { + Objects.requireNonNull(supplier); + return new ReferencePipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + true); + } + + /** + * Creates a new sequential {@code IntStream} from a {@code Spliterator.OfInt}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)}} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator.OfInt} describing the stream elements + * @return A new sequential {@code IntStream} + */ + public static IntStream intStream(Spliterator.OfInt spliterator) { + return new IntPipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + false); + } + + /** + * Creates a new parallel {@code IntStream} from a {@code Spliterator.OfInt}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)}} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator.OfInt} describing the stream elements + * @return A new parallel {@code IntStream} + */ + public static IntStream intParallelStream(Spliterator.OfInt spliterator) { + return new IntPipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + true); + } + + /** + * Creates a new sequential {@code IntStream} from a {@code Supplier} of + * {@code Spliterator.OfInt}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #intStream(Spliterator.OfInt)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator.OfInt} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator.OfInt}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @return A new sequential {@code IntStream} + * @see #intStream(Spliterator.OfInt) + */ + public static IntStream intStream(Supplier<? extends Spliterator.OfInt> supplier, + int characteristics) { + return new IntPipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + false); + } + + /** + * Creates a new parallel {@code IntStream} from a {@code Supplier} of + * {@code Spliterator.OfInt}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #intStream(Spliterator.OfInt)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator.OfInt} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator.OfInt}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @return A new parallel {@code IntStream} + * @see #intParallelStream(Spliterator.OfInt) + */ + public static IntStream intParallelStream(Supplier<? extends Spliterator.OfInt> supplier, + int characteristics) { + return new IntPipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + true); + } + + /** + * Creates a new sequential {@code LongStream} from a {@code Spliterator.OfLong}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator.OfLong} describing the stream elements + * @return A new sequential {@code LongStream} + */ + public static LongStream longStream(Spliterator.OfLong spliterator) { + return new LongPipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + false); + } + + /** + * Creates a new parallel {@code LongStream} from a {@code Spliterator.OfLong}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator.OfLong} describing the stream elements + * @return A new parallel {@code LongStream} + */ + public static LongStream longParallelStream(Spliterator.OfLong spliterator) { + return new LongPipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + true); + } + + /** + * Creates a new sequential {@code LongStream} from a {@code Supplier} of + * {@code Spliterator.OfLong}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #longStream(Spliterator.OfLong)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator.OfLong} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator.OfLong}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @return A new sequential {@code LongStream} + * @see #longStream(Spliterator.OfLong) + */ + public static LongStream longStream(Supplier<? extends Spliterator.OfLong> supplier, + int characteristics) { + return new LongPipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + false); + } + + /** + * Creates a new parallel {@code LongStream} from a {@code Supplier} of + * {@code Spliterator.OfLong}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #longStream(Spliterator.OfLong)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator.OfLong} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator.OfLong}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @return A new parallel {@code LongStream} + * @see #longParallelStream(Spliterator.OfLong) + */ + public static LongStream longParallelStream(Supplier<? extends Spliterator.OfLong> supplier, + int characteristics) { + return new LongPipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + true); + } + + /** + * Creates a new sequential {@code DoubleStream} from a {@code Spliterator.OfDouble}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator.OfDouble} describing the stream elements + * @return A new sequential {@code DoubleStream} + */ + public static DoubleStream doubleStream(Spliterator.OfDouble spliterator) { + return new DoublePipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + false); + } + + /** + * Creates a new parallel {@code DoubleStream} from a {@code Spliterator.OfDouble}. + * <p> + * The spliterator is only traversed, split, or queried for estimated size + * after the terminal operation of the stream pipeline commences. + * <p> + * It is strongly recommended the spliterator report a characteristic of + * {@code IMMUTABLE} or {@code CONCURRENT}, or be + * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, + * {@link #stream(Supplier, int)} should be used to + * reduce the scope of potential interference with the source. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param spliterator A {@code Spliterator.OfDouble} describing the stream elements + * @return A new parallel {@code DoubleStream} + */ + public static DoubleStream doubleParallelStream(Spliterator.OfDouble spliterator) { + return new DoublePipeline.Head<>(spliterator, + StreamOpFlag.fromCharacteristics(spliterator), + true); + } + + /** + * Creates a new sequential {@code DoubleStream} from a {@code Supplier} of + * {@code Spliterator.OfDouble}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #doubleStream(Spliterator.OfDouble)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator.OfDouble} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator.OfDouble}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @return A new sequential {@code DoubleStream} + * @see #doubleStream(Spliterator.OfDouble) + */ + public static DoubleStream doubleStream(Supplier<? extends Spliterator.OfDouble> supplier, + int characteristics) { + return new DoublePipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + false); + } + + /** + * Creates a new parallel {@code DoubleStream} from a {@code Supplier} of + * {@code Spliterator.OfDouble}. + * <p> + * The {@link Supplier#get()} method will be invoked on the supplier no + * more than once, and after the terminal operation of the stream pipeline + * commences. + * <p> + * For spliterators that report a characteristic of {@code IMMUTABLE} + * or {@code CONCURRENT}, or that are + * <a href="Spliterator.html#binding">late-binding</a>, it is likely + * more efficient to use {@link #doubleStream(Spliterator.OfDouble)} instead. + * The use of a {@code Supplier} in this form provides a level of + * indirection that reduces the scope of potential interference with the + * source. Since the supplier is only invoked after the terminal operation + * commences, any modifications to the source up to the start of the + * terminal operation are reflected in the stream result. See + * <a href="package-summary.html#Non-Interference">Non-Interference</a> for + * more details. + * + * @param supplier A {@code Supplier} of a {@code Spliterator.OfDouble} + * @param characteristics Spliterator characteristics of the supplied + * {@code Spliterator.OfDouble}. The characteristics must be equal to + * {@code source.get().getCharacteristics()} + * @return A new parallel {@code DoubleStream} + * @see #doubleParallelStream(Spliterator.OfDouble) + */ + public static DoubleStream doubleParallelStream(Supplier<? extends Spliterator.OfDouble> supplier, + int characteristics) { + return new DoublePipeline.Head<>(supplier, + StreamOpFlag.fromCharacteristics(characteristics), + true); + } +}
--- a/src/share/classes/java/util/stream/Streams.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/util/stream/Streams.java Thu Apr 11 20:37:23 2013 -0400 @@ -87,7 +87,7 @@ * @return An empty sequential {@code Stream} */ public static<T> Stream<T> emptyStream() { - return stream(Spliterators.<T>emptySpliterator()); + return StreamSupport.stream(Spliterators.<T>emptySpliterator()); } /** @@ -98,129 +98,7 @@ * @return A singleton sequential {@code Stream} */ public static<T> Stream<T> singletonStream(T t) { - return stream(new StreamBuilderImpl<>(t)); - } - - /** - * Creates a new sequential {@code Stream} from a {@code Supplier} of - * {@code Spliterator}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #stream(java.util.Spliterator)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @param <T> The type of stream elements - * @return A new sequential {@code Stream} - * @see #stream(Spliterator) - */ - public static<T> Stream<T> stream(Supplier<? extends Spliterator<T>> supplier, - int characteristics) { - Objects.requireNonNull(supplier); - return new ReferencePipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - false); - } - - /** - * Creates a new parallel {@code Stream} from a {@code Supplier} of - * {@code Spliterator}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #stream(java.util.Spliterator)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @param <T> The type of stream elements - * @return A new parallel {@code Stream} - * @see #parallelStream(Spliterator) - */ - public static<T> Stream<T> parallelStream(Supplier<? extends Spliterator<T>> supplier, - int characteristics) { - Objects.requireNonNull(supplier); - return new ReferencePipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - true); - } - - /** - * Creates a new sequential {@code Stream} from a {@code Spliterator}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator} describing the stream elements - * @param <T> The type of stream elements - * @return A new sequential {@code Stream} - */ - public static<T> Stream<T> stream(Spliterator<T> spliterator) { - Objects.requireNonNull(spliterator); - return new ReferencePipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - false); - } - - /** - * Creates a new parallel {@code Stream} from a {@code Spliterator}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator} describing the stream elements - * @param <T> The type of stream elements - * @return A new parallel {@code Stream} - */ - public static<T> Stream<T> parallelStream(Spliterator<T> spliterator) { - Objects.requireNonNull(spliterator); - return new ReferencePipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - true); + return StreamSupport.stream(new StreamBuilderImpl<>(t)); } // IntStream construction @@ -240,7 +118,7 @@ * @return An empty sequential {@code IntStream} */ public static IntStream emptyIntStream() { - return intStream(Spliterators.emptyIntSpliterator()); + return StreamSupport.intStream(Spliterators.emptyIntSpliterator()); } /** @@ -250,121 +128,7 @@ * @return A singleton sequential {@code IntStream} */ public static IntStream singletonIntStream(int t) { - return intStream(new IntStreamBuilderImpl(t)); - } - - /** - * Creates a new sequential {@code IntStream} from a {@code Supplier} of - * {@code Spliterator.OfInt}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #intStream(java.util.Spliterator.OfInt)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator.OfInt} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator.OfInt}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @return A new sequential {@code IntStream} - * @see #intStream(Spliterator.OfInt) - */ - public static IntStream intStream(Supplier<? extends Spliterator.OfInt> supplier, - int characteristics) { - return new IntPipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - false); - } - - /** - * Creates a new parallel {@code IntStream} from a {@code Supplier} of - * {@code Spliterator.OfInt}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #intStream(java.util.Spliterator.OfInt)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator.OfInt} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator.OfInt}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @return A new parallel {@code IntStream} - * @see #intParallelStream(Spliterator.OfInt) - */ - public static IntStream intParallelStream(Supplier<? extends Spliterator.OfInt> supplier, - int characteristics) { - return new IntPipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - true); - } - - /** - * Creates a new sequential {@code IntStream} from a {@code Spliterator.OfInt}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator.OfInt} describing the stream elements - * @return A new sequential {@code IntStream} - */ - public static IntStream intStream(Spliterator.OfInt spliterator) { - return new IntPipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - false); - } - - /** - * Creates a new parallel {@code IntStream} from a {@code Spliterator.OfInt}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator.OfInt} describing the stream elements - * @return A new parallel {@code IntStream} - */ - public static IntStream intParallelStream(Spliterator.OfInt spliterator) { - return new IntPipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - true); + return StreamSupport.intStream(new IntStreamBuilderImpl(t)); } // LongStream construction @@ -384,7 +148,7 @@ * @return An empty sequential {@code LongStream} */ public static LongStream emptyLongStream() { - return longStream(Spliterators.emptyLongSpliterator()); + return StreamSupport.longStream(Spliterators.emptyLongSpliterator()); } /** @@ -394,121 +158,7 @@ * @return A singleton sequential {@code LongStream} */ public static LongStream singletonLongStream(long t) { - return longStream(new LongStreamBuilderImpl(t)); - } - - /** - * Creates a new sequential {@code LongStream} from a {@code Supplier} of - * {@code Spliterator.OfLong}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #longStream(java.util.Spliterator.OfLong)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator.OfLong} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator.OfLong}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @return A new sequential {@code LongStream} - * @see #longStream(Spliterator.OfLong) - */ - public static LongStream longStream(Supplier<? extends Spliterator.OfLong> supplier, - int characteristics) { - return new LongPipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - false); - } - - /** - * Creates a new parallel {@code LongStream} from a {@code Supplier} of - * {@code Spliterator.OfLong}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #longStream(java.util.Spliterator.OfLong)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator.OfLong} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator.OfLong}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @return A new parallel {@code LongStream} - * @see #longParallelStream(Spliterator.OfLong) - */ - public static LongStream longParallelStream(Supplier<? extends Spliterator.OfLong> supplier, - int characteristics) { - return new LongPipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - true); - } - - /** - * Creates a new sequential {@code LongStream} from a {@code Spliterator.OfLong}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator.OfLong} describing the stream elements - * @return A new sequential {@code LongStream} - */ - public static LongStream longStream(Spliterator.OfLong spliterator) { - return new LongPipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - false); - } - - /** - * Creates a new parallel {@code LongStream} from a {@code Spliterator.OfLong}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator.OfLong} describing the stream elements - * @return A new parallel {@code LongStream} - */ - public static LongStream longParallelStream(Spliterator.OfLong spliterator) { - return new LongPipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - true); + return StreamSupport.longStream(new LongStreamBuilderImpl(t)); } // DoubleStream construction @@ -528,7 +178,7 @@ * @return An empty sequential {@code DoubleStream} */ public static DoubleStream emptyDoubleStream() { - return doubleStream(Spliterators.emptyDoubleSpliterator()); + return StreamSupport.doubleStream(Spliterators.emptyDoubleSpliterator()); } /** @@ -538,121 +188,7 @@ * @return A singleton sequential {@code DoubleStream} */ public static DoubleStream singletonDoubleStream(double t) { - return doubleStream(new DoubleStreamBuilderImpl(t)); - } - - /** - * Creates a new sequential {@code DoubleStream} from a {@code Supplier} of - * {@code Spliterator.OfDouble}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #doubleStream(java.util.Spliterator.OfDouble)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator.OfDouble} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator.OfDouble}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @return A new sequential {@code DoubleStream} - * @see #doubleStream(Spliterator.OfDouble) - */ - public static DoubleStream doubleStream(Supplier<? extends Spliterator.OfDouble> supplier, - int characteristics) { - return new DoublePipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - false); - } - - /** - * Creates a new parallel {@code DoubleStream} from a {@code Supplier} of - * {@code Spliterator.OfDouble}. - * <p> - * The {@link Supplier#get()} method will be invoked on the supplier no - * more than once, and after the terminal operation of the stream pipeline - * commences. - * <p> - * For spliterators that report a characteristic of {@code IMMUTABLE} - * or {@code CONCURRENT}, or that are - * <a href="Spliterator.html#binding">late-binding</a>, it is likely - * more efficient to use {@link #doubleStream(java.util.Spliterator.OfDouble)} instead. - * The use of a {@code Supplier} in this form provides a level of - * indirection that reduces the scope of potential interference with the - * source. Since the supplier is only invoked after the terminal operation - * commences, any modifications to the source up to the start of the - * terminal operation are reflected in the stream result. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param supplier A {@code Supplier} of a {@code Spliterator.OfDouble} - * @param characteristics Spliterator characteristics of the supplied - * {@code Spliterator.OfDouble}. The characteristics must be equal to - * {@code source.get().getCharacteristics()} - * @return A new parallel {@code DoubleStream} - * @see #doubleParallelStream(Spliterator.OfDouble) - */ - public static DoubleStream doubleParallelStream(Supplier<? extends Spliterator.OfDouble> supplier, - int characteristics) { - return new DoublePipeline.Head<>(supplier, - StreamOpFlag.fromCharacteristics(characteristics), - true); - } - - /** - * Creates a new sequential {@code DoubleStream} from a {@code Spliterator.OfDouble}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator.OfDouble} describing the stream elements - * @return A new sequential {@code DoubleStream} - */ - public static DoubleStream doubleStream(Spliterator.OfDouble spliterator) { - return new DoublePipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - false); - } - - /** - * Creates a new parallel {@code DoubleStream} from a {@code Spliterator.OfDouble}. - * <p> - * The spliterator is only traversed, split, or queried for estimated size - * after the terminal operation of the stream pipeline commences. - * <p> - * It is strongly recommended the spliterator report a characteristic of - * {@code IMMUTABLE} or {@code CONCURRENT}, or be - * <a href="Spliterator.html#binding">late-binding</a>. Otherwise, - * {@link #stream(java.util.function.Supplier, int)} should be used to - * reduce the scope of potential interference with the source. See - * <a href="package-summary.html#Non-Interference">Non-Interference</a> for - * more details. - * - * @param spliterator A {@code Spliterator.OfDouble} describing the stream elements - * @return A new parallel {@code DoubleStream} - */ - public static DoubleStream doubleParallelStream(Spliterator.OfDouble spliterator) { - return new DoublePipeline.Head<>(spliterator, - StreamOpFlag.fromCharacteristics(spliterator), - true); + return StreamSupport.doubleStream(new DoubleStreamBuilderImpl(t)); } // Infinite Stream generators @@ -685,7 +221,7 @@ return t = (t == NONE) ? seed : f.apply(t); } }; - return stream(Spliterators.spliteratorUnknownSize( + return StreamSupport.stream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE)); } @@ -702,7 +238,7 @@ public static<T> Stream<T> generate(Supplier<T> s) { Objects.requireNonNull(s); InfiniteIterator<T> iterator = s::get; - return stream(Spliterators.spliteratorUnknownSize( + return StreamSupport.stream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE)); } @@ -737,7 +273,7 @@ return v; } }; - return intStream(Spliterators.spliteratorUnknownSize( + return StreamSupport.intStream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL)); } @@ -753,7 +289,7 @@ public static IntStream generateInt(IntSupplier s) { Objects.requireNonNull(s); InfiniteIterator.OfInt iterator = s::getAsInt; - return intStream(Spliterators.spliteratorUnknownSize( + return StreamSupport.intStream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL)); } @@ -817,7 +353,7 @@ else if (step == 0) { throw new IllegalArgumentException("Illegal range: step(0)"); } - return intStream(new RangeIntSpliterator(start, end, step)); + return StreamSupport.intStream(new RangeIntSpliterator(start, end, step)); } // Infinite LongStream generators and ranges @@ -850,7 +386,7 @@ return v; } }; - return longStream(Spliterators.spliteratorUnknownSize( + return StreamSupport.longStream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL)); } @@ -867,7 +403,7 @@ public static LongStream generateLong(LongSupplier s) { Objects.requireNonNull(s); InfiniteIterator.OfLong iterator = s::getAsLong; - return longStream(Spliterators.spliteratorUnknownSize( + return StreamSupport.longStream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL)); } @@ -931,7 +467,7 @@ else if (step == 0) { throw new IllegalArgumentException("Illegal range: step(0)"); } - return longStream(new RangeLongSpliterator(start, end, step)); + return StreamSupport.longStream(new RangeLongSpliterator(start, end, step)); } // Infinite DoubleStream generators @@ -964,7 +500,7 @@ return v; } }; - return doubleStream(Spliterators.spliteratorUnknownSize( + return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL)); } @@ -980,7 +516,7 @@ public static DoubleStream generateDouble(DoubleSupplier s) { Objects.requireNonNull(s); InfiniteIterator.OfDouble iterator = s::getAsDouble; - return doubleStream(Spliterators.spliteratorUnknownSize( + return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL)); } @@ -1065,7 +601,7 @@ String.format("Illegal range: size %f > Long.MAX_VALUE", size)); } - return doubleStream(new RangeDoubleSpliterator(start, end, step, 0, (long) size)); + return StreamSupport.doubleStream(new RangeDoubleSpliterator(start, end, step, 0, (long) size)); } // Stream combining functions @@ -1162,8 +698,8 @@ }; return (a.isParallel() || b.isParallel()) - ? parallelStream(split) - : stream(split); + ? StreamSupport.parallelStream(split) + : StreamSupport.stream(split); } /** @@ -1219,8 +755,8 @@ Spliterator<C> split = Spliterators.spliterator(cIterator, zipSize, characteristics); return (a.isParallel() || b.isParallel()) - ? parallelStream(split) - : stream(split); + ? StreamSupport.parallelStream(split) + : StreamSupport.stream(split); } // Iterator and Spliterator implementations @@ -1564,7 +1100,7 @@ count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer - return (c < 2) ? Streams.stream(this) : Streams.stream(buffer.spliterator()); + return (c < 2) ? StreamSupport.stream(this) : StreamSupport.stream(buffer.spliterator()); } throw new IllegalStateException(); @@ -1650,7 +1186,7 @@ count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer - return (c < 2) ? Streams.intStream(this) : Streams.intStream(buffer.spliterator()); + return (c < 2) ? StreamSupport.intStream(this) : StreamSupport.intStream(buffer.spliterator()); } throw new IllegalStateException(); @@ -1736,7 +1272,7 @@ count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer - return (c < 2) ? Streams.longStream(this) : Streams.longStream(buffer.spliterator()); + return (c < 2) ? StreamSupport.longStream(this) : StreamSupport.longStream(buffer.spliterator()); } throw new IllegalStateException(); @@ -1822,7 +1358,7 @@ count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer - return (c < 2) ? Streams.doubleStream(this) : Streams.doubleStream(buffer.spliterator()); + return (c < 2) ? StreamSupport.doubleStream(this) : StreamSupport.doubleStream(buffer.spliterator()); } throw new IllegalStateException();
--- a/src/share/classes/java/util/zip/ZipFile.java Thu Apr 11 12:54:30 2013 -0700 +++ b/src/share/classes/java/util/zip/ZipFile.java Thu Apr 11 20:37:23 2013 -0400 @@ -42,10 +42,9 @@ import java.util.Spliterator; import java.util.Spliterators; import java.util.WeakHashMap; -import java.security.AccessController; import java.util.stream.Stream; -import java.util.stream.Streams; -import sun.security.action.GetPropertyAction; +import java.util.stream.StreamSupport; + import static java.util.zip.ZipConstants64.*; /** @@ -532,7 +531,7 @@ */ public Stream<? extends ZipEntry> stream() { final Enumeration<? extends ZipEntry> entries = entries(); - return Streams.stream(Spliterators.spliterator(new Iterator<ZipEntry>() { + return StreamSupport.stream(Spliterators.spliterator(new Iterator<ZipEntry>() { @Override public boolean hasNext() { return entries.hasMoreElements();
--- a/test-ng/bootlib/java/util/stream/DoubleStreamTestData.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/DoubleStreamTestData.java Thu Apr 11 20:37:23 2013 -0400 @@ -103,12 +103,12 @@ @Override public DoubleStream stream() { - return Streams.doubleStream(i.spliterator()); + return StreamSupport.doubleStream(i.spliterator()); } @Override public DoubleStream parallelStream() { - return Streams.doubleParallelStream(i.spliterator()); + return StreamSupport.doubleParallelStream(i.spliterator()); } @Override @@ -173,12 +173,12 @@ @Override public DoubleStream stream() { - return Streams.doubleStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); + return StreamSupport.doubleStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); } @Override public DoubleStream parallelStream() { - return Streams.doubleParallelStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); + return StreamSupport.doubleParallelStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); } @Override
--- a/test-ng/bootlib/java/util/stream/DoubleStreamTestScenario.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/DoubleStreamTestScenario.java Thu Apr 11 20:37:23 2013 -0400 @@ -114,7 +114,7 @@ <T, S_IN extends BaseStream<T, S_IN>> void _run(OpTestCase.TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) { DoubleStream s = m.apply(data.parallelStream()); Spliterator.OfDouble sp = s.spliterator(); - DoubleStream ss = Streams.doubleParallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); + DoubleStream ss = StreamSupport.doubleParallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); for (double t : ss.toArray()) b.accept(t); }
--- a/test-ng/bootlib/java/util/stream/IntStreamTestData.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/IntStreamTestData.java Thu Apr 11 20:37:23 2013 -0400 @@ -104,12 +104,12 @@ @Override public IntStream stream() { - return Streams.intStream(i.spliterator()); + return StreamSupport.intStream(i.spliterator()); } @Override public IntStream parallelStream() { - return Streams.intParallelStream(i.spliterator()); + return StreamSupport.intParallelStream(i.spliterator()); } @Override @@ -174,12 +174,12 @@ @Override public IntStream stream() { - return Streams.intStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); + return StreamSupport.intStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); } @Override public IntStream parallelStream() { - return Streams.intParallelStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); + return StreamSupport.intParallelStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); } @Override
--- a/test-ng/bootlib/java/util/stream/IntStreamTestScenario.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/IntStreamTestScenario.java Thu Apr 11 20:37:23 2013 -0400 @@ -114,7 +114,7 @@ <T, S_IN extends BaseStream<T, S_IN>> void _run(OpTestCase.TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) { IntStream s = m.apply(data.parallelStream()); Spliterator.OfInt sp = s.spliterator(); - IntStream ss = Streams.intParallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); + IntStream ss = StreamSupport.intParallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); for (int t : ss.toArray()) b.accept(t); }
--- a/test-ng/bootlib/java/util/stream/LongStreamTestData.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/LongStreamTestData.java Thu Apr 11 20:37:23 2013 -0400 @@ -103,12 +103,12 @@ @Override public LongStream stream() { - return Streams.longStream(i.spliterator()); + return StreamSupport.longStream(i.spliterator()); } @Override public LongStream parallelStream() { - return Streams.longParallelStream(i.spliterator()); + return StreamSupport.longParallelStream(i.spliterator()); } @Override @@ -173,12 +173,12 @@ @Override public LongStream stream() { - return Streams.longStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); + return StreamSupport.longStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); } @Override public LongStream parallelStream() { - return Streams.longParallelStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); + return StreamSupport.longParallelStream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED); } @Override
--- a/test-ng/bootlib/java/util/stream/LongStreamTestScenario.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/LongStreamTestScenario.java Thu Apr 11 20:37:23 2013 -0400 @@ -114,7 +114,7 @@ <T, S_IN extends BaseStream<T, S_IN>> void _run(OpTestCase.TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) { LongStream s = m.apply(data.parallelStream()); Spliterator.OfLong sp = s.spliterator(); - LongStream ss = Streams.longParallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); + LongStream ss = StreamSupport.longParallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); for (long t : ss.toArray()) b.accept(t); }
--- a/test-ng/bootlib/java/util/stream/StreamTestData.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/StreamTestData.java Thu Apr 11 20:37:23 2013 -0400 @@ -122,12 +122,12 @@ @Override public Stream<T> stream() { - return Streams.stream(buffer.spliterator()); + return StreamSupport.stream(buffer.spliterator()); } @Override public Stream<T> parallelStream() { - return Streams.parallelStream(buffer.spliterator()); + return StreamSupport.parallelStream(buffer.spliterator()); } @Override @@ -192,12 +192,12 @@ @Override public Stream<T> stream() { - return Streams.stream(() -> node.spliterator(), Spliterator.SIZED | Spliterator.ORDERED); + return StreamSupport.stream(() -> node.spliterator(), Spliterator.SIZED | Spliterator.ORDERED); } @Override public Stream<T> parallelStream() { - return Streams.parallelStream(() -> node.spliterator(), Spliterator.SIZED | Spliterator.ORDERED); + return StreamSupport.parallelStream(() -> node.spliterator(), Spliterator.SIZED | Spliterator.ORDERED); } @Override
--- a/test-ng/bootlib/java/util/stream/StreamTestScenario.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/bootlib/java/util/stream/StreamTestScenario.java Thu Apr 11 20:37:23 2013 -0400 @@ -124,7 +124,7 @@ <T, U, S_IN extends BaseStream<T, S_IN>> void _run(OpTestCase.TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) { Stream<U> s = m.apply(data.parallelStream()); Spliterator<U> sp = s.spliterator(); - Stream<U> ss = Streams.parallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); + Stream<U> ss = StreamSupport.parallelStream(() -> sp, StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s)) | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED)); for (Object t : ss.toArray()) b.accept((U) t); }
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/DistinctOpTest.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/tests/org/openjdk/tests/java/util/stream/DistinctOpTest.java Thu Apr 11 20:37:23 2013 -0400 @@ -27,17 +27,11 @@ import org.testng.annotations.Test; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Comparator; -import java.util.Comparators; -import java.util.HashSet; import java.util.List; -import java.util.SortedSet; import java.util.Spliterator; import java.util.Spliterators; -import java.util.TreeSet; -import java.util.function.Consumer; import java.util.stream.*; import static java.util.stream.LambdaTestHelpers.*; @@ -112,7 +106,7 @@ @Override public Stream<T> stream() { - return Streams.stream(spliterator()); + return StreamSupport.stream(spliterator()); } @Override
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/SortedOpTest.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/tests/org/openjdk/tests/java/util/stream/SortedOpTest.java Thu Apr 11 20:37:23 2013 -0400 @@ -80,7 +80,7 @@ } private <T> Stream<T> unknownSizeStream(List<T> l) { - return Streams.stream(Spliterators.spliteratorUnknownSize(l.iterator(), 0)); + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(l.iterator(), 0)); } @Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) @@ -152,7 +152,7 @@ } private IntStream unknownSizeIntStream(int[] a) { - return Streams.intStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); + return StreamSupport.intStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); } @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) @@ -195,7 +195,7 @@ } private LongStream unknownSizeLongStream(long[] a) { - return Streams.longStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); + return StreamSupport.longStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); } @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) @@ -238,7 +238,7 @@ } private DoubleStream unknownSizeDoubleStream(double[] a) { - return Streams.doubleStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); + return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize(Spliterators.iteratorFromSpliterator(Arrays.spliterator(a)), 0)); } @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java Thu Apr 11 20:37:23 2013 -0400 @@ -41,13 +41,13 @@ import java.util.stream.IntStream; import java.util.stream.IntStreamTestData; import java.util.stream.IntStreamTestDataProvider; -import java.util.stream.LambdaTestHelpers; import java.util.stream.LongStream; import java.util.stream.LongStreamTestData; import java.util.stream.LongStreamTestDataProvider; import java.util.stream.OpTestCase; import java.util.stream.SpliteratorTestHelper; import java.util.stream.Stream; +import java.util.stream.StreamSupport; import java.util.stream.StreamTestData; import java.util.stream.StreamTestDataProvider; import java.util.stream.Streams; @@ -55,7 +55,6 @@ import org.testng.Assert; import org.testng.annotations.Test; -import static java.util.stream.LambdaTestHelpers.cInteger; import static java.util.stream.LambdaTestHelpers.countTo; import static java.util.stream.LambdaTestHelpers.dpEven; import static java.util.stream.LambdaTestHelpers.ipEven; @@ -267,7 +266,7 @@ for (boolean proxyEstimateSize : new boolean[]{false, true}) { Spliterator<Integer> sp = intermediateOp.apply(l.stream()).spliterator(); ProxyNoExactSizeSpliterator<Integer> psp = new ProxyNoExactSizeSpliterator<>(sp, proxyEstimateSize); - Stream<Integer> s = Streams.parallelStream(psp); + Stream<Integer> s = StreamSupport.parallelStream(psp); terminalOp.accept(s); Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize)); @@ -288,14 +287,14 @@ withData(data). stream((Stream<Integer> in) -> { Stream<Integer> out = f.apply(in); - return Streams.stream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.stream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); withData(data). stream((Stream<Integer> in) -> { Stream<Integer> out = f.apply(in); - return Streams.parallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.parallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); } @@ -355,7 +354,7 @@ // @@@ Need way to obtain the target size Spliterator.OfInt sp = intermediateOp.apply(Streams.intRange(0, 1000)).spliterator(); ProxyNoExactSizeSpliterator.OfInt psp = new ProxyNoExactSizeSpliterator.OfInt(sp, proxyEstimateSize); - IntStream s = Streams.intParallelStream(psp); + IntStream s = StreamSupport.intParallelStream(psp); terminalOp.accept(s); Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize)); @@ -376,14 +375,14 @@ withData(data). stream(in -> { IntStream out = f.apply(in); - return Streams.intStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.intStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); withData(data). stream((in) -> { IntStream out = f.apply(in); - return Streams.intParallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.intParallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); } @@ -440,7 +439,7 @@ // @@@ Need way to obtain the target size Spliterator.OfLong sp = intermediateOp.apply(Streams.longRange(0, 1000)).spliterator(); ProxyNoExactSizeSpliterator.OfLong psp = new ProxyNoExactSizeSpliterator.OfLong(sp, proxyEstimateSize); - LongStream s = Streams.longParallelStream(psp); + LongStream s = StreamSupport.longParallelStream(psp); terminalOp.accept(s); Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize)); @@ -461,14 +460,14 @@ withData(data). stream(in -> { LongStream out = f.apply(in); - return Streams.longStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.longStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); withData(data). stream((in) -> { LongStream out = f.apply(in); - return Streams.longParallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.longParallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); } @@ -525,7 +524,7 @@ // @@@ Need way to obtain the target size Spliterator.OfDouble sp = intermediateOp.apply(Streams.doubleRange(0, 1000)).spliterator(); ProxyNoExactSizeSpliterator.OfDouble psp = new ProxyNoExactSizeSpliterator.OfDouble(sp, proxyEstimateSize); - DoubleStream s = Streams.doubleParallelStream(psp); + DoubleStream s = StreamSupport.doubleParallelStream(psp); terminalOp.accept(s); Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize)); @@ -546,14 +545,14 @@ withData(data). stream(in -> { DoubleStream out = f.apply(in); - return Streams.doubleStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.doubleStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); withData(data). stream((in) -> { DoubleStream out = f.apply(in); - return Streams.doubleParallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); + return StreamSupport.doubleParallelStream(() -> out.spliterator(), OpTestCase.getStreamFlags(out)); }). exercise(); }
--- a/test/java/util/stream/Stream/IntStreamTest.java Thu Apr 11 12:54:30 2013 -0700 +++ b/test/java/util/stream/Stream/IntStreamTest.java Thu Apr 11 20:37:23 2013 -0400 @@ -33,12 +33,12 @@ import java.util.*; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; import java.util.function.BiFunction; import java.util.function.IntFunction; import java.util.function.IntPredicate; import java.util.stream.IntStream; import java.util.stream.Stream; +import java.util.stream.StreamSupport; import java.util.stream.Streams; import static org.testng.Assert.*; import org.testng.annotations.Test; @@ -479,7 +479,7 @@ IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array) : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() : Arrays.stream(array); - int[] calArr = Streams.intStream(stream.spliterator()).toArray(); + int[] calArr = StreamSupport.intStream(stream.spliterator()).toArray(); for(int index = 0; index < array.length; index++) assertEquals(array[index], calArr[index]); }