src/share/classes/java/util/stream/BaseStream.java

Print this page
rev 7619 : 8019551: Make BaseStream public
Reviewed-by:


  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.util.stream;
  26 
  27 import java.util.Iterator;
  28 import java.util.Spliterator;
  29 
  30 /**
  31  * Base interface for stream types such as {@link Stream}, {@link IntStream},
  32  * etc.  Contains methods common to all stream types.  Many of these methods
  33  * are implemented by {@link AbstractPipeline}, even though
  34  * {@code AbstractPipeline} does not directly implement {@code BaseStream}.
  35  *
  36  * @param <T> type of stream elements
  37  * @param <S> type of stream implementing {@code BaseStream}
  38  * @since 1.8
  39  */
  40 interface BaseStream<T, S extends BaseStream<T, S>> {
  41     /**
  42      * Returns an iterator for the elements of this stream.
  43      *
  44      * <p>This is a <a href="package-summary.html#StreamOps">terminal
  45      * operation</a>.
  46      *
  47      * @return the element iterator for this stream
  48      */
  49     Iterator<T> iterator();
  50 
  51     /**
  52      * Returns a spliterator for the elements of this stream.
  53      *
  54      * <p>This is a <a href="package-summary.html#StreamOps">terminal
  55      * operation</a>.
  56      *
  57      * @return the element spliterator for this stream
  58      */
  59     Spliterator<T> spliterator();
  60 




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.util.stream;
  26 
  27 import java.util.Iterator;
  28 import java.util.Spliterator;
  29 
  30 /**
  31  * Base interface for stream types such as {@link Stream}, {@link IntStream},
  32  * etc.  Contains methods common to all stream types.


  33  *
  34  * @param <T> type of stream elements
  35  * @param <S> type of stream implementing {@code BaseStream}
  36  * @since 1.8
  37  */
  38 public interface BaseStream<T, S extends BaseStream<T, S>> {
  39     /**
  40      * Returns an iterator for the elements of this stream.
  41      *
  42      * <p>This is a <a href="package-summary.html#StreamOps">terminal
  43      * operation</a>.
  44      *
  45      * @return the element iterator for this stream
  46      */
  47     Iterator<T> iterator();
  48 
  49     /**
  50      * Returns a spliterator for the elements of this stream.
  51      *
  52      * <p>This is a <a href="package-summary.html#StreamOps">terminal
  53      * operation</a>.
  54      *
  55      * @return the element spliterator for this stream
  56      */
  57     Spliterator<T> spliterator();
  58