java.util.Spliterator# OfDouble ( ) 源码实例Demo

下面列出了java.util.Spliterator# OfDouble ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk9   文件: StreamSpliteratorTest.java
@Override
public Spliterator.OfDouble trySplit() {
    splits++;
    Spliterator.OfDouble prefix = psp.trySplit();
    if (prefix != null)
        prefixSplits++;
    return prefix;
}
 
源代码2 项目: jdk8u60   文件: StreamSpliteratorTest.java
@Override
public Spliterator.OfDouble trySplit() {
    splits++;
    Spliterator.OfDouble prefix = psp.trySplit();
    if (prefix != null)
        prefixSplits++;
    return prefix;
}
 
源代码3 项目: jdk8u60   文件: DoublePipeline.java
/**
 * Adapt a {@code Spliterator<Double>} to a {@code Spliterator.OfDouble}.
 *
 * @implNote
 * The implementation attempts to cast to a Spliterator.OfDouble, and throws
 * an exception if this cast is not possible.
 */
private static Spliterator.OfDouble adapt(Spliterator<Double> s) {
    if (s instanceof Spliterator.OfDouble) {
        return (Spliterator.OfDouble) s;
    } else {
        if (Tripwire.ENABLED)
            Tripwire.trip(AbstractPipeline.class,
                          "using DoubleStream.adapt(Spliterator<Double> s)");
        throw new UnsupportedOperationException("DoubleStream.adapt(Spliterator<Double> s)");
    }
}
 
源代码4 项目: JDKSourceCode1.8   文件: StreamSpliterators.java
OfDouble(Spliterator.OfDouble s,
         long sliceOrigin, long sliceFence, long origin, long fence) {
    super(s, sliceOrigin, sliceFence, origin, fence);
}
 
@Test(dataProvider = "Spliterator.OfDouble")
public void testDoubleSplitOnce(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
    testSplitOnce(exp, s, doubleBoxingConsumer());
}
 
源代码6 项目: openjdk-jdk9   文件: WhileOps.java
Dropping(Spliterator.OfDouble s, UnorderedWhileSpliterator.OfDouble parent) {
    super(s, parent);
}
 
源代码7 项目: desugar_jdk_libs   文件: StreamSpliterators.java
@Override
protected Spliterator.OfDouble makeSpliterator(Spliterator.OfDouble s) {
    return new UnorderedSliceSpliterator.OfDouble(s, this);
}
 
源代码8 项目: desugar_jdk_libs   文件: DoubleStream.java
@Override
Spliterator.OfDouble spliterator();
 
源代码9 项目: Bytecoder   文件: WhileOps.java
Taking(Spliterator.OfDouble s, boolean noSplitting, DoublePredicate p) {
    super(s, noSplitting, p);
}
 
源代码10 项目: jdk1.8-source-analysis   文件: Nodes.java
@Override
public Spliterator.OfDouble spliterator() {
    assert !building : "during building";
    return super.spliterator();
}
 
源代码11 项目: dragonwell8_jdk   文件: StreamSpliterators.java
OfDouble(Spliterator.OfDouble s,
         long sliceOrigin, long sliceFence, long origin, long fence) {
    super(s, sliceOrigin, sliceFence, origin, fence);
}
 
@Test(dataProvider = "Spliterator.OfDouble")
public void testDoubleNullPointerException(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
    executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((DoubleConsumer) null));
    executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((DoubleConsumer) null));
}
 
源代码13 项目: jdk8u-jdk   文件: DoubleStream.java
@Override
Spliterator.OfDouble spliterator();
 
源代码14 项目: dragonwell8_jdk   文件: Nodes.java
@Override
public Spliterator.OfDouble spliterator() {
    return Arrays.spliterator(array, 0, curSize);
}
 
