Search in sources :

Example 1 with OfInt

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

the class StringStreams method testStringCharsSpliteratorSplittingAfterIterating.

/**
 * Consume a bit of the spliterator, then split it.
 */
@Test
public void testStringCharsSpliteratorSplittingAfterIterating() {
    OfInt s = DIGITS.chars().spliterator();
    ArrayList<OfInt> sArray = new ArrayList<>();
    final HashSet<Integer> actualIntegers = new HashSet<>();
    IntConsumer consumer = (IntConsumer) i -> actualIntegers.add(Integer.valueOf(i));
    while (Objects.nonNull(s)) {
        s.tryAdvance(consumer);
        sArray.add(s);
        s = s.trySplit();
    }
    for (OfInt e : sArray) {
        e.forEachRemaining(consumer);
    }
    checkDigits(actualIntegers);
}
Also used : OfInt(java.util.Spliterator.OfInt) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IntConsumer(java.util.function.IntConsumer) Test(org.testng.annotations.Test)

Example 2 with OfInt

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

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 3 with OfInt

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

the class StringStreams method testStringCharsSpliteratorSplittingAfterIterating.

/**
 * Consume a bit of the spliterator, then split it.
 */
@Test
public void testStringCharsSpliteratorSplittingAfterIterating() {
    OfInt s = DIGITS.chars().spliterator();
    ArrayList<OfInt> sArray = new ArrayList<>();
    final HashSet<Integer> actualIntegers = new HashSet<>();
    IntConsumer consumer = (IntConsumer) i -> actualIntegers.add(Integer.valueOf(i));
    while (Objects.nonNull(s)) {
        s.tryAdvance(consumer);
        sArray.add(s);
        s = s.trySplit();
    }
    for (OfInt e : sArray) {
        e.forEachRemaining(consumer);
    }
    checkDigits(actualIntegers);
}
Also used : OfInt(java.util.Spliterator.OfInt) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IntConsumer(java.util.function.IntConsumer) Test(org.testng.annotations.Test)

Example 4 with OfInt

use of java.util.Spliterator.OfInt 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)

Aggregations

ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 OfInt (java.util.Spliterator.OfInt)4 IntConsumer (java.util.function.IntConsumer)4 Test (org.testng.annotations.Test)4 List (java.util.List)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Spliterator (java.util.Spliterator)2 VersionCheck (org.openj9.test.util.VersionCheck)2 Assert.assertEquals (org.testng.Assert.assertEquals)2 Assert.assertTrue (org.testng.Assert.assertTrue)2