package X6FRs_4.Mqv2r_3;

import java.util.ConcurrentModificationException;
import java.util.Map;
/* compiled from: SimpleArrayMap.java */
/* loaded from: classes.dex */
public class IMuAHx_6<K, V> {
    public static int PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public static Object[] f1006PGPF6hQ_2;
    public static int QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public static Object[] f1007QxJ9d_1;
    public int KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public int[] f1008KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Object[] f1009KQgRr5e_0;

    public IMuAHx_6() {
        this.f1008KQgRr5e_0 = PGPF6hQ_2.KQgRr5e_0;
        this.f1009KQgRr5e_0 = PGPF6hQ_2.f1014KQgRr5e_0;
        this.KQgRr5e_0 = 0;
    }

    public static int KQgRr5e_0(int[] iArr, int i, int i2) {
        try {
            return PGPF6hQ_2.KQgRr5e_0(iArr, i, i2);
        } catch (ArrayIndexOutOfBoundsException unused) {
            throw new ConcurrentModificationException();
        }
    }

    public V PGPF6hQ_2(int i) {
        return (V) this.f1009KQgRr5e_0[(i << 1) + 1];
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public void m502QxJ9d_1(int i) {
        int i2 = this.KQgRr5e_0;
        int[] iArr = this.f1008KQgRr5e_0;
        if (iArr.length < i) {
            Object[] objArr = this.f1009KQgRr5e_0;
            m501KQgRr5e_0(i);
            if (this.KQgRr5e_0 > 0) {
                System.arraycopy(iArr, 0, this.f1008KQgRr5e_0, 0, i2);
                System.arraycopy(objArr, 0, this.f1009KQgRr5e_0, 0, i2 << 1);
            }
            KQgRr5e_0(iArr, objArr, i2);
        }
        if (this.KQgRr5e_0 != i2) {
            throw new ConcurrentModificationException();
        }
    }

    public void clear() {
        int i = this.KQgRr5e_0;
        if (i > 0) {
            int[] iArr = this.f1008KQgRr5e_0;
            Object[] objArr = this.f1009KQgRr5e_0;
            this.f1008KQgRr5e_0 = PGPF6hQ_2.KQgRr5e_0;
            this.f1009KQgRr5e_0 = PGPF6hQ_2.f1014KQgRr5e_0;
            this.KQgRr5e_0 = 0;
            KQgRr5e_0(iArr, objArr, i);
        }
        if (this.KQgRr5e_0 > 0) {
            throw new ConcurrentModificationException();
        }
    }

    public boolean containsKey(Object obj) {
        return KQgRr5e_0(obj) >= 0;
    }

    public boolean containsValue(Object obj) {
        return QxJ9d_1(obj) >= 0;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof IMuAHx_6) {
            IMuAHx_6 iMuAHx_6 = (IMuAHx_6) obj;
            if (size() != iMuAHx_6.size()) {
                return false;
            }
            for (int i = 0; i < this.KQgRr5e_0; i++) {
                try {
                    K KQgRr5e_0 = KQgRr5e_0(i);
                    V PGPF6hQ_22 = PGPF6hQ_2(i);
                    Object obj2 = iMuAHx_6.get(KQgRr5e_0);
                    if (PGPF6hQ_22 == null) {
                        if (obj2 != null || !iMuAHx_6.containsKey(KQgRr5e_0)) {
                            return false;
                        }
                    } else if (!PGPF6hQ_22.equals(obj2)) {
                        return false;
                    }
                } catch (ClassCastException | NullPointerException unused) {
                    return false;
                }
            }
            return true;
        }
        if (obj instanceof Map) {
            Map map = (Map) obj;
            if (size() != map.size()) {
                return false;
            }
            for (int i2 = 0; i2 < this.KQgRr5e_0; i2++) {
                try {
                    K KQgRr5e_02 = KQgRr5e_0(i2);
                    V PGPF6hQ_23 = PGPF6hQ_2(i2);
                    Object obj3 = map.get(KQgRr5e_02);
                    if (PGPF6hQ_23 == null) {
                        if (obj3 != null || !map.containsKey(KQgRr5e_02)) {
                            return false;
                        }
                    } else if (!PGPF6hQ_23.equals(obj3)) {
                        return false;
                    }
                } catch (ClassCastException | NullPointerException unused2) {
                }
            }
            return true;
        }
        return false;
    }

