Search in sources :

Example 76 with Spliterator

use of java.util.Spliterator in project Bytecoder by mirkosertic.

the class DoublePipeline method forEachWithCancel.

@Override
final boolean forEachWithCancel(Spliterator<Double> spliterator, Sink<Double> sink) {
    Spliterator.OfDouble spl = adapt(spliterator);
    DoubleConsumer adaptedSink = adapt(sink);
    boolean cancelled;
    do {
    } while (!(cancelled = sink.cancellationRequested()) && spl.tryAdvance(adaptedSink));
    return cancelled;
}
Also used : DoubleConsumer(java.util.function.DoubleConsumer) ObjDoubleConsumer(java.util.function.ObjDoubleConsumer) Spliterator(java.util.Spliterator)

Example 77 with Spliterator

use of java.util.Spliterator in project Bytecoder by mirkosertic.

the class IntPipeline method forEachWithCancel.

@Override
final boolean forEachWithCancel(Spliterator<Integer> spliterator, Sink<Integer> sink) {
    Spliterator.OfInt spl = adapt(spliterator);
    IntConsumer adaptedSink = adapt(sink);
    boolean cancelled;
    do {
    } while (!(cancelled = sink.cancellationRequested()) && spl.tryAdvance(adaptedSink));
    return cancelled;
}
Also used : Spliterator(java.util.Spliterator) IntConsumer(java.util.function.IntConsumer) ObjIntConsumer(java.util.function.ObjIntConsumer)

Example 78 with Spliterator

use of java.util.Spliterator in project openj9 by eclipse.

the class StringStreams method testStringCharsSpliteratorEmpty.

@Test
public void testStringCharsSpliteratorEmpty() {
    Spliterator.OfInt s = EMPTY.chars().spliterator();
    final ArrayList<Integer> actualIntegers = new ArrayList<>();
    s.forEachRemaining((IntConsumer) i -> actualIntegers.add(Integer.valueOf(i)));
    checkDigitsOrdered(EMPTY, actualIntegers);
}
Also used : HashSet(java.util.HashSet) Objects(java.util.Objects) List(java.util.List) OfInt(java.util.Spliterator.OfInt) IntConsumer(java.util.function.IntConsumer) Assert.assertEquals(org.testng.Assert.assertEquals) Assert.assertTrue(org.testng.Assert.assertTrue) Set(java.util.Set) VersionCheck(org.openj9.test.util.VersionCheck) Test(org.testng.annotations.Test) Spliterator(java.util.Spliterator) ArrayList(java.util.ArrayList) OfInt(java.util.Spliterator.OfInt) ArrayList(java.util.ArrayList) Spliterator(java.util.Spliterator) Test(org.testng.annotations.Test)

Example 79 with Spliterator

use of java.util.Spliterator in project openj9 by eclipse.

the class StringStreams method testStringCharsSpliteratorSplitting.

@Test
public void testStringCharsSpliteratorSplitting() {
    OfInt s = DIGITS.chars().spliterator();
    ArrayList<OfInt> sArray = new ArrayList<>();
    while (Objects.nonNull(s)) {
        sArray.add(s);
        s = s.trySplit();
    }
    final HashSet<Integer> actualIntegers = new HashSet<>();
    for (OfInt e : sArray) {
        e.forEachRemaining((IntConsumer) i -> actualIntegers.add(Integer.valueOf(i)));
    }
    checkDigits(actualIntegers);
}
Also used : OfInt(java.util.Spliterator.OfInt) HashSet(java.util.HashSet) Objects(java.util.Objects) List(java.util.List) OfInt(java.util.Spliterator.OfInt) IntConsumer(java.util.function.IntConsumer) Assert.assertEquals(org.testng.Assert.assertEquals) Assert.assertTrue(org.testng.Assert.assertTrue) Set(java.util.Set) VersionCheck(org.openj9.test.util.VersionCheck) Test(org.testng.annotations.Test) Spliterator(java.util.Spliterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 80 with Spliterator

use of java.util.Spliterator in project openj9 by eclipse.

the class StringStreams method testStringCodePointsSpliterator.

@Test
public void testStringCodePointsSpliterator() {
    Spliterator.OfInt s = DIGITS.chars().spliterator();
    final ArrayList<Integer> actualIntegers = new ArrayList<>();
    s.forEachRemaining((IntConsumer) i -> actualIntegers.add(Integer.valueOf(i)));
    checkDigitsOrdered(DIGITS, actualIntegers);
}
Also used : HashSet(java.util.HashSet) Objects(java.util.Objects) List(java.util.List) OfInt(java.util.Spliterator.OfInt) IntConsumer(java.util.function.IntConsumer) Assert.assertEquals(org.testng.Assert.assertEquals) Assert.assertTrue(org.testng.Assert.assertTrue) Set(java.util.Set) VersionCheck(org.openj9.test.util.VersionCheck) Test(org.testng.annotations.Test) Spliterator(java.util.Spliterator) ArrayList(java.util.ArrayList) OfInt(java.util.Spliterator.OfInt) ArrayList(java.util.ArrayList) Spliterator(java.util.Spliterator) Test(org.testng.annotations.Test)

Aggregations

Spliterator (java.util.Spliterator)124 List (java.util.List)47 ArrayList (java.util.ArrayList)41 HashSet (java.util.HashSet)36 IntConsumer (java.util.function.IntConsumer)35 Set (java.util.Set)31 Objects (java.util.Objects)25 Collectors (java.util.stream.Collectors)25 Spliterators (java.util.Spliterators)24 Function (java.util.function.Function)24 Iterator (java.util.Iterator)23 Consumer (java.util.function.Consumer)23 Stream (java.util.stream.Stream)23 Map (java.util.Map)22 Arrays (java.util.Arrays)20 LongConsumer (java.util.function.LongConsumer)20 Collections (java.util.Collections)19 StreamSupport (java.util.stream.StreamSupport)19 Comparator (java.util.Comparator)18 Test (org.junit.Test)18