/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
@SuppressWarnings( "unchecked" ) public static DoubleStream toDoubleStream( Object list ) { if ( list == null ) { return DoubleStream.empty(); } else if ( list instanceof SequenceValue ) { throw new IllegalArgumentException( "Need to implement support for SequenceValue in CompiledConversionUtils.toDoubleStream" ); } else if ( list instanceof List ) { return ((List) list).stream().mapToDouble( n -> ((Number) n).doubleValue() ); } else if ( Object[].class.isAssignableFrom( list.getClass() ) ) { return Arrays.stream( (Object[]) list ).mapToDouble( n -> ((Number) n).doubleValue() ); } else if ( list instanceof float[] ) { float[] array = (float[]) list; return IntStream.range( 0, array.length ).mapToDouble( i -> array[i] ); } else if ( list instanceof double[] ) { return DoubleStream.of( (double[]) list ); } throw new IllegalArgumentException( format( "Can not be converted to stream: %s", list.getClass().getName() ) ); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
@Override public TS build(boolean parallel) { if (Stream.class.equals(streamType)) { @SuppressWarnings("unchecked") final TS result = (TS) Stream.empty(); return result; } else if (IntStream.class.equals(streamType)) { @SuppressWarnings("unchecked") final TS result = (TS) IntStream.empty(); return result; } else if (LongStream.class.equals(streamType)) { @SuppressWarnings("unchecked") final TS result = (TS) LongStream.empty(); return result; } else if (DoubleStream.class.equals(streamType)) { @SuppressWarnings("unchecked") final TS result = (TS) DoubleStream.empty(); return result; } else { throw new UnsupportedOperationException( "Unknown stream type '" + streamType.getName() + "'." ); } } }
public void testCopyOf_stream() { assertThat(ImmutableDoubleArray.copyOf(DoubleStream.empty())) .isSameAs(ImmutableDoubleArray.of()); assertThat(ImmutableDoubleArray.copyOf(DoubleStream.of(0, 1, 3)).asList()) .containsExactly(0.0, 1.0, 3.0) .inOrder(); }
public void testConcat_doubleStream() { assertThat( Streams.concat( DoubleStream.of(1), DoubleStream.of(2), DoubleStream.empty(), DoubleStream.of(3, 4))) .containsExactly(1.0, 2.0, 3.0, 4.0) .inOrder(); }
/** * Converts nullable float array into an empty stream, and non-null array into a stream. * @param nullable The nullable array to convert. * @return A stream of zero or more values. */ public static DoubleStream ofNullable(double[] nullable) { return null == nullable ? DoubleStream.empty() : Arrays.stream(nullable); }
/** * Converts nullable float array into an empty stream, and non-null array into a stream. * @param nullable The nullable array to convert. * @return A stream of zero or more values. */ public static DoubleStream ofNullable(double[] nullable) { return null == nullable ? DoubleStream.empty() : Arrays.stream(nullable); }
/** * Creates an empty MDoubleStream * * @return the empty double stream */ default MDoubleStream emptyDouble() { return doubleStream(DoubleStream.empty()); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
/** * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. * * <p><b>Java 9 users:</b> use {@code optional.stream()} instead. */ public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); }
@Override public MDoubleStream doubleStream(DoubleStream doubleStream) { if (doubleStream == null) { return new LocalDoubleStream(DoubleStream.empty()); } return new LocalDoubleStream(doubleStream); }
/** * Creates a MDoubleStream from a variable list of doubles * * @param values the values making up the double stream * @return the MDoubleStream */ default MDoubleStream doubleStream(double... values) { if (values == null) { return doubleStream(DoubleStream.empty()); } return doubleStream(DoubleStream.of(values)); }
public void testCopyOf_stream() { assertThat(ImmutableDoubleArray.copyOf(DoubleStream.empty())) .isSameAs(ImmutableDoubleArray.of()); assertThat(ImmutableDoubleArray.copyOf(DoubleStream.of(0, 1, 3)).asList()) .containsExactly(0.0, 1.0, 3.0) .inOrder(); }
public void testConcat_doubleStream() { assertThat( Streams.concat( DoubleStream.of(1), DoubleStream.of(2), DoubleStream.empty(), DoubleStream.of(3, 4))) .containsExactly(1.0, 2.0, 3.0, 4.0) .inOrder(); }