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


Java DoubleFunction.apply方法代碼示例

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


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

示例1: flatMap

import java.util.function.DoubleFunction; //導入方法依賴的package包/類
@Override
public final DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
    return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
                                    StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
            return new Sink.ChainedDouble<Double>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(double t) {
                    try (DoubleStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:DoublePipeline.java

示例2: flatMap

import java.util.function.DoubleFunction; //導入方法依賴的package包/類
@Override
public final DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
    Objects.requireNonNull(mapper);
    return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
                                    StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
            return new Sink.ChainedDouble<Double>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(double t) {
                    try (DoubleStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:DoublePipeline.java

示例3: forDouble

import java.util.function.DoubleFunction; //導入方法依賴的package包/類
/**
 * Creates an DOUBLE Printer that wraps the function provided
 * @param function  the function to wrap
 * @return          the newly created function Printer
 */
public static Printer<Double> forDouble(DoubleFunction<String> function) {
    return new Printer<Double>(FunctionStyle.DOUBLE, DEFAULT_NULL) {
        @Override
        public final String apply(double input) {
            return function.apply(input);
        }
    };
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:14,代碼來源:Printer.java

示例4: fromDouble

import java.util.function.DoubleFunction; //導入方法依賴的package包/類
/**
 * Creates an LONG function that wraps to function provided
 * @param function  the function to wrap
 * @param <O>       the output type
 * @return          the newly created function wrapper
 */
public static <O> Function2<Double,O> fromDouble(DoubleFunction<O> function) {
    return new Function2<Double,O>(FunctionStyle.DOUBLE) {
        @Override
        public final O apply(double input) {
            return function.apply(input);
        }
    };
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:15,代碼來源:Function2.java


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