DoubleStreamEx callWhile(DoubleStreamEx stream, DoublePredicate predicate, boolean drop) { return stream.delegate(new TakeDrop.TDOfDouble(stream.spliterator(), drop, false, predicate)); }
/** * Returns a stream consisting of all elements from this stream until the * first element which does not match the given predicate is found * (including the first mismatching element). * * <p> * This is a <a href="package-summary.html#StreamOps">quasi-intermediate * operation</a>. * * <p> * While this operation is quite cheap for sequential stream, it can be * quite expensive on parallel pipelines. * * @param predicate a non-interfering, stateless predicate to apply to * elements. * @return the new stream. * @since 0.5.5 * @see #takeWhile(DoublePredicate) */ public DoubleStreamEx takeWhileInclusive(DoublePredicate predicate) { Objects.requireNonNull(predicate); return delegate(new TakeDrop.TDOfDouble(spliterator(), false, true, predicate)); }
/** * Returns a stream where the first element is the replaced with the result * of applying the given function while the other elements are left intact. * * <p> * This is a <a href="package-summary.html#StreamOps">quasi-intermediate * operation</a>. * * @param mapper a * <a href="package-summary.html#NonInterference">non-interfering * </a>, <a href="package-summary.html#Statelessness">stateless</a> * function to apply to the first element * @return the new stream * @since 0.4.1 */ public DoubleStreamEx mapFirst(DoubleUnaryOperator mapper) { return delegate(new PairSpliterator.PSOfDouble((a, b) -> b, mapper, spliterator(), PairSpliterator.MODE_MAP_FIRST)); }
/** * Returns a stream where the last element is the replaced with the result * of applying the given function while the other elements are left intact. * * <p> * This is a <a href="package-summary.html#StreamOps">quasi-intermediate * operation</a>. * * <p> * The mapper function is called at most once. It could be not called at all * if the stream is empty or there is short-circuiting operation downstream. * * @param mapper a * <a href="package-summary.html#NonInterference">non-interfering * </a>, <a href="package-summary.html#Statelessness">stateless</a> * function to apply to the last element * @return the new stream * @since 0.4.1 */ public DoubleStreamEx mapLast(DoubleUnaryOperator mapper) { return delegate(new PairSpliterator.PSOfDouble((a, b) -> a, mapper, spliterator(), PairSpliterator.MODE_MAP_LAST)); }
/** * Returns a stream consisting of the results of applying the given function * to the every adjacent pair of elements of this stream. * * <p> * This is a <a href="package-summary.html#StreamOps">quasi-intermediate * operation</a>. * * <p> * The output stream will contain one element less than this stream. If this * stream contains zero or one element the output stream will be empty. * * @param mapper a non-interfering, stateless function to apply to each * adjacent pair of this stream elements. * @return the new stream * @since 0.2.1 */ public DoubleStreamEx pairMap(DoubleBinaryOperator mapper) { return delegate(new PairSpliterator.PSOfDouble(mapper, null, spliterator(), PairSpliterator.MODE_PAIRS)); }
return delegate(new PrefixOps.OfDouble(spliterator(), op));
Spliterator.OfDouble spliterator = (isParallel() ? StreamSupport.doubleStream(spliterator(), false) : stream()) .skip(n).spliterator(); return delegate(spliterator);
double size = spliterator.getExactSizeIfKnown(); DoubleBuffer buf = new DoubleBuffer(size >= 0 && size <= Integer.MAX_VALUE ? (int) size : INITIAL_SIZE); delegate(spliterator).forEachOrdered(i -> buf.add(buf.size == 0 ? i : accumulator.applyAsDouble(buf.data[buf.size - 1], i))); return buf.toArray();