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

项目:parallel-stream-support    文件:ParallelDoubleStreamSupportTest.java   
@Test
public void parallelStreamWithBuilder() {
  Builder builder = DoubleStream.builder();
  builder.accept(42.0);
  DoubleStream stream = ParallelDoubleStreamSupport.parallelStream(builder, this.workerPool);

  assertThat(stream, instanceOf(ParallelDoubleStreamSupport.class));
  assertTrue(stream.isParallel());
  assertEquals(OptionalDouble.of(42.0), stream.findAny());
}
项目:streamex    文件:DoubleStreamExTest.java   
@Test
public void testDropWhile() {
    assertArrayEquals(new double[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, LongStreamEx.range(100).asDoubleStream()
            .dropWhile(i -> i % 10 < 5).limit(10).toArray(), 0.0);
    assertEquals(100, LongStreamEx.range(100).asDoubleStream().sorted().dropWhile(i -> i % 10 < 0).count());
    assertEquals(0, LongStreamEx.range(100).asDoubleStream().dropWhile(i -> i % 10 < 10).count());
    assertEquals(OptionalDouble.of(0), LongStreamEx.range(100).asDoubleStream().dropWhile(i -> i % 10 < 0).findFirst());
    assertEquals(OptionalDouble.empty(), LongStreamEx.range(100).asDoubleStream().dropWhile(i -> i % 10 < 10).findFirst());

    java.util.Spliterator.OfDouble spltr = LongStreamEx.range(100).asDoubleStream().dropWhile(i -> i % 10 < 1).spliterator();
    assertTrue(spltr.tryAdvance((double x) -> assertEquals(1, x, 0.0)));
    Builder builder = DoubleStream.builder();
    spltr.forEachRemaining(builder);
    assertArrayEquals(LongStreamEx.range(2, 100).asDoubleStream().toArray(), builder.build().toArray(), 0.0);
}
项目:parallel-stream-support    文件:ParallelDoubleStreamSupportTest.java   
@Test(expected = NullPointerException.class)
public void parallelStreamWithNullBuilder() {
  ParallelDoubleStreamSupport.parallelStream((Builder) null, this.workerPool);
}