LongSummaryStatistics

public class LongSummaryStatistics extends Object
implements LongConsumer IntConsumer

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) {@linkplain java.util.stream streams}. For example, you can compute summary statistics on a stream of longs with:

 LongSummaryStatistics stats = longStream.collect(LongSummaryStatistics::new,
                                                  LongSummaryStatistics::accept,
                                                  LongSummaryStatistics::combine);
 

LongSummaryStatistics can be used as a {@linkplain java.util.stream.Stream#collect(Collector)} reduction} target for a {@linkplain java.util.stream.Stream stream}. For example:

 LongSummaryStatistics stats = people.stream()
                                     .collect(Collectors.summarizingLong(Person::getAge));
This computes, in a single pass, the count of people, as well as the minimum, maximum, sum, and average of their ages.

Public Constructor Summary

LongSummaryStatistics()
Construct an empty instance with zero count, zero sum, Long.MAX_VALUE min, Long.MIN_VALUE max and zero average.

Public Method Summary

void
accept(int value)
Records a new int value into the summary information.
void
accept(long value)
Records a new long value into the summary information.
void
combine(LongSummaryStatistics other)
Combines the state of another LongSummaryStatistics into this one.
final double
getAverage()
Returns the arithmetic mean of values recorded, or zero if no values have been recorded.
final long
getCount()
Returns the count of values recorded.
final long
getMax()
Returns the maximum value recorded, or Long.MIN_VALUE if no values have been recorded
final long
getMin()
Returns the minimum value recorded, or Long.MAX_VALUE if no values have been recorded.
final