package u;

import d5.AbstractC0844a;
import java.util.Arrays;

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

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

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

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

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

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

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

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

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

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

    public C1556a(C1558c c1558c, C2.a aVar) {
        this.f17043b = c1558c;
        this.f17044c = aVar;
    }

    @Override // u.InterfaceC1557b
    public final float a(int i) {
        int i5 = this.f17049h;
        for (int i8 = 0; i5 != -1 && i8 < this.f17042a; i8++) {
            if (i8 == i) {
                return this.f17048g[i5];
            }
            i5 = this.f17047f[i5];
        }
        return 0.0f;
    }

    @Override // u.InterfaceC1557b
    public final boolean b(i iVar) {
        int i = this.f17049h;
        if (i != -1) {
            for (int i5 = 0; i != -1 && i5 < this.f17042a; i5++) {
                if (this.f17046e[i] == iVar.f17078b) {
                    return true;
                }
                i = this.f17047f[i];
            }
        }
        return false;
    }

    @Override // u.InterfaceC1557b
    public final void c(i iVar, float f3, boolean z8) {
        if (f3 <= -0.001f || f3 >= 0.001f) {
            int i = this.f17049h;
            C1558c c1558c = this.f17043b;
            if (i == -1) {
                this.f17049h = 0;
                this.f17048g[0] = f3;
                this.f17046e[0] = iVar.f17078b;
                this.f17047f[0] = -1;
                iVar.f17086k++;
                iVar.a(c1558c);
                this.f17042a++;
                if (this.f17050j) {
                    return;
                }
                int i5 = this.i + 1;
                this.i = i5;
                int[] iArr = this.f17046e;
                if (i5 >= iArr.length) {
                    this.f17050j = true;
                    this.i = iArr.length - 1;
                    return;
                }
                return;
            }
            int i8 = -1;
            for (int i9 = 0; i != -1 && i9 < this.f17042a; i9++) {
                int i10 = this.f17046e[i];
                int i11 = iVar.f17078b;
                if (i10 == i11) {
                    float[] fArr = this.f17048g;
                    float f7 = fArr[i] + f3;
                    if (f7 > -0.001f && f7 < 0.001f) {
                        f7 = 0.0f;
                    }
                    fArr[i] = f7;
                    if (f7 == 0.0f) {
                        if (i == this.f17049h) {
                            this.f17049h = this.f17047f[i];
                        } else {
                            int[] iArr2 = this.f17047f;
                            iArr2[i8] = iArr2[i];
                        }
                        if (z8) {
                            iVar.b(c1558c);
                        }
                        if (this.f17050j) {
                            this.i = i;
                        }
                        iVar.f17086k--;
                        this.f17042a--;
                        return;
                    }
                    return;
                }
                if (i10 < i11) {
                    i8 = i;
                }
                i = this.f17047f[i];
            }
            int length = this.i;
            int i12 = length + 1;
            if (this.f17050j) {
                int[] iArr3 = this.f17046e;
                if (iArr3[length] != -1) {
                    length = iArr3.length;
                }
            } else {
                length = i12;
            }
            int[] iArr4 = this.f17046e;
            if (length >= iArr4.length && this.f17042a < iArr4.length) {
                int i13 = 0;
                while (true) {
                    int[] iArr5 = this.f17046e;
                    if (i13 >= iArr5.length) {
                        break;
                    }
                    if (iArr5[i13] == -1) {
                        length = i13;
                        break;
                    }
                    i13++;
                }
            }
            int[] iArr6 = this.f17046e;
            if (length >= iArr6.length) {
                length = iArr6.length;
                int i14 = this.f17045d * 2;
                this.f17045d = i14;
                this.f17050j = false;
                this.i = length - 1;
                this.f17048g = Arrays.copyOf(this.f17048g, i14);
                this.f17046e = Arrays.copyOf(this.f17046e, this.f17045d);
                this.f17047f = Arrays.copyOf(this.f17047f, this.f17045d);
            }
            this.f17046e[length] = iVar.f17078b;
            this.f17048g[length] = f3;
            if (i8 != -1) {
                int[] iArr7 = this.f17047f;
                iArr7[length] = iArr7[i8];
                iArr7[i8] = length;
            } else {
                this.f17047f[length] = this.f17049h;
                this.f17049h = length;
            }
            iVar.f17086k++;
            iVar.a(c1558c);
            this.f17042a++;
            if (!this.f17050j) {
                this.i++;
            }
            int i15 = this.i;
            int[] iArr8 = this.f17046e;
            if (i15 >= iArr8.length) {
                this.f17050j = true;
                this.i = iArr8.length - 1;
            }
        }
    }

    @Override // u.InterfaceC1557b
    public final void clear() {
        int i = this.f17049h;
        for (int i5 = 0; i != -1 && i5 < this.f17042a; i5++) {
            i iVar = ((i[]) this.f17044c.f1160u)[this.f17046e[i]];
            if (iVar != null) {
                iVar.b(this.f17043b);
            }
            i = this.f17047f[i];
        }
        this.f17049h = -1;
        this.i = -1;
        this.f17050j = false;
        this.f17042a = 0;
    }

    @Override // u.InterfaceC1557b
    public final float d(i iVar) {
        int i = this.f17049h;
        for (int i5 = 0; i != -1 && i5 < this.f17042a; i5++) {
            if (this.f17046e[i] == iVar.f17078b) {
                return this.f17048g[i];
            }
            i = this.f17047f[i];
        }
        return 0.0f;
    }

    @Override // u.InterfaceC1557b
    public final void e(i iVar, float f3) {
        if (f3 == 0.0f) {
            g(iVar, true);
            return;
        }
        int i = this.f17049h;
        C1558c c1558c = this.f17043b;
        if (i == -1) {
            this.f17049h = 0;
            this.f17048g[0] = f3;
            this.f17046e[0] = iVar.f17078b;
            this.f17047f[0] = -1;
            iVar.f17086k++;
            iVar.a(c1558c);
            this.f17042a++;
            if (this.f17050j) {
                return;
            }
            int i5 = this.i + 1;
            this.i = i5;
            int[] iArr = this.f17046e;
            if (i5 >= iArr.length) {
                this.f17050j = true;
                this.i = iArr.length - 1;
                return;
            }
            return;
        }
        int i8 = -1;
        for (int i9 = 0; i != -1 && i9 < this.f17042a; i9++) {
            int i10 = this.f17046e[i];
            int i11 = iVar.f17078b;
            if (i10 == i11) {
                this.f17048g[i] = f3;
                return;
            }
            if (i10 < i11) {
                i8 = i;
            }
            i = this.f17047f[i];
        }
        int length = this.i;
        int i12 = length + 1;
        if (this.f17050j) {
            int[] iArr2 = this.f17046e;
            if (iArr2[length] != -1) {
                length = iArr2.length;
            }
        } else {
            length = i12;
        }
        int[] iArr3 = this.f17046e;
        if (length >= iArr3.length && this.f17042a < iArr3.length) {
            int i13 = 0;
            while (true) {
                int[] iArr4 = this.f17046e;
                if (i13 >= iArr4.length) {
                    break;
                }
                if (iArr4[i13] == -1) {
                    length = i13;
                    break;
                }
                i13++;
            }
        }
        int[] iArr5 = this.f17046e;
        if (length >= iArr5.length) {
            length = iArr5.length;
            int i14 = this.f17045d * 2;
            this.f17045d = i14;
            this.f17050j = false;
            this.i = length - 1;
            this.f17048g = Arrays.copyOf(this.f17048g, i14);
            this.f17046e = Arrays.copyOf(this.f17046e, this.f17045d);
            this.f17047f = Arrays.copyOf(this.f17047f, this.f17045d);
        }
        this.f17046e[length] = iVar.f17078b;
        this.f17048g[length] = f3;
        if (i8 != -1) {
            int[] iArr6 = this.f17047f;
            iArr6[length] = iArr6[i8];
            iArr6[i8] = length;
        } else {
            this.f17047f[length] = this.f17049h;
            this.f17049h = length;
        }
        iVar.f17086k++;
        iVar.a(c1558c);
        int i15 = this.f17042a + 1;
        this.f17042a = i15;
        if (!this.f17050j) {
            this.i++;
        }
        int[] iArr7 = this.f17046e;
        if (i15 >= iArr7.length) {
            this.f17050j = true;
        }
        if (this.i >= iArr7.length) {
            this.f17050j = true;
            this.i = iArr7.length - 1;
        }
    }

    @Override // u.InterfaceC1557b
    public final i f(int i) {
        int i5 = this.f17049h;
        for (int i8 = 0; i5 != -1 && i8 < this.f17042a; i8++) {
            if (i8 == i) {
                return ((i[]) this.f17044c.f1160u)[this.f17046e[i5]];
            }
            i5 = this.f17047f[i5];
        }
        return null;
    }

    @Override // u.InterfaceC1557b
    public final float g(i iVar, boolean z8) {
        int i = this.f17049h;
        if (i == -1) {
            return 0.0f;
        }
        int i5 = 0;
        int i8 = -1;
        while (i != -1 && i5 < this.f17042a) {
            if (this.f17046e[i] == iVar.f17078b) {
                if (i == this.f17049h) {
                    this.f17049h = this.f17047f[i];
                } else {
                    int[] iArr = this.f17047f;
                    iArr[i8] = iArr[i];
                }
                if (z8) {
                    iVar.b(this.f17043b);
                }
                iVar.f17086k--;
                this.f17042a--;
                this.f17046e[i] = -1;
                if (this.f17050j) {
                    this.i = i;
                }
                return this.f17048g[i];
            }
            i5++;
            i8 = i;
            i = this.f17047f[i];
        }
        return 0.0f;
    }

    @Override // u.InterfaceC1557b
    public final void h(float f3) {
        int i = this.f17049h;
        for (int i5 = 0; i != -1 && i5 < this.f17042a; i5++) {
            float[] fArr = this.f17048g;
            fArr[i] = fArr[i] / f3;
            i = this.f17047f[i];
        }
    }

    @Override // u.InterfaceC1557b
    public final float i(C1558c c1558c, boolean z8) {
        float fD = d(c1558c.f17051a);
        g(c1558c.f17051a, z8);
        InterfaceC1557b interfaceC1557b = c1558c.f17054d;
        int iK = interfaceC1557b.k();
        for (int i = 0; i < iK; i++) {
            i iVarF = interfaceC1557b.f(i);
            c(iVarF, interfaceC1557b.d(iVarF) * fD, z8);
        }
        return fD;
    }

    @Override // u.InterfaceC1557b
    public final void j() {
        int i = this.f17049h;
        for (int i5 = 0; i != -1 && i5 < this.f17042a; i5++) {
            float[] fArr = this.f17048g;
            fArr[i] = fArr[i] * (-1.0f);
            i = this.f17047f[i];
        }
    }

    @Override // u.InterfaceC1557b
    public final int k() {
        return this.f17042a;
    }

    public final String toString() {
        int i = this.f17049h;
        String string = "";
        for (int i5 = 0; i != -1 && i5 < this.f17042a; i5++) {
            StringBuilder sbB = AbstractC1563h.b(AbstractC0844a.l(string, " -> "));
            sbB.append(this.f17048g[i]);
            sbB.append(" : ");
            StringBuilder sbB2 = AbstractC1563h.b(sbB.toString());
            sbB2.append(((i[]) this.f17044c.f1160u)[this.f17046e[i]]);
            string = sbB2.toString();
            i = this.f17047f[i];
        }
        return string;
    }
}
