< prev index next >

jdk/src/java.base/share/classes/java/util/stream/Stream.java

Print this page

        

*** 531,541 **** * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream ! * @since 1.9 */ default Stream<T> takeWhile(Predicate<? super T> predicate) { Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split --- 531,541 ---- * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream ! * @since 9 */ default Stream<T> takeWhile(Predicate<? super T> predicate) { Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split
*** 597,607 **** * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream ! * @since 1.9 */ default Stream<T> dropWhile(Predicate<? super T> predicate) { Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split --- 597,607 ---- * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream ! * @since 9 */ default Stream<T> dropWhile(Predicate<? super T> predicate) { Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split
*** 1144,1154 **** * * @param t the single element * @param <T> the type of stream elements * @return a stream with a single element if the specified element * is non-null, otherwise an empty stream ! * @since 1.9 */ public static<T> Stream<T> ofNullable(T t) { return t == null ? Stream.empty() : StreamSupport.stream(new Streams.StreamBuilderImpl<>(t), false); } --- 1144,1154 ---- * * @param t the single element * @param <T> the type of stream elements * @return a stream with a single element if the specified element * is non-null, otherwise an empty stream ! * @since 9 */ public static<T> Stream<T> ofNullable(T t) { return t == null ? Stream.empty() : StreamSupport.stream(new Streams.StreamBuilderImpl<>(t), false); }
< prev index next >