本文整理汇总了Java中java.util.IntSummaryStatistics.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java IntSummaryStatistics.getCount方法的具体用法?Java IntSummaryStatistics.getCount怎么用?Java IntSummaryStatistics.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.IntSummaryStatistics
的用法示例。
在下文中一共展示了IntSummaryStatistics.getCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGeneratedInputCountFromOutputLines
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
/**
* @return a number >= 0 if it is present in the output file, otherwise -1
*/
private static int getGeneratedInputCountFromOutputLines(List<String> outputLines) {
IntSummaryStatistics ints = outputLines.stream()
.map(line -> TEST_COUNT_LINE_PATTERN.matcher(line.trim()))
.filter(m -> m.matches())
.mapToInt(m -> Integer.parseInt(m.group(1)))
.summaryStatistics();
if (ints.getMin() < 0) {
throw new RuntimeException("RANDOOP: Number of tests is negative:" + outputLines);
} else if (ints.getCount() > 0) {
return (int) ints.getSum();
} else {
return -1;
}
}
示例2: aggregate
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public RequestAggregationValues aggregate(RequestCollector requests) {
IntSummaryStatistics stats = requests.getReqTimestamps().stream().collect(Collectors.groupingBy(timestamp -> DateUtils.round(new Date(timestamp), timestampAggregation), Collectors.counting()))
.values().stream().mapToInt(p -> toInt(p)).summaryStatistics();
return new RequestAggregationValuesImpl(stats.getMin(), stats.getMax(), stats.getAverage(), stats.getSum(), stats.getCount());
}
示例3: of
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
/**
* Return a new value object of the statistical summary, currently
* represented by the {@code statistics} object.
*
* @param statistics the creating (mutable) statistics class
* @return the statistical moments
*/
public static IntSummary of(final IntSummaryStatistics statistics) {
return new IntSummary(
statistics.getCount(),
statistics.getMin(),
statistics.getMax(),
statistics.getSum(),
statistics.getAverage()
);
}
示例4: aggregate
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public RequestAggregationValues aggregate(RequestCollector requests) {
double expectedCount = getExpectedNumberOfMeasurementValueGroups();
/*
* Group by aggregation interval and create summary statistics with min, avg, max and count
*/
Collection<Long> groupedByAggregationInterval = requests.getReqTimestamps().stream()
.collect(Collectors.groupingBy(timestamp -> DateUtils.round(new Date(timestamp), timestampAggregation), Collectors.counting())).values();
int calculatedCount = groupedByAggregationInterval.size();
try {
if (calculatedCount != 0) {
// use integer summaryStatistics to get min, avg, max
IntSummaryStatistics stats = groupedByAggregationInterval.stream().mapToInt(p -> toInt(p)).summaryStatistics();
// no time range selected, just return int summary
if (expectedCount == 0) {
return new RequestAggregationValuesImpl(stats.getMin(), stats.getMax(), stats.getAverage(), stats.getSum(), stats.getCount());
}
else {
// if calculated count != expected count --> adjust minimum, average and count value
if (Double.compare(calculatedCount, expectedCount) != 0) {
double newAverage = (double) (stats.getSum() / expectedCount);
return new RequestAggregationValuesImpl(0, stats.getMax(), newAverage, stats.getSum(), (int) expectedCount);
}
else {
return new RequestAggregationValuesImpl(stats.getMin(), stats.getMax(), stats.getAverage(), stats.getSum(), (int) expectedCount);
}
}
}
else {
return new RequestAggregationValuesImpl(0, 0, 0, 0, 0);
}
}
catch (ArithmeticException e) {
System.out.println(e.getMessage());
return new RequestAggregationValuesImpl(0, 0, 0, 0, 0);
}
}
示例5: SummaryStatistics
import java.util.IntSummaryStatistics; //导入方法依赖的package包/类
public SummaryStatistics(IntSummaryStatistics statistics) {
this(statistics.getAverage(), statistics.getMax(),
statistics.getMin(), statistics.getCount(),
statistics.getSum());
}