Java Code Examples for java.util.stream.DoubleStream#count()
The following examples show how to use
java.util.stream.DoubleStream#count() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShiftingWindowAveragingLongTest.java From streams-utils with Apache License 2.0 | 5 votes |
@Test public void should_average_an_empty_stream_into_a_stream_of_an_empty_stream() { // Given // a trick to create an empty ORDERED stream Stream<Long> longs = Stream.of(1L, 2L, 3L).filter(l -> l == 0); int groupingFactor = 3; // When DoubleStream stream = StreamsUtils.shiftingWindowAveragingLong(longs, groupingFactor, Long::valueOf); long numberOfRolledStreams = stream.count(); // Then assertThat(numberOfRolledStreams).isEqualTo(1); }
Example 2
Source File: ShiftingWindowAveragingLongTest.java From streams-utils with Apache License 2.0 | 5 votes |
@Test public void should_correctly_count_the_elements_of_a_sized_stream() { // Given Stream<String> strings = Stream.of("1", "2", "3", "4", "5", "6", "7"); int groupingFactor = 3; DoubleStream stream = StreamsUtils.shiftingWindowAveragingLong(strings, groupingFactor, Long::parseLong); // When long count = stream.count(); // Then assertThat(count).isEqualTo(5L); }
Example 3
Source File: ShiftingWindowAveragingIntTest.java From streams-utils with Apache License 2.0 | 5 votes |
@Test public void should_average_an_empty_stream_into_a_stream_of_an_empty_stream() { // Given // a trick to create an empty ORDERED stream Stream<Integer> ints = Stream.of(1, 2, 3).filter(i -> i == 0); int groupingFactor = 3; // When DoubleStream stream = StreamsUtils.shiftingWindowAveragingInt(ints, groupingFactor, Integer::valueOf); long numberOfRolledStreams = stream.count(); // Then assertThat(numberOfRolledStreams).isEqualTo(1); }
Example 4
Source File: ShiftingWindowAveragingIntTest.java From streams-utils with Apache License 2.0 | 5 votes |
@Test public void should_correctly_count_the_elements_of_a_sized_stream() { // Given Stream<String> strings = Stream.of("1", "2", "3", "4", "5", "6", "7"); int groupingFactor = 3; DoubleStream stream = StreamsUtils.shiftingWindowAveragingInt(strings, groupingFactor, Integer::parseInt); // When long count = stream.count(); // Then assertThat(count).isEqualTo(5L); }
Example 5
Source File: ShiftingWindowAveragingDoubleTest.java From streams-utils with Apache License 2.0 | 5 votes |
@Test public void should_average_an_empty_stream_into_a_stream_of_an_empty_stream() { // Given // a trick to create an empty ORDERED stream Stream<Double> longs = Stream.of(1d, 2d, 3d).filter(d -> d == 0); int groupingFactor = 3; // When DoubleStream stream = StreamsUtils.shiftingWindowAveragingDouble(longs, groupingFactor, Double::valueOf); long numberOfRolledStreams = stream.count(); // Then assertThat(numberOfRolledStreams).isEqualTo(1); }
Example 6
Source File: ShiftingWindowAveragingDoubleTest.java From streams-utils with Apache License 2.0 | 5 votes |
@Test public void should_correctly_count_the_elements_of_a_sized_stream() { // Given Stream<String> strings = Stream.of("1", "2", "3", "4", "5", "6", "7"); int groupingFactor = 3; DoubleStream stream = StreamsUtils.shiftingWindowAveragingDouble(strings, groupingFactor, Double::parseDouble); // When long count = stream.count(); // Then assertThat(count).isEqualTo(5L); }