discord-jadx/app/src/main/java/c/i/a/c/i2/z.java

106 lines
2.6 KiB
Java

package c.i.a.c.i2;
import java.util.ArrayList;
import java.util.Collections;
/* compiled from: SlidingPercentile */
public class z {
public static final /* synthetic */ int a = 0;
public final int b;
/* renamed from: c reason: collision with root package name */
public final ArrayList<b> f915c = new ArrayList<>();
public final b[] d = new b[5];
public int e = -1;
public int f;
public int g;
public int h;
/* compiled from: SlidingPercentile */
public static class b {
public int a;
public int b;
/* renamed from: c reason: collision with root package name */
public float f916c;
public b() {
}
public b(a aVar) {
}
}
public z(int i) {
this.b = i;
}
public void a(int i, float f) {
b bVar;
if (this.e != 1) {
Collections.sort(this.f915c, c.i);
this.e = 1;
}
int i2 = this.h;
if (i2 > 0) {
b[] bVarArr = this.d;
int i3 = i2 - 1;
this.h = i3;
bVar = bVarArr[i3];
} else {
bVar = new b(null);
}
int i4 = this.f;
this.f = i4 + 1;
bVar.a = i4;
bVar.b = i;
bVar.f916c = f;
this.f915c.add(bVar);
this.g += i;
while (true) {
int i5 = this.g;
int i6 = this.b;
if (i5 > i6) {
int i7 = i5 - i6;
b bVar2 = this.f915c.get(0);
int i8 = bVar2.b;
if (i8 <= i7) {
this.g -= i8;
this.f915c.remove(0);
int i9 = this.h;
if (i9 < 5) {
b[] bVarArr2 = this.d;
this.h = i9 + 1;
bVarArr2[i9] = bVar2;
}
} else {
bVar2.b = i8 - i7;
this.g -= i7;
}
} else {
return;
}
}
}
public float b(float f) {
if (this.e != 0) {
Collections.sort(this.f915c, d.i);
this.e = 0;
}
float f2 = f * ((float) this.g);
int i = 0;
for (int i2 = 0; i2 < this.f915c.size(); i2++) {
b bVar = this.f915c.get(i2);
i += bVar.b;
if (((float) i) >= f2) {
return bVar.f916c;
}
}
if (this.f915c.isEmpty()) {
return Float.NaN;
}
ArrayList<b> arrayList = this.f915c;
return arrayList.get(arrayList.size() - 1).f916c;
}
}