# averagingDouble<T> static method

Collector<T, InternalDoubleSummaryStatistics, double> averagingDouble<T>(

1. double mapper(
   1. T
   )

)

Returns a Collector that produces the arithmetic mean of double-valued functions applied to the input elements.

## Example

    final averageAmount = transactions.stream()
        .collect(Collectors.averagingDouble((t) => t.amount));

Implementations of Collector that implement various useful reduction operations, such as accumulating elements into collections, summarizing elements according to various criteria, etc.

The following are examples of using the predefined collectors to perform common mutable reduction tasks:

    // Accumulate names into a List
    final list = people.stream()
        .map((p) => p.name)
        .collect(Collectors.toList());

    // Accumulate names into a Set
    final set = people.stream()
        .map((p) => p.name)
        .collect(Collectors.toSet());

    // Convert elements to strings and concatenate them, separated by commas
    final joined = things.stream()
        .map((t) => t.toString())
        .collect(Collectors.joining(', '));

    // Compute sum of salaries of employee
    final total = employees.stream()
        .collect(Collectors.summingInt((e) => e.salary));

    // Group employees by department
    final byDept = employees.stream()
        .collect(Collectors.groupingBy((e) => e.department));

    // Compute sum of salaries by department
    final totalByDept = employees.stream()
        .collect(Collectors.groupingBy(
            (e) => e.department,
            Collectors.summingInt((e) => e.salary)));

    // Partition students into passing and failing
    final passingFailing = students.stream()
        .collect(Collectors.partitioningBy((s) => s.grade >= 60));

## Implementation

    static Collector<T, InternalDoubleSummaryStatistics, double> averagingDouble<T>(double Function(T) mapper) {
      return Collector<T, InternalDoubleSummaryStatistics, double>(
        supplier: () => InternalDoubleSummaryStatistics(),
        accumulator: (stats, element) => stats.accept(mapper(element)),
        combiner: (stats1, stats2) => stats1.combine(stats2),
        finisher: (stats) => stats.average,
      );
    }