本文整理匯總了Java中java.util.stream.DoubleStream.of方法的典型用法代碼示例。如果您正苦於以下問題:Java DoubleStream.of方法的具體用法?Java DoubleStream.of怎麽用?Java DoubleStream.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.stream.DoubleStream
的用法示例。
在下文中一共展示了DoubleStream.of方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testXxxStream
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
/**
* jdk提供的其他創建流的方式
*/
@Test
public void testXxxStream() {
IntStream intStream = IntStream.range(1, 10);
DoubleStream doubleStream = DoubleStream.of(10.2, 20.1);
LongStream longStream = LongStream.range(1, 100);
}
示例2: arrayToStream
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
public static Object arrayToStream(final Object array) {
if (array instanceof int[]) {
return IntStream.of((int[])array);
} else if (array instanceof long[]) {
return LongStream.of((long[])array);
} else if (array instanceof double[]) {
return DoubleStream.of((double[])array);
} else if (array instanceof Object[]) {
return Stream.of((Object[])array);
} else {
throw new IllegalArgumentException();
}
}
示例3: doubleProvider
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
static DoubleStream doubleProvider() {
return DoubleStream.of(2d, 3d);
}
示例4: stream
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
@NonNull
@Override
default DoubleStream stream() {
return DoubleStream.of(this.x(), this.y(), this.z(), this.w());
}
示例5: stream
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
@NonNull
@Override
default DoubleStream stream() {
return DoubleStream.of(this.x(), this.y(), this.z());
}
示例6: stream
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
@NonNull
@Override
default DoubleStream stream() {
return DoubleStream.of(this.x(), this.y());
}
示例7: stream
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
/**
* 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();
}
}
示例8: stream
import java.util.stream.DoubleStream; //導入方法依賴的package包/類
/**
* 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();
}