package u;

import java.util.Arrays;

/* JADX INFO: renamed from: u.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1027a {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C1028b f10006b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final B2.a f10007c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f10005a = 0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f10008d = 8;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int[] f10009e = new int[8];

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int[] f10010f = new int[8];

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public float[] f10011g = new float[8];

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f10012h = -1;
    public int i = -1;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public boolean f10013j = false;

    public C1027a(C1028b c1028b, B2.a aVar) {
        this.f10006b = c1028b;
        this.f10007c = aVar;
    }

    public final void a(f fVar, float f6, boolean z5) {
        if (f6 <= -0.001f || f6 >= 0.001f) {
            int i = this.f10012h;
            C1028b c1028b = this.f10006b;
            if (i == -1) {
                this.f10012h = 0;
                this.f10011g[0] = f6;
                this.f10009e[0] = fVar.f10038l;
                this.f10010f[0] = -1;
                fVar.f10045u++;
                fVar.a(c1028b);
                this.f10005a++;
                if (this.f10013j) {
                    return;
                }
                int i5 = this.i + 1;
                this.i = i5;
                int[] iArr = this.f10009e;
                if (i5 >= iArr.length) {
                    this.f10013j = true;
                    this.i = iArr.length - 1;
                    return;
                }
                return;
            }
            int i6 = -1;
            for (int i7 = 0; i != -1 && i7 < this.f10005a; i7++) {
                int i8 = this.f10009e[i];
                int i9 = fVar.f10038l;
                if (i8 == i9) {
                    float[] fArr = this.f10011g;
                    float f7 = fArr[i] + f6;
                    if (f7 > -0.001f && f7 < 0.001f) {
                        f7 = 0.0f;
                    }
                    fArr[i] = f7;
                    if (f7 == 0.0f) {
                        if (i == this.f10012h) {
                            this.f10012h = this.f10010f[i];
                        } else {
                            int[] iArr2 = this.f10010f;
                            iArr2[i6] = iArr2[i];
                        }
                        if (z5) {
                            fVar.b(c1028b);
                        }
                        if (this.f10013j) {
                            this.i = i;
                        }
                        fVar.f10045u--;
                        this.f10005a--;
                        return;
                    }
                    return;
                }
                if (i8 < i9) {
                    i6 = i;
                }
                i = this.f10010f[i];
            }
            int length = this.i;
            int i10 = length + 1;
            if (this.f10013j) {
                int[] iArr3 = this.f10009e;
                if (iArr3[length] != -1) {
                    length = iArr3.length;
                }
            } else {
                length = i10;
            }
            int[] iArr4 = this.f10009e;
            if (length >= iArr4.length && this.f10005a < iArr4.length) {
                int i11 = 0;
                while (true) {
                    int[] iArr5 = this.f10009e;
                    if (i11 >= iArr5.length) {
                        break;
                    }
                    if (iArr5[i11] == -1) {
                        length = i11;
                        break;
                    }
                    i11++;
                }
            }
            int[] iArr6 = this.f10009e;
            if (length >= iArr6.length) {
                length = iArr6.length;
                int i12 = this.f10008d * 2;
                this.f10008d = i12;
                this.f10013j = false;
                this.i = length - 1;
                this.f10011g = Arrays.copyOf(this.f10011g, i12);
                this.f10009e = Arrays.copyOf(this.f10009e, this.f10008d);
                this.f10010f = Arrays.copyOf(this.f10010f, this.f10008d);
            }
            this.f10009e[length] = fVar.f10038l;
            this.f10011g[length] = f6;
            if (i6 != -1) {
                int[] iArr7 = this.f10010f;
                iArr7[length] = iArr7[i6];
                iArr7[i6] = length;
            } else {
                this.f10010f[length] = this.f10012h;
                this.f10012h = length;
            }
            fVar.f10045u++;
            fVar.a(c1028b);
            this.f10005a++;
            if (!this.f10013j) {
                this.i++;
            }
            int i13 = this.i;
            int[] iArr8 = this.f10009e;
            if (i13 >= iArr8.length) {
                this.f10013j = true;
                this.i = iArr8.length - 1;
            }
        }
    }

    public final void b() {
        int i = this.f10012h;
        for (int i5 = 0; i != -1 && i5 < this.f10005a; i5++) {
            f fVar = ((f[]) this.f10007c.f134l)[this.f10009e[i]];
            if (fVar != null) {
                fVar.b(this.f10006b);
            }
            i = this.f10010f[i];
        }
        this.f10012h = -1;
        this.i = -1;
        this.f10013j = false;
        this.f10005a = 0;
    }

    public final float c(f fVar) {
        int i = this.f10012h;
        for (int i5 = 0; i != -1 && i5 < this.f10005a; i5++) {
            if (this.f10009e[i] == fVar.f10038l) {
                return this.f10011g[i];
            }
            i = this.f10010f[i];
        }
        return 0.0f;
    }

    public final int d() {
        return this.f10005a;
    }

    public final f e(int i) {
        int i5 = this.f10012h;
        for (int i6 = 0; i5 != -1 && i6 < this.f10005a; i6++) {
            if (i6 == i) {
                return ((f[]) this.f10007c.f134l)[this.f10009e[i5]];
            }
            i5 = this.f10010f[i5];
        }
        return null;
    }

    public final float f(int i) {
        int i5 = this.f10012h;
        for (int i6 = 0; i5 != -1 && i6 < this.f10005a; i6++) {
            if (i6 == i) {
                return this.f10011g[i5];
            }
            i5 = this.f10010f[i5];
        }
        return 0.0f;
    }

    public final void g(f fVar, float f6) {
        if (f6 == 0.0f) {
            h(fVar, true);
            return;
        }
        int i = this.f10012h;
        C1028b c1028b = this.f10006b;
        if (i == -1) {
            this.f10012h = 0;
            this.f10011g[0] = f6;
            this.f10009e[0] = fVar.f10038l;
            this.f10010f[0] = -1;
            fVar.f10045u++;
            fVar.a(c1028b);
            this.f10005a++;
            if (this.f10013j) {
                return;
            }
            int i5 = this.i + 1;
            this.i = i5;
            int[] iArr = this.f10009e;
            if (i5 >= iArr.length) {
                this.f10013j = true;
                this.i = iArr.length - 1;
                return;
            }
            return;
        }
        int i6 = -1;
        for (int i7 = 0; i != -1 && i7 < this.f10005a; i7++) {
            int i8 = this.f10009e[i];
            int i9 = fVar.f10038l;
            if (i8 == i9) {
                this.f10011g[i] = f6;
                return;
            }
            if (i8 < i9) {
                i6 = i;
            }
            i = this.f10010f[i];
        }
        int length = this.i;
        int i10 = length + 1;
        if (this.f10013j) {
            int[] iArr2 = this.f10009e;
            if (iArr2[length] != -1) {
                length = iArr2.length;
            }
        } else {
            length = i10;
        }
        int[] iArr3 = this.f10009e;
        if (length >= iArr3.length && this.f10005a < iArr3.length) {
            int i11 = 0;
            while (true) {
                int[] iArr4 = this.f10009e;
                if (i11 >= iArr4.length) {
                    break;
                }
                if (iArr4[i11] == -1) {
                    length = i11;
                    break;
                }
                i11++;
            }
        }
        int[] iArr5 = this.f10009e;
        if (length >= iArr5.length) {
            length = iArr5.length;
            int i12 = this.f10008d * 2;
            this.f10008d = i12;
            this.f10013j = false;
            this.i = length - 1;
            this.f10011g = Arrays.copyOf(this.f10011g, i12);
            this.f10009e = Arrays.copyOf(this.f10009e, this.f10008d);
            this.f10010f = Arrays.copyOf(this.f10010f, this.f10008d);
        }
        this.f10009e[length] = fVar.f10038l;
        this.f10011g[length] = f6;
        if (i6 != -1) {
            int[] iArr6 = this.f10010f;
            iArr6[length] = iArr6[i6];
            iArr6[i6] = length;
        } else {
            this.f10010f[length] = this.f10012h;
            this.f10012h = length;
        }
        fVar.f10045u++;
        fVar.a(c1028b);
        int i13 = this.f10005a + 1;
        this.f10005a = i13;
        if (!this.f10013j) {
            this.i++;
        }
        int[] iArr7 = this.f10009e;
        if (i13 >= iArr7.length) {
            this.f10013j = true;
        }
        if (this.i >= iArr7.length) {
            this.f10013j = true;
            this.i = iArr7.length - 1;
        }
    }

    public final float h(f fVar, boolean z5) {
        int i = this.f10012h;
        if (i == -1) {
            return 0.0f;
        }
        int i5 = 0;
        int i6 = -1;
        while (i != -1 && i5 < this.f10005a) {
            if (this.f10009e[i] == fVar.f10038l) {
                if (i == this.f10012h) {
                    this.f10012h = this.f10010f[i];
                } else {
                    int[] iArr = this.f10010f;
                    iArr[i6] = iArr[i];
                }
                if (z5) {
                    fVar.b(this.f10006b);
                }
                fVar.f10045u--;
                this.f10005a--;
                this.f10009e[i] = -1;
                if (this.f10013j) {
                    this.i = i;
                }
                return this.f10011g[i];
            }
            i5++;
            i6 = i;
            i = this.f10010f[i];
        }
        return 0.0f;
    }

    public final String toString() {
        int i = this.f10012h;
        String string = "";
        for (int i5 = 0; i != -1 && i5 < this.f10005a; i5++) {
            StringBuilder sbB = e.b(s0.c.c(string, " -> "));
            sbB.append(this.f10011g[i]);
            sbB.append(" : ");
            StringBuilder sbB2 = e.b(sbB.toString());
            sbB2.append(((f[]) this.f10007c.f134l)[this.f10009e[i]]);
            string = sbB2.toString();
            i = this.f10010f[i];
        }
        return string;
    }
}
