Java Code Examples for java.util.Spliterator#OfInt
The following examples show how to use
java.util.Spliterator#OfInt .
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 openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override default Node.OfInt truncate(long from, long to, IntFunction<Integer[]> generator) { if (from == 0 && to == count()) return this; long size = to - from; Spliterator.OfInt spliterator = spliterator(); Node.Builder.OfInt nodeBuilder = Nodes.intBuilder(size); nodeBuilder.begin(size); for (int i = 0; i < from && spliterator.tryAdvance((IntConsumer) e -> { }); i++) { } if (to == count()) { spliterator.forEachRemaining((IntConsumer) nodeBuilder); } else { for (int i = 0; i < size && spliterator.tryAdvance((IntConsumer) nodeBuilder); i++) { } } nodeBuilder.end(); return nodeBuilder.build(); }
Example 2
Source File: Node.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override default Node.OfInt truncate(long from, long to, IntFunction<Integer[]> generator) { if (from == 0 && to == count()) return this; long size = to - from; Spliterator.OfInt spliterator = spliterator(); Node.Builder.OfInt nodeBuilder = Nodes.intBuilder(size); nodeBuilder.begin(size); for (int i = 0; i < from && spliterator.tryAdvance((IntConsumer) e -> { }); i++) { } for (int i = 0; (i < size) && spliterator.tryAdvance((IntConsumer) nodeBuilder); i++) { } nodeBuilder.end(); return nodeBuilder.build(); }
Example 3
Source File: TestData.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
protected IntTestData(String name, I state, Function<I, IntStream> streamFn, Function<I, IntStream> parStreamFn, Function<I, Spliterator.OfInt> splitrFn, ToIntFunction<I> sizeFn) { super(name, StreamShape.INT_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn); }
Example 4
Source File: SpliteratorTraversingAndSplittingTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "Spliterator.OfInt") public void testIntNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) { executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((IntConsumer) null)); executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((IntConsumer) null)); }
Example 5
Source File: IntPipeline.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") final Spliterator.OfInt lazySpliterator(Supplier<? extends Spliterator<Integer>> supplier) { return new StreamSpliterators.DelegatingSpliterator.OfInt((Supplier<Spliterator.OfInt>) supplier); }
Example 6
Source File: IntStream.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override Spliterator.OfInt spliterator();
Example 7
Source File: SpliteratorTraversingAndSplittingTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
void add(String description, Supplier<Spliterator.OfInt> s) { add(description, exp, s); }
Example 8
Source File: StreamSpliteratorTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private OfInt(Spliterator.OfInt sp, boolean proxyEstimateSize) { super(sp, proxyEstimateSize); this.psp = sp; }
Example 9
Source File: IntPipeline.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override final void forEachWithCancel(Spliterator<Integer> spliterator, Sink<Integer> sink) { Spliterator.OfInt spl = adapt(spliterator); IntConsumer adaptedSink = adapt(sink); do { } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink)); }
Example 10
Source File: Nodes.java From JDKSourceCode1.8 with MIT License | 4 votes |
@Override public Spliterator.OfInt spliterator() { return Arrays.spliterator(array, 0, curSize); }
Example 11
Source File: SpliteratorTraversingAndSplittingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "Spliterator.OfInt") public void testIntSplitOnce(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) { testSplitOnce(exp, s, intBoxingConsumer()); }
Example 12
Source File: IntPipeline.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
@Override public final Spliterator.OfInt spliterator() { return adapt(super.spliterator()); }
Example 13
Source File: Nodes.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public Spliterator.OfInt spliterator() { return Spliterators.emptyIntSpliterator(); }
Example 14
Source File: StreamSpliterators.java From JDKSourceCode1.8 with MIT License | 4 votes |
OfInt(Spliterator.OfInt s, long skip, long limit) { super(s, skip, limit); }
Example 15
Source File: StreamSpliterators.java From desugar_jdk_libs with GNU General Public License v2.0 | 4 votes |
OfInt(Supplier<Spliterator.OfInt> supplier) { super(supplier); }
Example 16
Source File: StreamSpliterators.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
OfInt(Spliterator.OfInt s, UnorderedSliceSpliterator.OfInt parent) { super(s, parent); }
Example 17
Source File: SpliteratorTraversingAndSplittingTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "Spliterator.OfInt") public void testIntForEach(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) { testForEach(exp, s, intBoxingConsumer()); }
Example 18
Source File: SpliteratorTraversingAndSplittingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "Spliterator.OfInt") public void testIntSplitUntilNull(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) { testSplitUntilNull(exp, s, intBoxingConsumer()); }
Example 19
Source File: Streams.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
OfInt(Spliterator.OfInt aSpliterator, Spliterator.OfInt bSpliterator) { super(aSpliterator, bSpliterator); }
Example 20
Source File: IntStream.java From openjdk-jdk8u 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 StackOverflowException}. * * @param a the first stream * @param b the second stream * @return the concatenation of the two input streams */ public static IntStream concat(IntStream a, IntStream b) { Objects.requireNonNull(a); Objects.requireNonNull(b); Spliterator.OfInt split = new Streams.ConcatSpliterator.OfInt( a.spliterator(), b.spliterator()); IntStream stream = StreamSupport.intStream(split, a.isParallel() || b.isParallel()); return stream.onClose(Streams.composedClose(a, b)); }