@Override public Stream<T> build() { int c = count; if (c >= 0) { // Switch count to negative value signalling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.stream(this, false) : StreamSupport.stream(buffer.spliterator(), false); } throw new IllegalStateException(); }
@Override public DoubleStream build() { int c = count; if (c >= 0) { // Switch count to negative value signalling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.doubleStream(this, false) : StreamSupport.doubleStream(buffer.spliterator(), false); } throw new IllegalStateException(); }
@Override public IntStream build() { int c = count; if (c >= 0) { // Switch count to negative value signalling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.intStream(this, false) : StreamSupport.intStream(buffer.spliterator(), false); } throw new IllegalStateException(); }
return StreamSupport.stream( new WhileOps.UnorderedWhileSpliterator.OfRef.Dropping<>(s.spliterator(), true, predicate), s.isParallel()).onClose(StreamSupport.closeHandler(s));
@Override public LongStream build() { int c = count; if (c >= 0) { // Switch count to negative value signaling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.longStream(this, false) : StreamSupport.longStream(buffer.spliterator(), false); } throw new IllegalStateException(); }
/** * 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 IntStream dropWhile(IntStream stream, IntPredicate 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.intStream( new WhileOps.UnorderedWhileSpliterator.OfInt.Dropping(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 LongStream dropWhile(LongStream stream, LongPredicate 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.longStream( new WhileOps.UnorderedWhileSpliterator.OfLong.Dropping(stream.spliterator(), true, predicate), stream.isParallel()).onClose(StreamSupport.closeHandler(stream)); }
return StreamSupport.stream( new WhileOps.UnorderedWhileSpliterator.OfRef.Taking<>(s.spliterator(), true, predicate), s.isParallel()).onClose(StreamSupport.closeHandler(s));
@Override public LongStream build() { int c = count; if (c >= 0) { // Switch count to negative value signaling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.longStream(this, false) : StreamSupport.longStream(buffer.spliterator(), false); } throw new IllegalStateException(); }
/** * 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 IntStream takeWhile(IntStream stream, IntPredicate 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.intStream( new WhileOps.UnorderedWhileSpliterator.OfInt.Taking(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 LongStream takeWhile(LongStream stream, LongPredicate 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.longStream( new WhileOps.UnorderedWhileSpliterator.OfLong.Taking(stream.spliterator(), true, predicate), stream.isParallel()).onClose(StreamSupport.closeHandler(stream)); }
@Override public Stream<T> build() { int c = count; if (c >= 0) { // Switch count to negative value signalling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.stream(this, false) : StreamSupport.stream(buffer.spliterator(), false); } throw new IllegalStateException(); }
return StreamSupport.stream( new WhileOps.UnorderedWhileSpliterator.OfRef.Dropping<>(s.spliterator(), true, predicate), s.isParallel()).onClose(StreamSupport.closeHandler(s));
/** * Returns an empty sequential {@code LongStream}. * * @return an empty sequential stream */ public static LongStream empty() { return StreamSupport.longStream(Spliterators.emptyLongSpliterator(), false); }
@Override public IntStream build() { int c = count; if (c >= 0) { // Switch count to negative value signalling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.intStream(this, false) : StreamSupport.intStream(buffer.spliterator(), false); } throw new IllegalStateException(); }
@Override public DoubleStream build() { int c = count; if (c >= 0) { // Switch count to negative value signalling the builder is built count = -count - 1; // Use this spliterator if 0 or 1 elements, otherwise use // the spliterator of the spined buffer return (c < 2) ? StreamSupport.doubleStream(this, false) : StreamSupport.doubleStream(buffer.spliterator(), false); } throw new IllegalStateException(); }
/** * 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 IntStream takeWhile(IntStream stream, IntPredicate 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.intStream( new WhileOps.UnorderedWhileSpliterator.OfInt.Taking(stream.spliterator(), true, predicate), stream.isParallel()).onClose(StreamSupport.closeHandler(stream)); }