本文整理匯總了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));
}
}
};
}
};
}
示例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));
}
}
};
}
};
}
示例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);
}
};
}
示例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);
}
};
}