@Override public OfDouble iterator() { return Spliterators.iterator(spliterator()); }
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 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)); }
/** * 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)); }
return delegate(new PrefixOps.OfDouble(spliterator(), op));
@Override public void forEachOrdered(DoubleConsumer action) { if (spliterator != null && !isParallel()) { spliterator().forEachRemaining(action); } else { if (context.fjp != null) context.terminate(() -> { stream().forEachOrdered(action); return null; }); else { stream().forEachOrdered(action); } } }
@Override public void forEach(DoubleConsumer action) { if (spliterator != null && !isParallel()) { spliterator().forEachRemaining(action); } else { if (context.fjp != null) context.terminate(() -> { stream().forEach(action); return null; }); else { stream().forEach(action); } } }
Spliterator.OfDouble spliterator = (isParallel() ? StreamSupport.doubleStream(spliterator(), false) : stream()) .skip(n).spliterator(); return delegate(spliterator);
Spliterator.OfDouble spliterator = spliterator(); double size = spliterator.getExactSizeIfKnown(); DoubleBuffer buf = new DoubleBuffer(size >= 0 && size <= Integer.MAX_VALUE ? (int) size : INITIAL_SIZE);
/** * Returns a {@code float[]} array containing the elements of this stream * which are converted to floats using {@code (float)} cast operation. * * <p> * This is a terminal operation. * * @return an array containing the elements of this stream * @since 0.3.0 */ public float[] toFloatArray() { if (isParallel()) return collect(DoubleCollector.toFloatArray()); java.util.Spliterator.OfDouble spliterator = spliterator(); long size = spliterator.getExactSizeIfKnown(); FloatBuffer buf; if (size >= 0 && size <= Integer.MAX_VALUE) { buf = new FloatBuffer((int) size); spliterator.forEachRemaining((DoubleConsumer) buf::addUnsafe); } else { buf = new FloatBuffer(); spliterator.forEachRemaining((DoubleConsumer) buf::add); } return buf.toArray(); }