package n;

import java.util.Arrays;
import o.AbstractC2628a;
import x4.AbstractC3250p;

/* JADX INFO: renamed from: n.t, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C2592t implements Cloneable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public /* synthetic */ boolean f21474a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public /* synthetic */ long[] f21475b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public /* synthetic */ Object[] f21476c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public /* synthetic */ int f21477d;

    public C2592t(int i6) {
        if (i6 == 0) {
            this.f21475b = AbstractC2628a.f21781b;
            this.f21476c = AbstractC2628a.f21782c;
            return;
        }
        int i7 = i6 * 8;
        int i8 = 4;
        while (true) {
            if (i8 >= 32) {
                break;
            }
            int i9 = (1 << i8) - 12;
            if (i7 <= i9) {
                i7 = i9;
                break;
            }
            i8++;
        }
        int i10 = i7 / 8;
        this.f21475b = new long[i10];
        this.f21476c = new Object[i10];
    }

    public final void a() {
        int i6 = this.f21477d;
        Object[] objArr = this.f21476c;
        for (int i7 = 0; i7 < i6; i7++) {
            objArr[i7] = null;
        }
        this.f21477d = 0;
        this.f21474a = false;
    }

    public final Object b(long j4) {
        Object obj;
        int iB = AbstractC2628a.b(this.f21475b, this.f21477d, j4);
        if (iB < 0 || (obj = this.f21476c[iB]) == AbstractC2593u.f21478a) {
            return null;
        }
        return obj;
    }

    public final int c(long j4) {
        if (this.f21474a) {
            int i6 = this.f21477d;
            long[] jArr = this.f21475b;
            Object[] objArr = this.f21476c;
            int i7 = 0;
            for (int i8 = 0; i8 < i6; i8++) {
                Object obj = objArr[i8];
                if (obj != AbstractC2593u.f21478a) {
                    if (i8 != i7) {
                        jArr[i7] = jArr[i8];
                        objArr[i7] = obj;
                        objArr[i8] = null;
                    }
                    i7++;
                }
            }
            this.f21474a = false;
            this.f21477d = i7;
        }
        return AbstractC2628a.b(this.f21475b, this.f21477d, j4);
    }

    public final Object clone() throws CloneNotSupportedException {
        Object objClone = super.clone();
        kotlin.jvm.internal.o.f(objClone, "null cannot be cast to non-null type androidx.collection.LongSparseArray<E of androidx.collection.LongSparseArray>");
        C2592t c2592t = (C2592t) objClone;
        c2592t.f21475b = (long[]) this.f21475b.clone();
        c2592t.f21476c = (Object[]) this.f21476c.clone();
        return c2592t;
    }

    public final long d(int i6) {
        if (!(i6 >= 0 && i6 < this.f21477d)) {
            AbstractC2628a.c("Expected index to be within 0..size()-1, but was " + i6);
            throw null;
        }
        if (this.f21474a) {
            int i7 = this.f21477d;
            long[] jArr = this.f21475b;
            Object[] objArr = this.f21476c;
            int i8 = 0;
            for (int i9 = 0; i9 < i7; i9++) {
                Object obj = objArr[i9];
                if (obj != AbstractC2593u.f21478a) {
                    if (i9 != i8) {
                        jArr[i8] = jArr[i9];
                        objArr[i8] = obj;
                        objArr[i9] = null;
                    }
                    i8++;
                }
            }
            this.f21474a = false;
            this.f21477d = i8;
        }
        return this.f21475b[i6];
    }

    public final void e(long j4, Object obj) {
        int iB = AbstractC2628a.b(this.f21475b, this.f21477d, j4);
        if (iB >= 0) {
            this.f21476c[iB] = obj;
            return;
        }
        int i6 = ~iB;
        int i7 = this.f21477d;
        Object obj2 = AbstractC2593u.f21478a;
        if (i6 < i7) {
            Object[] objArr = this.f21476c;
            if (objArr[i6] == obj2) {
                this.f21475b[i6] = j4;
                objArr[i6] = obj;
                return;
            }
        }
        if (this.f21474a) {
            long[] jArr = this.f21475b;
            if (i7 >= jArr.length) {
                Object[] objArr2 = this.f21476c;
                int i8 = 0;
                for (int i9 = 0; i9 < i7; i9++) {
                    Object obj3 = objArr2[i9];
                    if (obj3 != obj2) {
                        if (i9 != i8) {
                            jArr[i8] = jArr[i9];
                            objArr2[i8] = obj3;
                            objArr2[i9] = null;
                        }
                        i8++;
                    }
                }
                this.f21474a = false;
                this.f21477d = i8;
                i6 = ~AbstractC2628a.b(this.f21475b, i8, j4);
            }
        }
        int i10 = this.f21477d;
        if (i10 >= this.f21475b.length) {
            int i11 = (i10 + 1) * 8;
            int i12 = 4;
            while (true) {
                if (i12 >= 32) {
                    break;
                }
                int i13 = (1 << i12) - 12;
                if (i11 <= i13) {
                    i11 = i13;
                    break;
                }
                i12++;
            }
            int i14 = i11 / 8;
            long[] jArrCopyOf = Arrays.copyOf(this.f21475b, i14);
            kotlin.jvm.internal.o.g(jArrCopyOf, "copyOf(...)");
            this.f21475b = jArrCopyOf;
            Object[] objArrCopyOf = Arrays.copyOf(this.f21476c, i14);
            kotlin.jvm.internal.o.g(objArrCopyOf, "copyOf(...)");
            this.f21476c = objArrCopyOf;
        }
        int i15 = this.f21477d;
        if (i15 - i6 != 0) {
            long[] jArr2 = this.f21475b;
            int i16 = i6 + 1;
            AbstractC3250p.A(jArr2, jArr2, i16, i6, i15);
            Object[] objArr3 = this.f21476c;
            AbstractC3250p.B(objArr3, i16, objArr3, i6, this.f21477d);
        }
        this.f21475b[i6] = j4;
        this.f21476c[i6] = obj;
        this.f21477d++;
    }

    public final void f(long j4) {
        int iB = AbstractC2628a.b(this.f21475b, this.f21477d, j4);
        if (iB >= 0) {
            Object[] objArr = this.f21476c;
            Object obj = objArr[iB];
            Object obj2 = AbstractC2593u.f21478a;
            if (obj != obj2) {
                objArr[iB] = obj2;
                this.f21474a = true;
            }
        }
    }

    public final int h() {
        if (this.f21474a) {
            int i6 = this.f21477d;
            long[] jArr = this.f21475b;
            Object[] objArr = this.f21476c;
            int i7 = 0;
            for (int i8 = 0; i8 < i6; i8++) {
                Object obj = objArr[i8];
                if (obj != AbstractC2593u.f21478a) {
                    if (i8 != i7) {
                        jArr[i7] = jArr[i8];
                        objArr[i7] = obj;
                        objArr[i8] = null;
                    }
                    i7++;
                }
            }
            this.f21474a = false;
            this.f21477d = i7;
        }
        return this.f21477d;
    }

    public final Object i(int i6) {
        if (!(i6 >= 0 && i6 < this.f21477d)) {
            AbstractC2628a.c("Expected index to be within 0..size()-1, but was " + i6);
            throw null;
        }
        if (this.f21474a) {
            int i7 = this.f21477d;
            long[] jArr = this.f21475b;
            Object[] objArr = this.f21476c;
            int i8 = 0;
            for (int i9 = 0; i9 < i7; i9++) {
                Object obj = objArr[i9];
                if (obj != AbstractC2593u.f21478a) {
                    if (i9 != i8) {
                        jArr[i8] = jArr[i9];
                        objArr[i8] = obj;
                        objArr[i9] = null;
                    }
                    i8++;
                }
            }
            this.f21474a = false;
            this.f21477d = i8;
        }
        return this.f21476c[i6];
    }

    public final String toString() {
        if (h() <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f21477d * 28);
        sb.append('{');
        int i6 = this.f21477d;
        for (int i7 = 0; i7 < i6; i7++) {
            if (i7 > 0) {
                sb.append(", ");
            }
            sb.append(d(i7));
            sb.append('=');
            Object objI = i(i7);
            if (objI != sb) {
                sb.append(objI);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        String string = sb.toString();
        kotlin.jvm.internal.o.g(string, "toString(...)");
        return string;
    }

    public /* synthetic */ C2592t(Object obj) {
        this(10);
    }
}