源代码15 项目: TencentKona-8   文件: ReferencePipeline.java
@Override
public final DoubleStream flatMapToDouble(Function<? super P_OUT, ? extends DoubleStream> mapper) {
    Objects.requireNonNull(mapper);
    return new DoublePipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) {
            return new Sink.ChainedReference<P_OUT, Double>(sink) {
                // true if cancellationRequested() has been called
                boolean cancellationRequestedCalled;

                // cache the consumer to avoid creation on every accepted element
                DoubleConsumer downstreamAsDouble = downstream::accept;

                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(P_OUT u) {
                    try (DoubleStream result = mapper.apply(u)) {
                        if (result != null) {
                            if (!cancellationRequestedCalled) {
                                result.sequential().forEach(downstreamAsDouble);
                            }
                            else {
                                Spliterator.OfDouble s = result.sequential().spliterator();
                                do { } while (!downstream.cancellationRequested() && s.tryAdvance(downstreamAsDouble));
                            }
                        }
                    }
                }

                @Override
                public boolean cancellationRequested() {
                    cancellationRequestedCalled = true;
                    return downstream.cancellationRequested();
                }
            };
        }
    };
}
 
源代码16 项目: jdk8u-jdk   文件: DoublePipeline.java
@Override
final void forEachWithCancel(Spliterator<Double> spliterator, Sink<Double> sink) {
    Spliterator.OfDouble spl = adapt(spliterator);
    DoubleConsumer adaptedSink = adapt(sink);
    do { } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
 
源代码17 项目: Bytecoder   文件: Nodes.java
@Override
public Spliterator.OfDouble spliterator() {
    return Arrays.spliterator(array, 0, curSize);
}
 
@Test(dataProvider = "Spliterator.OfDouble")
public void testDoubleSplitSixDeep(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
    testSplitSixDeep(exp, s, doubleBoxingConsumer());
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: StreamSupport.java
/**
 * Creates a new sequential or parallel {@code DoubleStream} from a
 * {@code Spliterator.OfDouble}.
 *
 * <p>The spliterator is only traversed, split, or queried for estimated size
 * after the terminal operation of the stream pipeline commences.
 *
 * <p>It is strongly recommended the spliterator report a characteristic of
 * {@code IMMUTABLE} or {@code CONCURRENT}, or be
 * <a href="../Spliterator.html#binding">late-binding</a>.  Otherwise,
 * {@link #doubleStream(java.util.function.Supplier, int, boolean)} should
 * be used to reduce the scope of potential interference with the source.  See
 * <a href="package-summary.html#NonInterference">Non-Interference</a> for
 * more details.
 *
 * @param spliterator A {@code Spliterator.OfDouble} describing the stream elements
 * @param parallel if {@code true} then the returned stream is a parallel
 *        stream; if {@code false} the returned stream is a sequential
 *        stream.
 * @return a new sequential or parallel {@code DoubleStream}
 */
public static DoubleStream doubleStream(Spliterator.OfDouble spliterator,
                                        boolean parallel) {
    return new DoublePipeline.Head<>(spliterator,
                                     StreamOpFlag.fromCharacteristics(spliterator),
                                     parallel);
}
 
源代码20 项目: openjdk-jdk9   文件: DoubleStream.java
/**
 * Creates a lazily concatenated stream whose elements are all the
 * elements of the first stream followed by all the elements of the
 * second 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.
 *
 * @implNote
 * Use caution when constructing streams from repeated concatenation.
 * Accessing an element of a deeply concatenated stream can result in deep
 * call chains, or even {@code StackOverflowError}.
 *
 * @param a the first stream
 * @param b the second stream
 * @return the concatenation of the two input streams
 */
public static DoubleStream concat(DoubleStream a, DoubleStream b) {
    Objects.requireNonNull(a);
    Objects.requireNonNull(b);

    Spliterator.OfDouble split = new Streams.ConcatSpliterator.OfDouble(
            a.spliterator(), b.spliterator());
    DoubleStream stream = StreamSupport.doubleStream(split, a.isParallel() || b.isParallel());
    return stream.onClose(Streams.composedClose(a, b));
}