Java Code Examples for java.util.Spliterator#OfDouble
The following examples show how to use
java.util.Spliterator#OfDouble .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamSpliteratorTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public Spliterator.OfDouble trySplit() { splits++; Spliterator.OfDouble prefix = psp.trySplit(); if (prefix != null) prefixSplits++; return prefix; }
Example 2
Source File: StreamSpliteratorTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public Spliterator.OfDouble trySplit() { splits++; Spliterator.OfDouble prefix = psp.trySplit(); if (prefix != null) prefixSplits++; return prefix; }
Example 3
Source File: DoublePipeline.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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)"); } }
Example 4
Source File: SpliteratorTraversingAndSplittingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "Spliterator.OfDouble") public void testDoubleSplitSixDeep(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) { testSplitSixDeep(exp, s, doubleBoxingConsumer()); }
Example 5
Source File: Nodes.java From Bytecoder with Apache License 2.0 | 4 votes |
@Override public Spliterator.OfDouble spliterator() { return Arrays.spliterator(array, 0, curSize); }
Example 6
Source File: DoublePipeline.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@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)); }
Example 7
Source File: ReferencePipeline.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@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(); } }; } }; }
Example 8
Source File: Nodes.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfDouble spliterator() { return Arrays.spliterator(array, 0, curSize); }
Example 9
Source File: DoubleStream.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override Spliterator.OfDouble spliterator();
Example 10
Source File: SpliteratorTraversingAndSplittingTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@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)); }
Example 11
Source File: StreamSpliterators.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
OfDouble(Spliterator.OfDouble s, long sliceOrigin, long sliceFence, long origin, long fence) { super(s, sliceOrigin, sliceFence, origin, fence); }
Example 12
Source File: Nodes.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
@Override public Spliterator.OfDouble spliterator() { assert !building : "during building"; return super.spliterator(); }
Example 13
Source File: WhileOps.java From Bytecoder with Apache License 2.0 | 4 votes |
Taking(Spliterator.OfDouble s, boolean noSplitting, DoublePredicate p) { super(s, noSplitting, p); }
Example 14
Source File: DoubleStream.java From desugar_jdk_libs with GNU General Public License v2.0 | 4 votes |
@Override Spliterator.OfDouble spliterator();
Example 15
Source File: StreamSpliterators.java From desugar_jdk_libs with GNU General Public License v2.0 | 4 votes |
@Override protected Spliterator.OfDouble makeSpliterator(Spliterator.OfDouble s) { return new UnorderedSliceSpliterator.OfDouble(s, this); }
Example 16
Source File: WhileOps.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
Dropping(Spliterator.OfDouble s, UnorderedWhileSpliterator.OfDouble parent) { super(s, parent); }
Example 17
Source File: SpliteratorTraversingAndSplittingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "Spliterator.OfDouble") public void testDoubleSplitOnce(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) { testSplitOnce(exp, s, doubleBoxingConsumer()); }
Example 18
Source File: StreamSpliterators.java From JDKSourceCode1.8 with MIT License | 4 votes |
OfDouble(Spliterator.OfDouble s, long sliceOrigin, long sliceFence, long origin, long fence) { super(s, sliceOrigin, sliceFence, origin, fence); }
Example 19
Source File: DoubleStream.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * 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)); }
Example 20
Source File: StreamSupport.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 3 votes |
/** * 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); }