public class IntSummaryStatistics extends Object implements IntConsumer
这个课程旨在与(但不要求)工作( streams) 。 例如,您可以使用以下方式计算int数据流的汇总统计信息:
IntSummaryStatistics stats = intStream.collect(IntSummaryStatistics::new, IntSummaryStatistics::accept, IntSummaryStatistics::combine);
IntSummaryStatistics可以用作reduction目标为stream 。 例如:
IntSummaryStatistics stats = people.stream() .collect(Collectors.summarizingInt(Person::getDependents));
这个计算单次通过计算人数,以及其受扶养人数的最小值,最大值,总和和平均值。
Collectors.toIntStatistics()上并行流,因为并行执行Stream.collect()提供了必要的隔离,隔离和结果安全,高效的并行执行的合并。
此实现不检查总和的溢出。
| Constructor and Description |
|---|
IntSummaryStatistics()
用零计数,零和,
Integer.MAX_VALUE分钟,
Integer.MIN_VALUE最大和零平均值构造一个空实例。
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(int value)
在摘要信息中记录一个新值
|
void |
combine(IntSummaryStatistics other)
将另一个
IntSummaryStatistics的状态
IntSummaryStatistics到这一个中。
|
double |
getAverage()
返回记录的值的算术平均值,如果没有记录值,则返回零。
|
long |
getCount()
返回记录的值的计数。
|
int |
getMax()
返回记录的最大值,如果没有记录值,则返回
Integer.MIN_VALUE 。
|
int |
getMin()
返回记录的最小值,如果没有记录值,则返回
Integer.MAX_VALUE 。
|
long |
getSum()
返回记录的值的总和,如果没有记录值,则返回零。
|
String |
toString()
返回对象的字符串表示形式。
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitandThenpublic IntSummaryStatistics()
Integer.MAX_VALUE分钟,
Integer.MIN_VALUE最大和零平均值构造一个空实例。
public void accept(int value)
accept在界面
IntConsumer
value - 输入值
public void combine(IntSummaryStatistics other)
IntSummaryStatistics的状态
IntSummaryStatistics到一个。
other - 另一个
IntSummaryStatistics
NullPointerException - 如果
other为空
public final long getCount()
public final long getSum()
public final int getMin()
Integer.MAX_VALUE 。
Integer.MAX_VALUE如果没有
public final int getMax()
Integer.MIN_VALUE 。
Integer.MIN_VALUE如果没有
public final double getAverage()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.