IntSummaryStatistics
open class IntSummaryStatistics : IntConsumer
kotlin.Any | |
↳ | java.util.IntSummaryStatistics |
A state object for collecting statistics such as count, min, max, sum, and average.
This class is designed to work with (though does not require) streams. For example, you can compute summary statistics on a stream of ints with:
<code>IntSummaryStatistics stats = intStream.collect(IntSummaryStatistics::new, IntSummaryStatistics::accept, IntSummaryStatistics::combine); </code>
IntSummaryStatistics
can be used as a reduction target for a stream. For example:
<code>IntSummaryStatistics stats = people.stream() .collect(Collectors.summarizingInt(Person::getDependents)); </code>
Summary
Public constructors | |
---|---|
Constructs an empty instance with zero count, zero sum, |
|
IntSummaryStatistics(count: Long, min: Int, max: Int, sum: Long) Constructs a non-empty instance with the specified |
Public methods | |
---|---|
open Unit |
Records a new value into the summary information |
open Unit |
combine(other: IntSummaryStatistics!) Combines the state of another |
Double |
Returns the arithmetic mean of values recorded, or zero if no values have been recorded. |
Long |
getCount() Returns the count of values recorded. |
Int |
getMax() Returns the maximum value recorded, or |
Int |
getMin() Returns the minimum value recorded, or |
Long |
getSum() Returns the sum of values recorded, or zero if no values have been recorded. |
open String |
toString() Returns a non-empty string representation of this object suitable for debugging. |
Inherited functions | |
---|---|
Public constructors
IntSummaryStatistics
IntSummaryStatistics()
Constructs an empty instance with zero count, zero sum, Integer.MAX_VALUE
min, Integer.MIN_VALUE
max and zero average.
IntSummaryStatistics
IntSummaryStatistics(
count: Long,
min: Int,
max: Int,
sum: Long)
Constructs a non-empty instance with the specified count
, min
, max
, and sum
.
If count
is zero then the remaining arguments are ignored and an empty instance is constructed.
If the arguments are inconsistent then an IllegalArgumentException
is thrown. The necessary consistent argument conditions are:
count >= 0
min <= max
Parameters | |
---|---|
count |
Long: the count of values |
min |
Int: the minimum value |
max |
Int: the maximum value |
sum |
Long: the sum of all values |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the arguments are inconsistent |
Public methods
accept
open fun accept(value: Int): Unit
Records a new value into the summary information
Parameters | |
---|---|
value |
Int: the input value |
combine
open fun combine(other: IntSummaryStatistics!): Unit
Combines the state of another IntSummaryStatistics
into this one.
Parameters | |
---|---|
other |
IntSummaryStatistics!: another IntSummaryStatistics |
Exceptions | |
---|---|
java.lang.NullPointerException |
if other is null |
getAverage
fun getAverage(): Double
Returns the arithmetic mean of values recorded, or zero if no values have been recorded.
Return | |
---|---|
Double |
the arithmetic mean of values, or zero if none |
getCount
fun getCount(): Long
Returns the count of values recorded.
Return | |
---|---|
Long |
the count of values |
getMax
fun getMax(): Int
Returns the maximum value recorded, or Integer.MIN_VALUE
if no values have been recorded.
Return | |
---|---|
Int |
the maximum value, or Integer.MIN_VALUE if none |
getMin
fun getMin(): Int
Returns the minimum value recorded, or Integer.MAX_VALUE
if no values have been recorded.
Return | |
---|---|
Int |
the minimum value, or Integer.MAX_VALUE if none |
getSum
fun getSum(): Long
Returns the sum of values recorded, or zero if no values have been recorded.
Return | |
---|---|
Long |
the sum of values, or zero if none |
toString
open fun toString(): String
Returns a non-empty string representation of this object suitable for debugging. The exact presentation format is unspecified and may vary between implementations and versions.
Return | |
---|---|
String |
a string representation of the object. |