    public V get(Object obj) {
        int KQgRr5e_0 = KQgRr5e_0(obj);
        if (KQgRr5e_0 >= 0) {
            return (V) this.f1009KQgRr5e_0[(KQgRr5e_0 << 1) + 1];
        }
        return null;
    }

    public int hashCode() {
        int[] iArr = this.f1008KQgRr5e_0;
        Object[] objArr = this.f1009KQgRr5e_0;
        int i = this.KQgRr5e_0;
        int i2 = 1;
        int i3 = 0;
        int i4 = 0;
        while (i3 < i) {
            Object obj = objArr[i2];
            i4 += (obj == null ? 0 : obj.hashCode()) ^ iArr[i3];
            i3++;
            i2 += 2;
        }
        return i4;
    }

    public boolean isEmpty() {
        return this.KQgRr5e_0 <= 0;
    }

    public V put(K k, V v) {
        int i;
        int KQgRr5e_0;
        int i2 = this.KQgRr5e_0;
        if (k == null) {
            KQgRr5e_0 = KQgRr5e_0();
            i = 0;
        } else {
            int hashCode = k.hashCode();
            i = hashCode;
            KQgRr5e_0 = KQgRr5e_0(k, hashCode);
        }
        if (KQgRr5e_0 >= 0) {
            int i3 = (KQgRr5e_0 << 1) + 1;
            Object[] objArr = this.f1009KQgRr5e_0;
            V v2 = (V) objArr[i3];
            objArr[i3] = v;
            return v2;
        }
        int i4 = KQgRr5e_0 ^ (-1);
        if (i2 >= this.f1008KQgRr5e_0.length) {
            int i5 = 4;
            if (i2 >= 8) {
                i5 = (i2 >> 1) + i2;
            } else if (i2 >= 4) {
                i5 = 8;
            }
            int[] iArr = this.f1008KQgRr5e_0;
            Object[] objArr2 = this.f1009KQgRr5e_0;
            m501KQgRr5e_0(i5);
            if (i2 == this.KQgRr5e_0) {
                int[] iArr2 = this.f1008KQgRr5e_0;
                if (iArr2.length > 0) {
                    System.arraycopy(iArr, 0, iArr2, 0, iArr.length);
                    System.arraycopy(objArr2, 0, this.f1009KQgRr5e_0, 0, objArr2.length);
                }
                KQgRr5e_0(iArr, objArr2, i2);
            } else {
                throw new ConcurrentModificationException();
            }
        }
        if (i4 < i2) {
            int[] iArr3 = this.f1008KQgRr5e_0;
            int i6 = i4 + 1;
            System.arraycopy(iArr3, i4, iArr3, i6, i2 - i4);
            Object[] objArr3 = this.f1009KQgRr5e_0;
            System.arraycopy(objArr3, i4 << 1, objArr3, i6 << 1, (this.KQgRr5e_0 - i4) << 1);
        }
        int i7 = this.KQgRr5e_0;
        if (i2 == i7) {
            int[] iArr4 = this.f1008KQgRr5e_0;
            if (i4 < iArr4.length) {
                iArr4[i4] = i;
                Object[] objArr4 = this.f1009KQgRr5e_0;
                int i8 = i4 << 1;
                objArr4[i8] = k;
                objArr4[i8 + 1] = v;
                this.KQgRr5e_0 = i7 + 1;
                return null;
            }
        }
        throw new ConcurrentModificationException();
    }

    public V remove(Object obj) {
        int KQgRr5e_0 = KQgRr5e_0(obj);
        if (KQgRr5e_0 >= 0) {
            return QxJ9d_1(KQgRr5e_0);
        }
        return null;
    }

    public int size() {
        return this.KQgRr5e_0;
    }

