package u2;

import java.util.Map;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;

/* loaded from: classes.dex */
public final class c {

    /* renamed from: a, reason: collision with root package name */
    private int[] f36789a;

    /* renamed from: b, reason: collision with root package name */
    private Object[] f36790b;

    /* renamed from: c, reason: collision with root package name */
    private int f36791c;

    public c(int i10) {
        if (i10 == 0) {
            this.f36789a = a.f36777a;
            this.f36790b = a.f36778b;
        } else {
            this.f36789a = new int[i10];
            this.f36790b = new Object[i10 << 1];
        }
        this.f36791c = 0;
    }

    public final boolean a(Object obj) {
        return d(obj) >= 0;
    }

    public final Object b(Object obj) {
        int d10 = d(obj);
        if (d10 >= 0) {
            return this.f36790b[(d10 << 1) + 1];
        }
        return null;
    }

    protected final int c(Object obj, int i10) {
        int i11 = this.f36791c;
        if (i11 == 0) {
            return -1;
        }
        int a10 = a.a(this.f36789a, i11, i10);
        if (a10 < 0 || t.b(obj, this.f36790b[a10 << 1])) {
            return a10;
        }
        int i12 = a10 + 1;
        while (i12 < i11 && this.f36789a[i12] == i10) {
            if (t.b(obj, this.f36790b[i12 << 1])) {
                return i12;
            }
            i12++;
        }
        for (int i13 = a10 - 1; i13 >= 0 && this.f36789a[i13] == i10; i13--) {
            if (t.b(obj, this.f36790b[i13 << 1])) {
                return i13;
            }
        }
        return ~i12;
    }

    public final int d(Object obj) {
        return obj == null ? e() : c(obj, obj.hashCode());
    }

    protected final int e() {
        int i10 = this.f36791c;
        if (i10 == 0) {
            return -1;
        }
        int a10 = a.a(this.f36789a, i10, 0);
        if (a10 < 0 || this.f36790b[a10 << 1] == null) {
            return a10;
        }
        int i11 = a10 + 1;
        while (i11 < i10 && this.f36789a[i11] == 0) {
            if (this.f36790b[i11 << 1] == null) {
                return i11;
            }
            i11++;
        }
        for (int i12 = a10 - 1; i12 >= 0 && this.f36789a[i12] == 0; i12--) {
            if (this.f36790b[i12 << 1] == null) {
                return i12;
            }
        }
        return ~i11;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        try {
            if (obj instanceof c) {
                c cVar = (c) obj;
                int i10 = this.f36791c;
                if (i10 != cVar.f36791c) {
                    return false;
                }
                for (int i11 = 0; i11 < i10; i11++) {
                    Object g10 = g(i11);
                    Object h10 = h(i11);
                    Object b10 = cVar.b(g10);
                    if (h10 == null) {
                        if (b10 != null || !cVar.a(g10)) {
                            return false;
                        }
                    } else if (!t.b(h10, b10)) {
                        return false;
                    }
                }
                return true;
            }
            if (!(obj instanceof Map) || this.f36791c != ((Map) obj).size()) {
                return false;
            }
            int i12 = this.f36791c;
            for (int i13 = 0; i13 < i12; i13++) {
                Object g11 = g(i13);
                Object h11 = h(i13);
                Object obj2 = ((Map) obj).get(g11);
                if (h11 == null) {
                    if (obj2 != null || !((Map) obj).containsKey(g11)) {
                        return false;
                    }
                } else if (!t.b(h11, obj2)) {
                    return false;
                }
            }
            return true;
        } catch (ClassCastException | NullPointerException unused) {
        }
        return false;
    }

    public final boolean f() {
        return this.f36791c <= 0;
    }

    public final Object g(int i10) {
        return this.f36790b[i10 << 1];
    }

    public final Object h(int i10) {
        return this.f36790b[(i10 << 1) + 1];
    }

    public int hashCode() {
        int[] iArr = this.f36789a;
        Object[] objArr = this.f36790b;
        int i10 = this.f36791c;
        int i11 = 1;
        int i12 = 0;
        int i13 = 0;
        while (i12 < i10) {
            Object obj = objArr[i11];
            i13 += (obj != null ? obj.hashCode() : 0) ^ iArr[i12];
            i12++;
            i11 += 2;
        }
        return i13;
    }

    public String toString() {
        if (f()) {
            return "{}";
        }
        StringBuilder sb2 = new StringBuilder(this.f36791c * 28);
        sb2.append('{');
        int i10 = this.f36791c;
        for (int i11 = 0; i11 < i10; i11++) {
            if (i11 > 0) {
                sb2.append(", ");
            }
            Object g10 = g(i11);
            if (g10 != this) {
                sb2.append(g10);
            } else {
                sb2.append("(this Map)");
            }
            sb2.append('=');
            Object h10 = h(i11);
            if (h10 != this) {
                sb2.append(h10);
            } else {
                sb2.append("(this Map)");
            }
        }
        sb2.append('}');
        return sb2.toString();
    }

    public /* synthetic */ c(int i10, int i11, k kVar) {
        this((i11 & 1) != 0 ? 0 : i10);
    }
}
