java.util.stream.DoubleStream.empty()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中java.util.stream.DoubleStream.empty()方法的一些代码示例,展示了DoubleStream.empty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DoubleStream.empty()方法的具体详情如下:
包路径:java.util.stream.DoubleStream
类名称:DoubleStream
方法名:empty

DoubleStream.empty介绍

暂无

代码示例

代码示例来源:origin: google/guava

/**
 * 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();
}

代码示例来源:origin: prestodb/presto

/**
 * 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();
}

代码示例来源:origin: google/j2objc

/**
 * 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();
}

代码示例来源:origin: neo4j/neo4j

@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() ) );
}

代码示例来源:origin: wildfly/wildfly

/**
 * 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();
}

代码示例来源:origin: speedment/speedment

@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() + "'."
      );
    }
  }
}

代码示例来源:origin: google/guava

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();
}

代码示例来源:origin: google/guava

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();
}

代码示例来源:origin: poetix/protonpack

/**
 * 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);
}

代码示例来源:origin: com.codepoetics/protonpack

/**
 * 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);
}

代码示例来源:origin: com.davidbracewell/mango

/**
* Creates an empty MDoubleStream
*
* @return the empty double stream
*/
default MDoubleStream emptyDouble() {
 return doubleStream(DoubleStream.empty());
}

代码示例来源:origin: org.apache.hbase.thirdparty/hbase-shaded-miscellaneous

/**
 * 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();
}

代码示例来源:origin: com.facebook.presto/presto-jdbc

/**
 * 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();
}

代码示例来源:origin: org.testifyproject.external/external-guava

/**
 * 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();
}

代码示例来源:origin: seznam/euphoria

/**
 * 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();
}

代码示例来源:origin: org.apache.ratis/ratis-proto-shaded

/**
 * 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();
}

代码示例来源:origin: com.davidbracewell/mango

@Override
public MDoubleStream doubleStream(DoubleStream doubleStream) {
 if (doubleStream == null) {
   return new LocalDoubleStream(DoubleStream.empty());
 }
 return new LocalDoubleStream(doubleStream);
}

代码示例来源:origin: com.davidbracewell/mango

/**
* 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));
}

代码示例来源:origin: com.google.guava/guava-tests

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();
}

代码示例来源:origin: com.google.guava/guava-tests

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();
}

相关文章