a.spliterator(), b.spliterator()); DoubleStream stream = StreamSupport.doubleStream(split, a.isParallel() || b.isParallel()); return stream.onClose(Streams.composedClose(a, b));
a.spliterator(), b.spliterator()); DoubleStream stream = StreamSupport.doubleStream(split, a.isParallel() || b.isParallel()); return stream.onClose(Streams.composedClose(a, b));
/** * Returns a stream consisting of the remaining elements of the passed * stream after discarding elements that match the given predicate up to, * but not discarding, the first element encountered that does not match the * predicate. All subsequently encountered elements are not discarded. * * <p>This is a <a href="package-summary.html#StreamOps">stateful * intermediate operation</a>. * * @param stream the stream to wrap for the {@code dropWhile()} operation * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * predicate to apply to each element to determine if it * should be discarded, or it and all subsequently * encountered elements be included. * @return the new stream * @since 9 */ public static DoubleStream dropWhile(DoubleStream stream, DoublePredicate predicate) { Objects.requireNonNull(stream); Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split return StreamSupport.doubleStream( new WhileOps.UnorderedWhileSpliterator.OfDouble.Dropping(stream.spliterator(), true, predicate), stream.isParallel()).onClose(StreamSupport.closeHandler(stream)); }
/** * Returns a stream consisting of elements of the passed stream that match * the given predicate up to, but discarding, the first element encountered * that does not match the predicate. All subsequently encountered elements * are discarded. * * <p>This is a <a href="package-summary.html#StreamOps">short-circuiting * stateful intermediate operation</a>. * * @param stream the stream to wrap for the {@code takeWhile()} operation * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * predicate to apply to each element to determine if it * should be included, or it and all subsequently * encountered elements be discarded. * @return the new stream * @since 9 */ public static DoubleStream takeWhile(DoubleStream stream, DoublePredicate predicate) { Objects.requireNonNull(stream); Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split return StreamSupport.doubleStream( new WhileOps.UnorderedWhileSpliterator.OfDouble.Taking(stream.spliterator(), true, predicate), stream.isParallel()).onClose(StreamSupport.closeHandler(stream)); }
/** * Returns a stream consisting of the remaining elements of the passed * stream after discarding elements that match the given predicate up to, * but not discarding, the first element encountered that does not match the * predicate. All subsequently encountered elements are not discarded. * * <p>This is a <a href="package-summary.html#StreamOps">stateful * intermediate operation</a>. * * @param stream the stream to wrap for the {@code dropWhile()} operation * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * predicate to apply to each element to determine if it * should be discarded, or it and all subsequently * encountered elements be included. * @return the new stream * @since 9 */ public static DoubleStream dropWhile(DoubleStream stream, DoublePredicate predicate) { Objects.requireNonNull(stream); Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split return StreamSupport.doubleStream( new WhileOps.UnorderedWhileSpliterator.OfDouble.Dropping(stream.spliterator(), true, predicate), stream.isParallel()).onClose(StreamSupport.closeHandler(stream)); }
/** * Returns a stream consisting of elements of the passed stream that match * the given predicate up to, but discarding, the first element encountered * that does not match the predicate. All subsequently encountered elements * are discarded. * * <p>This is a <a href="package-summary.html#StreamOps">short-circuiting * stateful intermediate operation</a>. * * @param stream the stream to wrap for the {@code takeWhile()} operation * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>, * predicate to apply to each element to determine if it * should be included, or it and all subsequently * encountered elements be discarded. * @return the new stream * @since 9 */ public static DoubleStream takeWhile(DoubleStream stream, DoublePredicate predicate) { Objects.requireNonNull(stream); Objects.requireNonNull(predicate); // Reuses the unordered spliterator, which, when encounter is present, // is safe to use as long as it configured not to split return StreamSupport.doubleStream( new WhileOps.UnorderedWhileSpliterator.OfDouble.Taking(stream.spliterator(), true, predicate), stream.isParallel()).onClose(StreamSupport.closeHandler(stream)); }