Java Code Examples for java.util.stream.DoubleStream#empty()
The following examples show how to use
java.util.stream.DoubleStream#empty() .
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: Streams.java From arctic-sea with Apache License 2.0 | 5 votes |
/** * Factory function for creating a {@code Stream} from an array. * * @param array the array * @return the stream */ public static DoubleStream stream(double[] array) { if (array == null) { return DoubleStream.empty(); } return Arrays.stream(array); }
Example 2
Source File: PluginDefaultGroovyMethods.java From groovy with Apache License 2.0 | 5 votes |
/** * If a value is present in the {@link OptionalDouble}, returns a {@link DoubleStream} * with the value as its source or else an empty stream. * * @since 3.0.0 */ public static DoubleStream stream(final OptionalDouble self) { if (!self.isPresent()) { return DoubleStream.empty(); } return DoubleStream.of(self.getAsDouble()); }
Example 3
Source File: OptionalDouble.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * If a value is present, returns a sequential {@link DoubleStream} * containing only that value, otherwise returns an empty * {@code DoubleStream}. * * @apiNote * This method can be used to transform a {@code Stream} of optional doubles * to a {@code DoubleStream} of present doubles: * <pre>{@code * Stream<OptionalDouble> os = .. * DoubleStream s = os.flatMapToDouble(OptionalDouble::stream) * }</pre> * * @return the optional value as a {@code DoubleStream} * @since 9 */ public DoubleStream stream() { if (isPresent) { return DoubleStream.of(value); } else { return DoubleStream.empty(); } }
Example 4
Source File: OptionalDouble.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * If a value is present, returns a sequential {@link DoubleStream} * containing only that value, otherwise returns an empty * {@code DoubleStream}. * * @apiNote * This method can be used to transform a {@code Stream} of optional doubles * to a {@code DoubleStream} of present doubles: * <pre>{@code * Stream<OptionalDouble> os = .. * DoubleStream s = os.flatMapToDouble(OptionalDouble::stream) * }</pre> * * @return the optional value as a {@code DoubleStream} * @since 9 */ public DoubleStream stream() { if (isPresent) { return DoubleStream.of(value); } else { return DoubleStream.empty(); } }
Example 5
Source File: DoubleStreamExample.java From levelup-java-examples with Apache License 2.0 | 3 votes |
@Test public void doublestream_empty() { DoubleStream emptyStream = DoubleStream.empty(); assertEquals(0, emptyStream.count()); }