Java Code Examples for java.util.Spliterator#OfLong
The following examples show how to use
java.util.Spliterator#OfLong .
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: Node.java From JDKSourceCode1.8 with MIT License | 5 votes |
@Override default Node.OfLong truncate(long from, long to, IntFunction<Long[]> generator) { if (from == 0 && to == count()) return this; long size = to - from; Spliterator.OfLong spliterator = spliterator(); Node.Builder.OfLong nodeBuilder = Nodes.longBuilder(size); nodeBuilder.begin(size); for (int i = 0; i < from && spliterator.tryAdvance((LongConsumer) e -> { }); i++) { } for (int i = 0; (i < size) && spliterator.tryAdvance((LongConsumer) nodeBuilder); i++) { } nodeBuilder.end(); return nodeBuilder.build(); }
Example 2
Source File: TestData.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected LongTestData(String name, I state, Function<I, LongStream> streamFn, Function<I, LongStream> parStreamFn, Function<I, Spliterator.OfLong> splitrFn, ToIntFunction<I> sizeFn) { super(name, StreamShape.LONG_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn); }
Example 3
Source File: LongPipeline.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Adapt a {@code Spliterator<Long>} to a {@code Spliterator.OfLong}. * * @implNote * The implementation attempts to cast to a Spliterator.OfLong, and throws * an exception if this cast is not possible. */ private static Spliterator.OfLong adapt(Spliterator<Long> s) { if (s instanceof Spliterator.OfLong) { return (Spliterator.OfLong) s; } else { if (Tripwire.ENABLED) Tripwire.trip(AbstractPipeline.class, "using LongStream.adapt(Spliterator<Long> s)"); throw new UnsupportedOperationException("LongStream.adapt(Spliterator<Long> s)"); } }
Example 4
Source File: Nodes.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfLong spliterator() { return Arrays.spliterator(array, 0, curSize); }
Example 5
Source File: SpliteratorTraversingAndSplittingTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
void add(String description, List<Long> expected, Supplier<Spliterator.OfLong> s) { description = joiner(description).toString(); data.add(new Object[]{description, expected, s}); }
Example 6
Source File: Nodes.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfLong spliterator() { assert !building : "during building"; return super.spliterator(); }
Example 7
Source File: StreamSpliterators.java From desugar_jdk_libs with GNU General Public License v2.0 | 4 votes |
@Override protected Spliterator.OfLong makeSpliterator(Spliterator.OfLong s, long sliceOrigin, long sliceFence, long origin, long fence) { return new SliceSpliterator.OfLong(s, sliceOrigin, sliceFence, origin, fence); }
Example 8
Source File: Nodes.java From desugar_jdk_libs with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfLong spliterator() { return DesugarArrays.spliterator(array, 0, curSize); }
Example 9
Source File: StreamSpliterators.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfLong trySplit() { if (estimate == 0) return null; return new InfiniteSupplyingSpliterator.OfLong(estimate = estimate >>> 1, s); }
Example 10
Source File: LongPipeline.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") final Spliterator.OfLong lazySpliterator(Supplier<? extends Spliterator<Long>> supplier) { return new StreamSpliterators.DelegatingSpliterator.OfLong((Supplier<Spliterator.OfLong>) supplier); }
Example 11
Source File: StreamSpliterators.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
OfLong(Spliterator.OfLong s, long skip, long limit) { super(s, skip, limit); }
Example 12
Source File: SpliteratorTestHelper.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier) { testLongSpliterator(supplier, defaultContentAsserter()); }
Example 13
Source File: StreamSpliteratorTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public void forEachRemaining(Consumer<? super Long> consumer) { Spliterator.OfLong.super.forEachRemaining(consumer); }
Example 14
Source File: SpliteratorTraversingAndSplittingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "Spliterator.OfLong") public void testLongSplitAfterFullTraversal(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) { testSplitAfterFullTraversal(s, longBoxingConsumer()); }
Example 15
Source File: Nodes.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfLong spliterator() { assert !building : "during building"; return super.spliterator(); }
Example 16
Source File: StreamSpliterators.java From JDKSourceCode1.8 with MIT License | 4 votes |
OfLong(Spliterator.OfLong s, long sliceOrigin, long sliceFence) { super(s, sliceOrigin, sliceFence); }
Example 17
Source File: SpliteratorTraversingAndSplittingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
void add(String description, Supplier<Spliterator.OfLong> s) { add(description, exp, s); }
Example 18
Source File: LongPipeline.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
@Override final void forEachWithCancel(Spliterator<Long> spliterator, Sink<Long> sink) { Spliterator.OfLong spl = adapt(spliterator); LongConsumer adaptedSink = adapt(sink); do { } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink)); }
Example 19
Source File: Nodes.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfLong spliterator() { return new InternalNodeSpliterator.OfLong(this); }
Example 20
Source File: StreamSupport.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Creates a new sequential or parallel {@code LongStream} from a * {@code Spliterator.OfLong}. * * <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 #longStream(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.OfLong} 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 LongStream} */ public static LongStream longStream(Spliterator.OfLong spliterator, boolean parallel) { return new LongPipeline.Head<>(spliterator, StreamOpFlag.fromCharacteristics(spliterator), parallel); }