/* * 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> { /** * Return an iterator for the elements of this stream. This is * a terminal operation. * * @return the element iterator for this stream */ Iterator iterator(); /** * Return 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(); /** * Return 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(); /** * Produce 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(); /** * Produce 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(); }