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

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

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

    java.util.Spliterator.OfLong spltr = LongStreamEx.range(100).dropWhile(i -> i % 10 < 1).spliterator();
    assertTrue(spltr.tryAdvance((long x) -> assertEquals(1, x)));
    Builder builder = LongStream.builder();
    spltr.forEachRemaining(builder);
    assertArrayEquals(LongStreamEx.range(2, 100).toArray(), builder.build().toArray());
}
项目:parallel-stream-support    文件:ParallelLongStreamSupportTest.java   
@Test(expected = NullPointerException.class)
public void parallelStreamWithNullBuilder() {
  ParallelLongStreamSupport.parallelStream((Builder) null, this.workerPool);
}
项目:perfload-perfalyzer    文件:BinManager.java   
/**
 * Creates a {@link java.util.stream.LongStream} with the bin counts as its source.
 *
 * @return the stream
 */
public LongStream countStream() {
    Builder builder = LongStream.builder();
    bins.forEach(bin -> builder.add(bin.counter));
    return builder.build();
}