Java 类java.util.stream.IntStream.Builder 实例源码

项目:parallel-stream-support    文件:ParallelIntStreamSupportTest.java   
@Test
public void parallelStreamWithBuilder() {
  Builder builder = IntStream.builder();
  builder.accept(42);
  IntStream stream = ParallelIntStreamSupport.parallelStream(builder, this.workerPool);

  assertThat(stream, instanceOf(ParallelIntStreamSupport.class));
  assertTrue(stream.isParallel());
  assertEquals(OptionalInt.of(42), stream.findAny());
}
项目:streamex    文件:IntStreamExTest.java   
@Test
public void testDropWhile() {
    assertArrayEquals(new int[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, IntStreamEx.range(100).dropWhile(
        i -> i % 10 < 5).limit(10).toArray());
    assertEquals(100, IntStreamEx.range(100).dropWhile(i -> i % 10 < 0).count());
    assertEquals(0, IntStreamEx.range(100).dropWhile(i -> i % 10 < 10).count());
    assertEquals(OptionalInt.of(0), IntStreamEx.range(100).dropWhile(i -> i % 10 < 0).findFirst());
    assertEquals(OptionalInt.empty(), IntStreamEx.range(100).dropWhile(i -> i % 10 < 10).findFirst());

    java.util.Spliterator.OfInt spltr = IntStreamEx.range(100).dropWhile(i -> i % 10 < 1).spliterator();
    assertTrue(spltr.tryAdvance((int x) -> assertEquals(1, x)));
    Builder builder = IntStream.builder();
    spltr.forEachRemaining(builder);
    assertArrayEquals(IntStreamEx.range(2, 100).toArray(), builder.build().toArray());
}
项目:parallel-stream-support    文件:ParallelIntStreamSupportTest.java   
@Test(expected = NullPointerException.class)
public void parallelStreamWithNullBuilder() {
  ParallelIntStreamSupport.parallelStream((Builder) null, this.workerPool);
}