/** * Returns a sequential {@link DoubleStreamEx} created from given * {@link java.util.Spliterator.OfDouble}. * * @param spliterator a spliterator to create the stream from. * @return the new stream * @since 0.3.4 */ public static DoubleStreamEx of(Spliterator.OfDouble spliterator) { return new DoubleStreamEx(spliterator, StreamContext.SEQUENTIAL); }
final DoubleStreamEx delegate(Spliterator.OfDouble spliterator) { return new DoubleStreamEx(spliterator, context); }
private static DoubleStreamEx seq(DoubleStream stream) { return new DoubleStreamEx(stream, StreamContext.SEQUENTIAL); }
@Override public DoubleStreamEx mapToDouble(ToDoubleFunction<? super T> mapper) { return new DoubleStreamEx(stream().mapToDouble(mapper), context); }
@Override final DoubleStreamEx callWhile(DoubleStreamEx stream, DoublePredicate predicate, boolean drop) { try { return new DoubleStreamEx((DoubleStream) JDK9_METHODS[IDX_DOUBLE_STREAM][drop ? IDX_DROP_WHILE : IDX_TAKE_WHILE] .invokeExact(stream.stream(), predicate), stream.context); } catch (Error | RuntimeException e) { throw e; } catch (Throwable e) { throw new InternalError(e); } }
@Override public DoubleStreamEx peek(DoubleConsumer action) { return new DoubleStreamEx(stream().peek(action), context); }
@Override public DoubleStreamEx distinct() { return new DoubleStreamEx(stream().distinct(), context); }
@Override public DoubleStreamEx limit(long maxSize) { return new DoubleStreamEx(stream().limit(maxSize), context); }
@Override public DoubleStreamEx asDoubleStream() { return new DoubleStreamEx(stream().asDoubleStream(), context); }
@Override public DoubleStreamEx asDoubleStream() { return new DoubleStreamEx(stream().asDoubleStream(), context); }
@Override public DoubleStreamEx mapToDouble(LongToDoubleFunction mapper) { return new DoubleStreamEx(stream().mapToDouble(mapper), context); }
@Override public DoubleStreamEx filter(DoublePredicate predicate) { return new DoubleStreamEx(stream().filter(predicate), context); }
@Override public DoubleStreamEx map(DoubleUnaryOperator mapper) { return new DoubleStreamEx(stream().map(mapper), context); }
@Override public DoubleStreamEx flatMap(DoubleFunction<? extends DoubleStream> mapper) { return new DoubleStreamEx(stream().flatMap(mapper), context); }
@Override public DoubleStreamEx skip(long n) { return new DoubleStreamEx(stream().skip(n), context); }
@Override public DoubleStreamEx mapToDouble(IntToDoubleFunction mapper) { return new DoubleStreamEx(stream().mapToDouble(mapper), context); }
@Override public DoubleStreamEx flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) { return new DoubleStreamEx(stream().flatMapToDouble(mapper), context); }
@Override public DoubleStreamEx sorted() { return new DoubleStreamEx(stream().sorted(), context); }
/** * Creates a lazily concatenated stream whose elements are all the elements * of the other stream followed by all the elements of this stream. The * resulting stream is ordered if both of the input streams are ordered, and * parallel if either of the input streams is parallel. When the resulting * stream is closed, the close handlers for both input streams are invoked. * * @param other the other stream * @return this stream prepended by the other stream * @see DoubleStream#concat(DoubleStream, DoubleStream) */ public DoubleStreamEx prepend(DoubleStream other) { return new DoubleStreamEx(DoubleStream.concat(other, stream()), context.combine(other)); }
/** * Creates a lazily concatenated stream whose elements are all the elements * of this stream followed by all the elements of the other stream. The * resulting stream is ordered if both of the input streams are ordered, and * parallel if either of the input streams is parallel. When the resulting * stream is closed, the close handlers for both input streams are invoked. * * @param other the other stream * @return this stream appended by the other stream * @see DoubleStream#concat(DoubleStream, DoubleStream) */ public DoubleStreamEx append(DoubleStream other) { return new DoubleStreamEx(DoubleStream.concat(stream(), other), context.combine(other)); }