package com.google.common.math; import com.google.common.primitives.Doubles; import java.util.Iterator; /* loaded from: classes.dex */ public final class StatsAccumulator { private long a = 0; private double b = 0.0d; private double c = 0.0d; private double d = Double.NaN; private double e = Double.NaN; public void a(double d) { long j = this.a; if (j == 0) { this.a = 1L; this.b = d; this.d = d; this.e = d; if (Doubles.b(d)) { return; } this.c = Double.NaN; return; } this.a = j + 1; if (Doubles.b(d) && Doubles.b(this.b)) { double d2 = this.b; double d3 = d - d2; this.b = d2 + (d3 / this.a); this.c += d3 * (d - this.b); } else { this.b = a(this.b, d); this.c = Double.NaN; } this.d = Math.min(this.d, d); this.e = Math.max(this.e, d); } public void a(Iterable iterable) { Iterator it = iterable.iterator(); while (it.hasNext()) { a(it.next().doubleValue()); } } public void a(Iterator it) { while (it.hasNext()) { a(it.next().doubleValue()); } } public void a(double... dArr) { for (double d : dArr) { a(d); } } public void a(int... iArr) { for (int i : iArr) { a(i); } } public void a(long... jArr) { for (long j : jArr) { a(j); } } public Stats a() { return new Stats(this.a, this.b, this.c, this.d, this.e); } static double a(double d, double d2) { if (Doubles.b(d)) { return d2; } if (Doubles.b(d2) || d == d2) { return d; } return Double.NaN; } }