package p040n; import java.util.Arrays; import p040n.C1479b; /* renamed from: n.j */ /* loaded from: classes.dex */ public class C1493j implements C1479b.InterfaceC1480a { /* renamed from: n */ public static float f3312n = 0.001f; /* renamed from: a */ public final int f3313a = -1; /* renamed from: b */ public int f3314b = 16; /* renamed from: c */ public int f3315c = 16; /* renamed from: d */ public int[] f3316d = new int[16]; /* renamed from: e */ public int[] f3317e = new int[16]; /* renamed from: f */ public int[] f3318f = new int[16]; /* renamed from: g */ public float[] f3319g = new float[16]; /* renamed from: h */ public int[] f3320h = new int[16]; /* renamed from: i */ public int[] f3321i = new int[16]; /* renamed from: j */ public int f3322j = 0; /* renamed from: k */ public int f3323k = -1; /* renamed from: l */ public final C1479b f3324l; /* renamed from: m */ public final C1481c f3325m; public C1493j(C1479b c1479b, C1481c c1481c) { this.f3324l = c1479b; this.f3325m = c1481c; clear(); } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: a */ public float mo1189a(int i) { int i2 = this.f3322j; int i3 = this.f3323k; for (int i4 = 0; i4 < i2; i4++) { if (i4 == i) { return this.f3319g[i3]; } i3 = this.f3321i[i3]; if (i3 == -1) { return 0.0f; } } return 0.0f; } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: b */ public float mo1188b(C1491i c1491i) { int m1174p = m1174p(c1491i); if (m1174p != -1) { return this.f3319g[m1174p]; } return 0.0f; } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: c */ public void mo1187c(C1491i c1491i, float f, boolean z) { float f2 = f3312n; if (f <= (-f2) || f >= f2) { int m1174p = m1174p(c1491i); if (m1174p == -1) { mo1183g(c1491i, f); return; } float[] fArr = this.f3319g; float f3 = fArr[m1174p] + f; fArr[m1174p] = f3; float f4 = f3312n; if (f3 <= (-f4) || f3 >= f4) { return; } fArr[m1174p] = 0.0f; mo1181i(c1491i, z); } } @Override // p040n.C1479b.InterfaceC1480a public void clear() { int i = this.f3322j; for (int i2 = 0; i2 < i; i2++) { C1491i mo1184f = mo1184f(i2); if (mo1184f != null) { mo1184f.m1194d(this.f3324l); } } for (int i3 = 0; i3 < this.f3314b; i3++) { this.f3318f[i3] = -1; this.f3317e[i3] = -1; } for (int i4 = 0; i4 < this.f3315c; i4++) { this.f3316d[i4] = -1; } this.f3322j = 0; this.f3323k = -1; } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: d */ public float mo1186d(C1479b c1479b, boolean z) { float mo1188b = mo1188b(c1479b.f3240a); mo1181i(c1479b.f3240a, z); C1493j c1493j = (C1493j) c1479b.f3244e; int mo1179k = c1493j.mo1179k(); int i = 0; int i2 = 0; while (i < mo1179k) { int i3 = c1493j.f3318f[i2]; if (i3 != -1) { mo1187c(this.f3325m.f3249d[i3], c1493j.f3319g[i2] * mo1188b, z); i++; } i2++; } return mo1188b; } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: e */ public boolean mo1185e(C1491i c1491i) { return m1174p(c1491i) != -1; } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: f */ public C1491i mo1184f(int i) { int i2 = this.f3322j; if (i2 == 0) { return null; } int i3 = this.f3323k; for (int i4 = 0; i4 < i2; i4++) { if (i4 == i && i3 != -1) { return this.f3325m.f3249d[this.f3318f[i3]]; } i3 = this.f3321i[i3]; if (i3 == -1) { break; } } return null; } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: g */ public void mo1183g(C1491i c1491i, float f) { float f2 = f3312n; if (f > (-f2) && f < f2) { mo1181i(c1491i, true); return; } if (this.f3322j == 0) { m1177m(0, c1491i, f); m1178l(c1491i, 0); this.f3323k = 0; return; } int m1174p = m1174p(c1491i); if (m1174p != -1) { this.f3319g[m1174p] = f; return; } if (this.f3322j + 1 >= this.f3314b) { m1175o(); } int i = this.f3322j; int i2 = this.f3323k; int i3 = -1; for (int i4 = 0; i4 < i; i4++) { int i5 = this.f3318f[i2]; int i6 = c1491i.f3291f; if (i5 == i6) { this.f3319g[i2] = f; return; } if (i5 < i6) { i3 = i2; } i2 = this.f3321i[i2]; if (i2 == -1) { break; } } m1173q(i3, c1491i, f); } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: h */ public void mo1182h(float f) { int i = this.f3322j; int i2 = this.f3323k; for (int i3 = 0; i3 < i; i3++) { float[] fArr = this.f3319g; fArr[i2] = fArr[i2] / f; i2 = this.f3321i[i2]; if (i2 == -1) { return; } } } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: i */ public float mo1181i(C1491i c1491i, boolean z) { int m1174p = m1174p(c1491i); if (m1174p == -1) { return 0.0f; } m1172r(c1491i); float f = this.f3319g[m1174p]; if (this.f3323k == m1174p) { this.f3323k = this.f3321i[m1174p]; } this.f3318f[m1174p] = -1; int[] iArr = this.f3320h; int i = iArr[m1174p]; if (i != -1) { int[] iArr2 = this.f3321i; iArr2[i] = iArr2[m1174p]; } int i2 = this.f3321i[m1174p]; if (i2 != -1) { iArr[i2] = iArr[m1174p]; } this.f3322j--; c1491i.f3301p--; if (z) { c1491i.m1194d(this.f3324l); } return f; } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: j */ public void mo1180j() { int i = this.f3322j; int i2 = this.f3323k; for (int i3 = 0; i3 < i; i3++) { float[] fArr = this.f3319g; fArr[i2] = fArr[i2] * (-1.0f); i2 = this.f3321i[i2]; if (i2 == -1) { return; } } } @Override // p040n.C1479b.InterfaceC1480a /* renamed from: k */ public int mo1179k() { return this.f3322j; } /* renamed from: l */ public final void m1178l(C1491i c1491i, int i) { int[] iArr; int i2 = c1491i.f3291f % this.f3315c; int[] iArr2 = this.f3316d; int i3 = iArr2[i2]; if (i3 == -1) { iArr2[i2] = i; } else { while (true) { iArr = this.f3317e; int i4 = iArr[i3]; if (i4 == -1) { break; } i3 = i4; } iArr[i3] = i; } this.f3317e[i] = -1; } /* renamed from: m */ public final void m1177m(int i, C1491i c1491i, float f) { this.f3318f[i] = c1491i.f3291f; this.f3319g[i] = f; this.f3320h[i] = -1; this.f3321i[i] = -1; c1491i.m1197a(this.f3324l); c1491i.f3301p++; this.f3322j++; } /* renamed from: n */ public final int m1176n() { for (int i = 0; i < this.f3314b; i++) { if (this.f3318f[i] == -1) { return i; } } return -1; } /* renamed from: o */ public final void m1175o() { int i = this.f3314b * 2; this.f3318f = Arrays.copyOf(this.f3318f, i); this.f3319g = Arrays.copyOf(this.f3319g, i); this.f3320h = Arrays.copyOf(this.f3320h, i); this.f3321i = Arrays.copyOf(this.f3321i, i); this.f3317e = Arrays.copyOf(this.f3317e, i); for (int i2 = this.f3314b; i2 < i; i2++) { this.f3318f[i2] = -1; this.f3317e[i2] = -1; } this.f3314b = i; } /* renamed from: p */ public int m1174p(C1491i c1491i) { if (this.f3322j != 0 && c1491i != null) { int i = c1491i.f3291f; int i2 = this.f3316d[i % this.f3315c]; if (i2 == -1) { return -1; } if (this.f3318f[i2] == i) { return i2; } do { i2 = this.f3317e[i2]; if (i2 == -1) { break; } } while (this.f3318f[i2] != i); if (i2 != -1 && this.f3318f[i2] == i) { return i2; } } return -1; } /* renamed from: q */ public final void m1173q(int i, C1491i c1491i, float f) { int m1176n = m1176n(); m1177m(m1176n, c1491i, f); if (i != -1) { this.f3320h[m1176n] = i; int[] iArr = this.f3321i; iArr[m1176n] = iArr[i]; iArr[i] = m1176n; } else { this.f3320h[m1176n] = -1; if (this.f3322j > 0) { this.f3321i[m1176n] = this.f3323k; this.f3323k = m1176n; } else { this.f3321i[m1176n] = -1; } } int i2 = this.f3321i[m1176n]; if (i2 != -1) { this.f3320h[i2] = m1176n; } m1178l(c1491i, m1176n); } /* renamed from: r */ public final void m1172r(C1491i c1491i) { int[] iArr; int i; int i2 = c1491i.f3291f; int i3 = i2 % this.f3315c; int[] iArr2 = this.f3316d; int i4 = iArr2[i3]; if (i4 == -1) { return; } if (this.f3318f[i4] == i2) { int[] iArr3 = this.f3317e; iArr2[i3] = iArr3[i4]; iArr3[i4] = -1; return; } while (true) { iArr = this.f3317e; i = iArr[i4]; if (i == -1 || this.f3318f[i] == i2) { break; } i4 = i; } if (i == -1 || this.f3318f[i] != i2) { return; } iArr[i4] = iArr[i]; iArr[i] = -1; } public String toString() { StringBuilder sb; String str = hashCode() + " { "; int i = this.f3322j; for (int i2 = 0; i2 < i; i2++) { C1491i mo1184f = mo1184f(i2); if (mo1184f != null) { String str2 = str + mo1184f + " = " + mo1189a(i2) + " "; int m1174p = m1174p(mo1184f); String str3 = str2 + "[p: "; if (this.f3320h[m1174p] != -1) { sb = new StringBuilder(); sb.append(str3); sb.append(this.f3325m.f3249d[this.f3318f[this.f3320h[m1174p]]]); } else { sb = new StringBuilder(); sb.append(str3); sb.append("none"); } String str4 = sb.toString() + ", n: "; str = (this.f3321i[m1174p] != -1 ? str4 + this.f3325m.f3249d[this.f3318f[this.f3321i[m1174p]]] : str4 + "none") + "]"; } } return str + " }"; } }