src/share/classes/java/util/LongSummaryStatistics.java

Print this page
rev 7597 : 8015318: Extend Collector with 'finish' operation
Reviewed-by:
Contributed-by: brian.goetz@oracle.com

*** 44,61 **** * {@linkplain java.util.stream.Stream#reduce(java.util.function.BinaryOperator) reduction} * target for a {@linkplain java.util.stream.Stream stream}. For example: * * <pre> {@code * LongSummaryStatistics stats = people.stream() ! * .collect(Collectors.toLongSummaryStatistics(Person::getAge)); *}</pre> * * This computes, in a single pass, the count of people, as well as the minimum, * maximum, sum, and average of their ages in milliseconds. * * @implNote This implementation is not thread safe. However, it is safe to use ! * {@link java.util.stream.Collectors#toLongSummaryStatistics(java.util.function.ToLongFunction) * Collectors.toLongStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for * safe and efficient parallel execution. * --- 44,61 ---- * {@linkplain java.util.stream.Stream#reduce(java.util.function.BinaryOperator) reduction} * target for a {@linkplain java.util.stream.Stream stream}. For example: * * <pre> {@code * LongSummaryStatistics stats = people.stream() ! * .collect(Collectors.summarizingLong(Person::getAge)); *}</pre> * * This computes, in a single pass, the count of people, as well as the minimum, * maximum, sum, and average of their ages in milliseconds. * * @implNote This implementation is not thread safe. However, it is safe to use ! * {@link java.util.stream.Collectors#summarizingLong(java.util.function.ToLongFunction) * Collectors.toLongStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for * safe and efficient parallel execution. *