本文整理了Java中java.util.stream.Collectors.summarizingDouble()
方法的一些代码示例,展示了Collectors.summarizingDouble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collectors.summarizingDouble()
方法的具体详情如下:
包路径:java.util.stream.Collectors
类名称:Collectors
方法名:summarizingDouble
暂无
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Product, DoubleSummaryStatistics> aggregateByProduct_serial_lazy_jdk()
{
Map<Product, DoubleSummaryStatistics> result =
this.jdkPositions.stream().collect(
Collectors.groupingBy(
Position::getProduct,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Account, DoubleSummaryStatistics> aggregateByAccount_serial_lazy_jdk()
{
Map<Account, DoubleSummaryStatistics> accountDoubleMap =
this.jdkPositions.stream().collect(
Collectors.groupingBy(
Position::getAccount,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(accountDoubleMap);
return accountDoubleMap;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<String, DoubleSummaryStatistics> aggregateByCategory_serial_lazy_jdk()
{
Map<String, DoubleSummaryStatistics> categoryDoubleMap =
this.jdkPositions.stream().collect(
Collectors.groupingBy(
Position::getCategory,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(categoryDoubleMap);
return categoryDoubleMap;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<String, DoubleSummaryStatistics> aggregateByCategory_serial_lazy_streams_gsc()
{
Map<String, DoubleSummaryStatistics> categoryDoubleMap =
this.gscPositions.stream().collect(
Collectors.groupingBy(
Position::getCategory,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(categoryDoubleMap);
return categoryDoubleMap;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Account, DoubleSummaryStatistics> aggregateByAccount_parallel_lazy_jdk()
{
Map<Account, DoubleSummaryStatistics> result =
this.jdkPositions.parallelStream().collect(
Collectors.groupingBy(
Position::getAccount,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Account, DoubleSummaryStatistics> aggregateByAccount_parallel_lazy_streams_gsc()
{
Map<Account, DoubleSummaryStatistics> result =
this.gscPositions.parallelStream().collect(
Collectors.groupingBy(
Position::getAccount,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<String, DoubleSummaryStatistics> aggregateByCategory_parallel_lazy_streams_gsc()
{
Map<String, DoubleSummaryStatistics> result =
this.gscPositions.parallelStream().collect(
Collectors.groupingBy(Position::getCategory, Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Account, DoubleSummaryStatistics> aggregateByAccount_serial_lazy_streams_gsc()
{
Map<Account, DoubleSummaryStatistics> accountDoubleMap =
this.gscPositions.stream().collect(
Collectors.groupingBy(
Position::getAccount,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(accountDoubleMap);
return accountDoubleMap;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Product, DoubleSummaryStatistics> aggregateByProduct_parallel_lazy_jdk()
{
Map<Product, DoubleSummaryStatistics> result =
this.jdkPositions.parallelStream().collect(
Collectors.groupingBy(
Position::getProduct,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Product, DoubleSummaryStatistics> aggregateByProduct_serial_lazy_streams_gsc()
{
Map<Product, DoubleSummaryStatistics> result =
this.gscPositions.stream().collect(
Collectors.groupingBy(
Position::getProduct,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<Product, DoubleSummaryStatistics> aggregateByProduct_parallel_lazy_streams_gsc()
{
Map<Product, DoubleSummaryStatistics> result =
this.gscPositions.parallelStream().collect(
Collectors.groupingBy(
Position::getProduct,
Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public Map<String, DoubleSummaryStatistics> aggregateByCategory_parallel_lazy_jdk()
{
Map<String, DoubleSummaryStatistics> result =
this.jdkPositions.parallelStream().collect(
Collectors.groupingBy(Position::getCategory, Collectors.summarizingDouble(Position::getMarketValue)));
Assert.assertNotNull(result);
return result;
}
代码示例来源:origin: OryxProject/oryx
.collect(Collectors.summarizingDouble(f -> ((NumericFeature) f).getValue()))
).collect().stream().map(p -> {
代码示例来源:origin: aol/cyclops
default DoubleSummaryStatistics doubleStats(ToDoubleFunction<T> fn){
return stream().collect(Collectors.summarizingDouble(fn));
}
代码示例来源:origin: geotools/geotools
/** Returns min and max value applying the expression over the feature collection */
public static NumberRange<Double> getMinMax(
ListFeatureCollection fc, Expression attributeExpression) {
DoubleSummaryStatistics stats =
fc.stream()
.collect(
Collectors.summarizingDouble(
f -> attributeExpression.evaluate(f, Double.class)));
return new NumberRange<>(Double.class, stats.getMin(), stats.getMax());
}
代码示例来源:origin: sing-group/GC4S
protected String getDoubleListSummary(List<Double> values,
String numericType
) {
DoubleSummaryStatistics statistics = values.stream()
.collect(Collectors.summarizingDouble(Double::doubleValue));
return getSummary(numericType, new SummaryStatistics(statistics));
}
代码示例来源:origin: kousen/java_8_recipes
public void computeSalaryStatistics() {
List<Team> teams = parseSalaries();
DoubleSummaryStatistics teamStats = teams.stream()
.mapToDouble(Team::getSalary)
.collect(DoubleSummaryStatistics::new,
DoubleSummaryStatistics::accept,
DoubleSummaryStatistics::combine);
printStats(teamStats);
teamStats = teams.stream()
.collect(Collectors.summarizingDouble(Team::getSalary));
printStats(teamStats);
}
代码示例来源:origin: com.oath.cyclops/cyclops
default DoubleSummaryStatistics doubleStats(ToDoubleFunction<T> fn){
return stream().collect(Collectors.summarizingDouble(fn));
}
代码示例来源:origin: Netflix/spectator
@Test
public void maxGauge() {
Registry r = newRegistry(true, 10000);
r.maxGauge("foo").set(1.0);
r.maxGauge("foo").set(3.0);
r.maxGauge("foo").set(2.0);
final DoubleSummaryStatistics valueSummary = r.gauges()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingDouble(Gauge::value));
Assertions.assertEquals(1, valueSummary.getCount());
Assertions.assertEquals(3.0, valueSummary.getSum(), 1e-12);
}
代码示例来源:origin: Netflix/spectator
@Test
public void gauges() {
Registry r = newRegistry(true, 10000);
r.gauge(r.createId("foo", "a", "1")).set(1.0);
r.gauge(r.createId("foo", "a", "2")).set(2.0);
r.gauge(r.createId("bar")).set(7.0);
Assertions.assertEquals(3, r.gauges().count());
final DoubleSummaryStatistics valueSummary = r.gauges()
.filter(Functions.nameEquals("foo"))
.collect(Collectors.summarizingDouble(Gauge::value));
Assertions.assertEquals(2, valueSummary.getCount());
Assertions.assertEquals(3.0, valueSummary.getSum(), 1e-12);
Assertions.assertEquals(1.5, valueSummary.getAverage(), 1e-12);
}
内容来源于网络,如有侵权,请联系作者删除!