mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-04 19:48:54 +01:00
83 lines
3.7 KiB
Java
83 lines
3.7 KiB
Java
package com.facebook.react.fabric;
|
|
|
|
import com.amazon.clouddrive.extended.model.BulkOperationType;
|
|
import com.amazon.mobile.heremapsexplore.Constants.ReactProperties;
|
|
import java.util.PriorityQueue;
|
|
import java.util.Queue;
|
|
import kotlin.Metadata;
|
|
import kotlin.comparisons.ComparisonsKt;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u0006\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0004\b\u0000\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u000e\u0010\u0012\u001a\u00020\u00132\u0006\u0010\u0014\u001a\u00020\u0006R\u0014\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0007\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u001e\u0010\n\u001a\u00020\t2\u0006\u0010\b\u001a\u00020\t@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR\u000e\u0010\r\u001a\u00020\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\u000f\u001a\u00020\u00062\u0006\u0010\b\u001a\u00020\u0006@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u0010\u0010\u0011R\u0011\u0010\u0015\u001a\u00020\t8F¢\u0006\u0006\u001a\u0004\b\u0016\u0010\f¨\u0006\u0017"}, d2 = {"Lcom/facebook/react/fabric/LongStreamingStats;", "", "<init>", "()V", "minHeap", "Ljava/util/Queue;", "", "maxHeap", "value", "", "average", "getAverage", "()D", "len", "", ReactProperties.GEOFENCE_MAXIMUM_RANGE, "getMax", "()J", BulkOperationType.add, "", "n", "median", "getMedian", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
|
|
/* loaded from: classes6.dex */
|
|
public final class LongStreamingStats {
|
|
private double average;
|
|
private int len;
|
|
private long max;
|
|
|
|
@NotNull
|
|
private final Queue<Long> minHeap = new PriorityQueue(11);
|
|
|
|
@NotNull
|
|
private final Queue<Long> maxHeap = new PriorityQueue(11, ComparisonsKt.reverseOrder());
|
|
|
|
public final void add(long n) {
|
|
double d;
|
|
if (n != 0) {
|
|
if (this.minHeap.size() == this.maxHeap.size()) {
|
|
this.maxHeap.offer(Long.valueOf(n));
|
|
this.minHeap.offer(this.maxHeap.poll());
|
|
} else {
|
|
this.minHeap.offer(Long.valueOf(n));
|
|
this.maxHeap.offer(this.minHeap.poll());
|
|
}
|
|
}
|
|
int i = this.len + 1;
|
|
this.len = i;
|
|
if (i == 1) {
|
|
d = n;
|
|
} else {
|
|
d = (n / i) + (this.average / (i / r0));
|
|
}
|
|
this.average = d;
|
|
long j = this.max;
|
|
if (n <= j) {
|
|
n = j;
|
|
}
|
|
this.max = n;
|
|
}
|
|
|
|
public final double getAverage() {
|
|
return this.average;
|
|
}
|
|
|
|
public final long getMax() {
|
|
return this.max;
|
|
}
|
|
|
|
public final double getMedian() {
|
|
long longValue;
|
|
Long valueOf;
|
|
if (this.minHeap.size() == 0 && this.maxHeap.size() == 0) {
|
|
return 0.0d;
|
|
}
|
|
int size = this.minHeap.size();
|
|
int size2 = this.maxHeap.size();
|
|
Queue<Long> queue = this.minHeap;
|
|
if (size > size2) {
|
|
valueOf = queue.peek();
|
|
} else {
|
|
Long peek = queue.peek();
|
|
if (peek != null) {
|
|
longValue = peek.longValue();
|
|
} else {
|
|
Long peek2 = this.maxHeap.peek();
|
|
peek2.getClass();
|
|
longValue = peek2.longValue();
|
|
}
|
|
valueOf = Long.valueOf(longValue / 2);
|
|
}
|
|
return valueOf.longValue();
|
|
}
|
|
}
|