當前位置: 首頁>>代碼示例>>Java>>正文


Java LongStream.of方法代碼示例

本文整理匯總了Java中java.util.stream.LongStream.of方法的典型用法代碼示例。如果您正苦於以下問題:Java LongStream.of方法的具體用法?Java LongStream.of怎麽用?Java LongStream.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.stream.LongStream的用法示例。


在下文中一共展示了LongStream.of方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: arrayToStream

import java.util.stream.LongStream; //導入方法依賴的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();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:ArrayStreamLinkerExporter.java

示例2: longProvider

import java.util.stream.LongStream; //導入方法依賴的package包/類
static LongStream longProvider() {
    return LongStream.of(4L, 5L);
}
 
開發者ID:bonigarcia,項目名稱:mastering-junit5,代碼行數:4,代碼來源:MethodSourcePrimitiveTypesParameterizedTest.java

示例3: stream

import java.util.stream.LongStream; //導入方法依賴的package包/類
@NonNull
@Override
default LongStream stream() {
  return LongStream.of(this.x(), this.y());
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:6,代碼來源:Vector2l.java

示例4: stream

import java.util.stream.LongStream; //導入方法依賴的package包/類
@NonNull
@Override
default LongStream stream() {
  return LongStream.of(this.x(), this.y(), this.z(), this.w());
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:6,代碼來源:Vector4l.java

示例5: stream

import java.util.stream.LongStream; //導入方法依賴的package包/類
@NonNull
@Override
default LongStream stream() {
  return LongStream.of(this.x(), this.y(), this.z());
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:6,代碼來源:Vector3l.java

示例6: stream

import java.util.stream.LongStream; //導入方法依賴的package包/類
/**
 * If a value is present, returns a sequential {@link LongStream} containing
 * only that value, otherwise returns an empty {@code LongStream}.
 *
 * @apiNote
 * This method can be used to transform a {@code Stream} of optional longs
 * to an {@code LongStream} of present longs:
 * <pre>{@code
 *     Stream<OptionalLong> os = ..
 *     LongStream s = os.flatMapToLong(OptionalLong::stream)
 * }</pre>
 *
 * @return the optional value as an {@code LongStream}
 * @since 9
 */
public LongStream stream() {
    if (isPresent) {
        return LongStream.of(value);
    } else {
        return LongStream.empty();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:OptionalLong.java

示例7: stream

import java.util.stream.LongStream; //導入方法依賴的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 LongStream stream(OptionalLong optional) {
  return optional.isPresent() ? LongStream.of(optional.getAsLong()) : LongStream.empty();
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:10,代碼來源:Streams.java


注:本文中的java.util.stream.LongStream.of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。