--- /dev/null 2013-03-09 17:25:01.184291984 -0500 +++ new/src/share/classes/java/util/stream/BaseStream.java 2013-03-11 17:43:59.000000000 -0400 @@ -0,0 +1,90 @@ +/* + * 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.Iterator; +import java.util.Spliterator; + +/** + * Base interface for stream types such as {@link Stream}, {@link IntStream}, + * etc. Contains methods common to all stream types. + * + * @param Type of stream elements. + * @since 1.8 + */ +interface BaseStream> { + /** + * Returns an iterator for the elements of this stream. This is + * a terminal operation. + * + * @return the element iterator for this stream + */ + Iterator iterator(); + + /** + * Returns a spliterator for the elements of this stream. This is + * a terminal operation. + * + * @return the element spliterator for this stream + */ + Spliterator spliterator(); + + /** + * Returns whether this stream, when executed, will execute in parallel + * + * @return whether this stream will execute in parallel + */ + boolean isParallel(); + + /** + * Returns the composition of stream flags of the stream source and all + * intermediate operations. + * + * @return the composition of stream flags of the stream source and all + * intermediate operations + * @see StreamOpFlag + */ + int getStreamFlags(); + + /** + * Produces a stream which has the same contents as this stream, but is a + * sequential stream. If this stream is already sequential, may return + * itself. This is a + * stateful intermediate operation. + * + * @return a sequential stream + */ + S sequential(); + + /** + * Produces a stream which has the same contents as this stream, but is a + * parallel stream. If this stream is already parallel, may return itself. + * This is a + * stateful intermediate operation. + * + * @return a parallel stream + */ + S parallel(); +}