    public String toString() {
        if (isEmpty()) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.KQgRr5e_0 * 28);
        sb.append('{');
        for (int i = 0; i < this.KQgRr5e_0; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            K KQgRr5e_0 = KQgRr5e_0(i);
            if (KQgRr5e_0 != this) {
                sb.append(KQgRr5e_0);
            } else {
                sb.append("(this Map)");
            }
            sb.append('=');
            V PGPF6hQ_22 = PGPF6hQ_2(i);
            if (PGPF6hQ_22 != this) {
                sb.append(PGPF6hQ_22);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }

    public int KQgRr5e_0(Object obj, int i) {
        int i2 = this.KQgRr5e_0;
        if (i2 == 0) {
            return -1;
        }
        int KQgRr5e_0 = KQgRr5e_0(this.f1008KQgRr5e_0, i2, i);
        if (KQgRr5e_0 >= 0 && !obj.equals(this.f1009KQgRr5e_0[KQgRr5e_0 << 1])) {
            int i3 = KQgRr5e_0 + 1;
            while (i3 < i2 && this.f1008KQgRr5e_0[i3] == i) {
                if (obj.equals(this.f1009KQgRr5e_0[i3 << 1])) {
                    return i3;
                }
                i3++;
            }
            for (int i4 = KQgRr5e_0 - 1; i4 >= 0 && this.f1008KQgRr5e_0[i4] == i; i4--) {
                if (obj.equals(this.f1009KQgRr5e_0[i4 << 1])) {
                    return i4;
                }
            }
            return i3 ^ (-1);
        }
        return KQgRr5e_0;
    }

    public IMuAHx_6(int i) {
        if (i == 0) {
            this.f1008KQgRr5e_0 = PGPF6hQ_2.KQgRr5e_0;
            this.f1009KQgRr5e_0 = PGPF6hQ_2.f1014KQgRr5e_0;
        } else {
            m501KQgRr5e_0(i);
        }
        this.KQgRr5e_0 = 0;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public IMuAHx_6(IMuAHx_6<K, V> iMuAHx_6) {
        this();
        if (iMuAHx_6 != 0) {
            KQgRr5e_0((IMuAHx_6) iMuAHx_6);
        }
    }

    public int KQgRr5e_0() {
        int i = this.KQgRr5e_0;
        if (i == 0) {
            return -1;
        }
        int KQgRr5e_0 = KQgRr5e_0(this.f1008KQgRr5e_0, i, 0);
        if (KQgRr5e_0 >= 0 && this.f1009KQgRr5e_0[KQgRr5e_0 << 1] != null) {
            int i2 = KQgRr5e_0 + 1;
            while (i2 < i && this.f1008KQgRr5e_0[i2] == 0) {
                if (this.f1009KQgRr5e_0[i2 << 1] == null) {
                    return i2;
                }
                i2++;
            }
            for (int i3 = KQgRr5e_0 - 1; i3 >= 0 && this.f1008KQgRr5e_0[i3] == 0; i3--) {
                if (this.f1009KQgRr5e_0[i3 << 1] == null) {
                    return i3;
                }
            }
            return i2 ^ (-1);
        }
        return KQgRr5e_0;
    }

    public int QxJ9d_1(Object obj) {
        int i = this.KQgRr5e_0 * 2;
        Object[] objArr = this.f1009KQgRr5e_0;
        if (obj == null) {
            for (int i2 = 1; i2 < i; i2 += 2) {
                if (objArr[i2] == null) {
                    return i2 >> 1;
                }
            }
            return -1;
        }
        for (int i3 = 1; i3 < i; i3 += 2) {
            if (obj.equals(objArr[i3])) {
                return i3 >> 1;
            }
        }
        return -1;
    }

    public V QxJ9d_1(int i) {
        Object[] objArr = this.f1009KQgRr5e_0;
        int i2 = i << 1;
        V v = (V) objArr[i2 + 1];
        int i3 = this.KQgRr5e_0;
        int i4 = 0;
        if (i3 <= 1) {
            KQgRr5e_0(this.f1008KQgRr5e_0, objArr, i3);
            this.f1008KQgRr5e_0 = PGPF6hQ_2.KQgRr5e_0;
            this.f1009KQgRr5e_0 = PGPF6hQ_2.f1014KQgRr5e_0;
        } else {
            int i5 = i3 - 1;
            int[] iArr = this.f1008KQgRr5e_0;
            if (iArr.length > 8 && i3 < iArr.length / 3) {
                int i6 = i3 > 8 ? i3 + (i3 >> 1) : 8;
                int[] iArr2 = this.f1008KQgRr5e_0;
                Object[] objArr2 = this.f1009KQgRr5e_0;
                m501KQgRr5e_0(i6);
                if (i3 != this.KQgRr5e_0) {
                    throw new ConcurrentModificationException();
                }
                if (i > 0) {
                    System.arraycopy(iArr2, 0, this.f1008KQgRr5e_0, 0, i);
                    System.arraycopy(objArr2, 0, this.f1009KQgRr5e_0, 0, i2);
                }
                if (i < i5) {
                    int i7 = i + 1;
                    int i8 = i5 - i;
                    System.arraycopy(iArr2, i7, this.f1008KQgRr5e_0, i, i8);
                    System.arraycopy(objArr2, i7 << 1, this.f1009KQgRr5e_0, i2, i8 << 1);
                }
            } else {
                if (i < i5) {
                    int[] iArr3 = this.f1008KQgRr5e_0;
                    int i9 = i + 1;
                    int i10 = i5 - i;
                    System.arraycopy(iArr3, i9, iArr3, i, i10);
                    Object[] objArr3 = this.f1009KQgRr5e_0;
                    System.arraycopy(objArr3, i9 << 1, objArr3, i2, i10 << 1);
                }
                Object[] objArr4 = this.f1009KQgRr5e_0;
                int i11 = i5 << 1;
                objArr4[i11] = null;
                objArr4[i11 + 1] = null;
            }
            i4 = i5;
        }
        if (i3 == this.KQgRr5e_0) {
            this.KQgRr5e_0 = i4;
            return v;
        }
        throw new ConcurrentModificationException();
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public final void m501KQgRr5e_0(int i) {
        if (i == 8) {
            synchronized (KQgRr5e_0.class) {
                if (f1006PGPF6hQ_2 != null) {
                    Object[] objArr = f1006PGPF6hQ_2;
                    this.f1009KQgRr5e_0 = objArr;
                    f1006PGPF6hQ_2 = (Object[]) objArr[0];
                    this.f1008KQgRr5e_0 = (int[]) objArr[1];
                    objArr[1] = null;
                    objArr[0] = null;
                    PGPF6hQ_2--;
                    return;
                }
            }
        } else if (i == 4) {
            synchronized (KQgRr5e_0.class) {
                if (f1007QxJ9d_1 != null) {
                    Object[] objArr2 = f1007QxJ9d_1;
                    this.f1009KQgRr5e_0 = objArr2;
                    f1007QxJ9d_1 = (Object[]) objArr2[0];
                    this.f1008KQgRr5e_0 = (int[]) objArr2[1];
                    objArr2[1] = null;
                    objArr2[0] = null;
                    QxJ9d_1--;
                    return;
                }
            }
        }
        this.f1008KQgRr5e_0 = new int[i];
        this.f1009KQgRr5e_0 = new Object[i << 1];
    }

    public static void KQgRr5e_0(int[] iArr, Object[] objArr, int i) {
        if (iArr.length == 8) {
            synchronized (KQgRr5e_0.class) {
                if (PGPF6hQ_2 < 10) {
                    objArr[0] = f1006PGPF6hQ_2;
                    objArr[1] = iArr;
                    for (int i2 = (i << 1) - 1; i2 >= 2; i2--) {
                        objArr[i2] = null;
                    }
                    f1006PGPF6hQ_2 = objArr;
                    PGPF6hQ_2++;
                }
            }
        } else if (iArr.length == 4) {
            synchronized (KQgRr5e_0.class) {
                if (QxJ9d_1 < 10) {
                    objArr[0] = f1007QxJ9d_1;
                    objArr[1] = iArr;
                    for (int i3 = (i << 1) - 1; i3 >= 2; i3--) {
                        objArr[i3] = null;
                    }
                    f1007QxJ9d_1 = objArr;
                    QxJ9d_1++;
                }
            }
        }
    }

    public int KQgRr5e_0(Object obj) {
        return obj == null ? KQgRr5e_0() : KQgRr5e_0(obj, obj.hashCode());
    }

    public K KQgRr5e_0(int i) {
        return (K) this.f1009KQgRr5e_0[i << 1];
    }

    public V KQgRr5e_0(int i, V v) {
        int i2 = (i << 1) + 1;
        Object[] objArr = this.f1009KQgRr5e_0;
        V v2 = (V) objArr[i2];
        objArr[i2] = v;
        return v2;
    }

    public void KQgRr5e_0(IMuAHx_6<? extends K, ? extends V> iMuAHx_6) {
        int i = iMuAHx_6.KQgRr5e_0;
        m502QxJ9d_1(this.KQgRr5e_0 + i);
        if (this.KQgRr5e_0 != 0) {
            for (int i2 = 0; i2 < i; i2++) {
                put(iMuAHx_6.KQgRr5e_0(i2), iMuAHx_6.PGPF6hQ_2(i2));
            }
        } else if (i > 0) {
            System.arraycopy(iMuAHx_6.f1008KQgRr5e_0, 0, this.f1008KQgRr5e_0, 0, i);
            System.arraycopy(iMuAHx_6.f1009KQgRr5e_0, 0, this.f1009KQgRr5e_0, 0, i << 1);
            this.KQgRr5e_0 = i;
        }
    }
}
