本文整理了Java中java.util.stream.DoubleStream.reduce()
方法的一些代码示例,展示了DoubleStream.reduce()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DoubleStream.reduce()
方法的具体详情如下:
包路径:java.util.stream.DoubleStream
类名称:DoubleStream
方法名:reduce
[英]Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value. This is equivalent to:
double result = identity;
but is not constrained to execute sequentially.
The identity value must be an identity for the accumulator function. This means that for all x, accumulator.apply(identity, x) is equal to x. The accumulator function must be an associative function.
This is a terminal operation.
[中]使用提供的标识值和associative累积函数对此流的元素执行{$0$},并返回缩减后的值。这相当于:
double result = identity;
但不受顺序执行的约束。
标识值必须是累加器函数的标识。这意味着对于所有x,累加器。apply(identity,x)等于x。累加器函数必须是associative函数。
这是一个terminal operation。
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Double apply(double[] estimations) {
A.notEmpty(estimations, "estimations vector");
return Arrays.stream(estimations).reduce(0.0, Double::sum) / estimations.length;
}
}
代码示例来源:origin: speedment/speedment
@Override
public OptionalDouble execute() {
try (final DoubleStream stream = buildPrevious()) {
if (hasInitialValue) {
return OptionalDouble.of(stream.reduce(initialValue, combiner));
} else {
return stream.reduce(combiner);
}
}
}
}
代码示例来源:origin: speedment/speedment
default OptionalDouble reduce(DoublePipeline pipeline, DoubleBinaryOperator op) {
requireNonNull(pipeline);
requireNonNull(op);
return optimize(pipeline).getAsDoubleStream().reduce(op);
}
代码示例来源:origin: speedment/speedment
default double reduce(DoublePipeline pipeline, double identity, DoubleBinaryOperator op) {
requireNonNull(pipeline);
requireNonNull(identity);
requireNonNull(op);
return optimize(pipeline).getAsDoubleStream().reduce(identity, op);
}
代码示例来源:origin: speedment/speedment
@Override
public double reduce(double identity, DoubleBinaryOperator op) {
return finallyClose(() -> stream().reduce(identity, op));
}
代码示例来源:origin: speedment/speedment
@Override
public OptionalDouble reduce(DoubleBinaryOperator op) {
return finallyClose(() -> stream().reduce(op));
}
代码示例来源:origin: vavr-io/vavr
return ((Iterator<BigDecimal>) iter).foldLeft(((BigDecimal) o), BigDecimal::multiply);
} else {
return ((Iterator<Number>) iter).toJavaStream().mapToDouble(Number::doubleValue).reduce(((Number) o).doubleValue(), (d1, d2) -> d1 * d2);
代码示例来源:origin: com.davidbracewell/mango
@Override
public double reduce(double zeroValue, @NonNull SerializableDoubleBinaryOperator operator) {
return stream.reduce(zeroValue, operator);
}
代码示例来源:origin: com.davidbracewell/mango
@Override
public OptionalDouble reduce(@NonNull SerializableDoubleBinaryOperator operator) {
return stream.reduce(operator);
}
代码示例来源:origin: pavelfatin/typometer
public double getMaxValue() {
return mySeries.stream().mapToDouble(Series::getMaxValue).reduce(0.0D, Math::max);
}
}
代码示例来源:origin: io.prestosql/presto-main
private double estimatedGroupCount(List<Symbol> symbols, PlanNodeStatsEstimate statsEstimate)
{
return symbols.stream()
.map(statsEstimate::getSymbolStatistics)
.mapToDouble(this::ndvIncludingNull)
// This assumes no correlation, maximum number of aggregation keys
.reduce(1, (a, b) -> a * b);
}
代码示例来源:origin: org.qcri.rheem/rheem-core
/**
* Utility method to calculate the probability that all cardinality estimates are correct.
*
* @param estimates some {@link CardinalityEstimate}s
* @return the joint probability of all {@link CardinalityEstimate}s being correct
*/
private double calculateJointProbability(CardinalityEstimate[] estimates) {
return Arrays.stream(estimates)
.map(this::replaceNullCardinality)
.mapToDouble(CardinalityEstimate::getCorrectnessProbability)
.reduce(1d, (a, b) -> a * b);
}
代码示例来源:origin: se.ugli.ugli-commons/ugli-commons
@Override
public OptionalDouble reduce(final DoubleBinaryOperator op) {
// This is a terminal operation
return evalAndclose(() -> stream.reduce(op));
}
代码示例来源:origin: se.ugli.ugli-commons/ugli-commons
@Override
public double reduce(final double identity, final DoubleBinaryOperator op) {
// This is a terminal operation
return evalAndclose(() -> stream.reduce(identity, op));
}
代码示例来源:origin: one.util/streamex
@Override
public double reduce(double identity, DoubleBinaryOperator op) {
if (context.fjp != null)
return context.terminate(() -> stream().reduce(identity, op));
return stream().reduce(identity, op);
}
代码示例来源:origin: com.speedment.runtime/runtime-core
default double reduce(DoublePipeline pipeline, double identity, DoubleBinaryOperator op) {
requireNonNull(pipeline);
requireNonNull(identity);
requireNonNull(op);
return optimize(pipeline).getAsDoubleStream().reduce(identity, op);
}
代码示例来源:origin: com.speedment.runtime/runtime-core
default OptionalDouble reduce(DoublePipeline pipeline, DoubleBinaryOperator op) {
requireNonNull(pipeline);
requireNonNull(op);
return optimize(pipeline).getAsDoubleStream().reduce(op);
}
代码示例来源:origin: com.speedment.runtime/runtime-core
@Override
public double reduce(double identity, DoubleBinaryOperator op) {
return finallyClose(() -> stream().reduce(identity, op));
}
代码示例来源:origin: com.simiacryptus/java-util
/**
* Gets volume.
*
* @return the volume
*/
public double getVolume() {
int dim = min.length;
return IntStream.range(0, dim).mapToDouble(d -> {
return max[d] - min[d];
}).filter(x -> Double.isFinite(x) && x > 0.0).reduce((a, b) -> a * b).orElse(Double.NaN);
}
代码示例来源:origin: one.util/streamex
@Override
public OptionalDouble reduce(DoubleBinaryOperator op) {
if (context.fjp != null)
return context.terminate(op, stream()::reduce);
return stream().reduce(op);
}
内容来源于网络,如有侵权,请联系作者删除!