jdk/src/share/classes/java/util/stream/DoubleStream.java
changeset 18822 4b6be7c19547
parent 18820 a87cdd6a8834
child 18825 06636235cd12
equal deleted inserted replaced
18821:50a3b8a90563 18822:4b6be7c19547
   670      * Returns an empty sequential {@code DoubleStream}.
   670      * Returns an empty sequential {@code DoubleStream}.
   671      *
   671      *
   672      * @return an empty sequential stream
   672      * @return an empty sequential stream
   673      */
   673      */
   674     public static DoubleStream empty() {
   674     public static DoubleStream empty() {
   675         return StreamSupport.doubleStream(Spliterators.emptyDoubleSpliterator());
   675         return StreamSupport.doubleStream(Spliterators.emptyDoubleSpliterator(), false);
   676     }
   676     }
   677 
   677 
   678     /**
   678     /**
   679      * Returns a sequential {@code DoubleStream} containing a single element.
   679      * Returns a sequential {@code DoubleStream} containing a single element.
   680      *
   680      *
   681      * @param t the single element
   681      * @param t the single element
   682      * @return a singleton sequential stream
   682      * @return a singleton sequential stream
   683      */
   683      */
   684     public static DoubleStream of(double t) {
   684     public static DoubleStream of(double t) {
   685         return StreamSupport.doubleStream(new Streams.DoubleStreamBuilderImpl(t));
   685         return StreamSupport.doubleStream(new Streams.DoubleStreamBuilderImpl(t), false);
   686     }
   686     }
   687 
   687 
   688     /**
   688     /**
   689      * Returns a sequential stream whose elements are the specified values.
   689      * Returns a sequential stream whose elements are the specified values.
   690      *
   690      *
   728                 return v;
   728                 return v;
   729             }
   729             }
   730         };
   730         };
   731         return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize(
   731         return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize(
   732                 iterator,
   732                 iterator,
   733                 Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL));
   733                 Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
   734     }
   734     }
   735 
   735 
   736     /**
   736     /**
   737      * Returns a sequential {@code DoubleStream} where each element is
   737      * Returns a sequential {@code DoubleStream} where each element is
   738      * generated by an {@code DoubleSupplier}.  This is suitable for generating
   738      * generated by an {@code DoubleSupplier}.  This is suitable for generating
   742      * @return a new sequential {@code DoubleStream}
   742      * @return a new sequential {@code DoubleStream}
   743      */
   743      */
   744     public static DoubleStream generate(DoubleSupplier s) {
   744     public static DoubleStream generate(DoubleSupplier s) {
   745         Objects.requireNonNull(s);
   745         Objects.requireNonNull(s);
   746         return StreamSupport.doubleStream(
   746         return StreamSupport.doubleStream(
   747                 new StreamSpliterators.InfiniteSupplyingSpliterator.OfDouble(Long.MAX_VALUE, s));
   747                 new StreamSpliterators.InfiniteSupplyingSpliterator.OfDouble(Long.MAX_VALUE, s), false);
   748     }
   748     }
   749 
   749 
   750     /**
   750     /**
   751      * Creates a lazy concatenated {@code DoubleStream} whose elements are all the
   751      * Creates a lazy concatenated {@code DoubleStream} whose elements are all the
   752      * elements of a first {@code DoubleStream} succeeded by all the elements of the
   752      * elements of a first {@code DoubleStream} succeeded by all the elements of the
   762         Objects.requireNonNull(a);
   762         Objects.requireNonNull(a);
   763         Objects.requireNonNull(b);
   763         Objects.requireNonNull(b);
   764 
   764 
   765         Spliterator.OfDouble split = new Streams.ConcatSpliterator.OfDouble(
   765         Spliterator.OfDouble split = new Streams.ConcatSpliterator.OfDouble(
   766                 a.spliterator(), b.spliterator());
   766                 a.spliterator(), b.spliterator());
   767         return (a.isParallel() || b.isParallel())
   767         return StreamSupport.doubleStream(split, a.isParallel() || b.isParallel());
   768                ? StreamSupport.doubleParallelStream(split)
       
   769                : StreamSupport.doubleStream(split);
       
   770     }
   768     }
   771 }
   769 }