public class IntSummaryStatistics extends Object implements IntConsumer
这类设计的工作(但不要求)streams。例如,你可以计算汇总统计一个流对象与:
IntSummaryStatistics stats = intStream.collect(IntSummaryStatistics::new,
IntSummaryStatistics::accept,
IntSummaryStatistics::combine);
IntSummaryStatistics
可以作为一个stream一reduction目标。例如:
IntSummaryStatistics stats = people.stream()
.collect(Collectors.summarizingInt(Person::getDependents));
计算,通过在一个单一的,人的数量,以及最小,最大,和,和他们的家属人数平均。
Collectors.toIntStatistics()
在平行流,因为
Stream.collect()
并行实现提供了必要的分割,分离与融合的安全和高效的并行执行的结果。
此实现不检查溢出的总和。
Constructor and Description |
---|
IntSummaryStatistics()
构造一个空的实例计数为零,零和的,
Integer.MAX_VALUE min,max和零均值
Integer.MIN_VALUE 。
|
Modifier and Type | Method and Description |
---|---|
void |
accept(int value)
将一个新的值记录到汇总信息中
|
void |
combine(IntSummaryStatistics other)
结合另一个
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, wait
andThen
public IntSummaryStatistics()
Integer.MAX_VALUE
min,max和零均值
Integer.MIN_VALUE
。
public void accept(int value)
accept
接口
IntConsumer
value
-输入值
public void combine(IntSummaryStatistics other)
IntSummaryStatistics
状态进入这一。
IntSummaryStatistics
other
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.