package ῲ.㴹;

import java.util.ConcurrentModificationException;
import java.util.Map;

/* renamed from: ῲ.㴹.㿎  reason: contains not printable characters */
/* compiled from: SimpleArrayMap */
public class C2288<K, V> {

    /* renamed from: ඓ  reason: contains not printable characters */
    public static Object[] f7903;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public static Object[] f7904;

    /* renamed from: 㴹  reason: contains not printable characters */
    public static int f7905;

    /* renamed from: 㿎  reason: contains not printable characters */
    public static int f7906;

    /* renamed from: ʬ  reason: contains not printable characters */
    public Object[] f7907;

    /* renamed from: ῲ  reason: contains not printable characters */
    public int[] f7908;

    /* renamed from: 㸾  reason: contains not printable characters */
    public int f7909;

    public C2288() {
        this.f7908 = C2287.f7902;
        this.f7907 = C2287.f7900;
        this.f7909 = 0;
    }

    public void clear() {
        int i = this.f7909;
        if (i > 0) {
            int[] iArr = this.f7908;
            Object[] objArr = this.f7907;
            this.f7908 = C2287.f7902;
            this.f7907 = C2287.f7900;
            this.f7909 = 0;
            m5971(iArr, objArr, i);
        }
        if (this.f7909 > 0) {
            throw new ConcurrentModificationException();
        }
    }

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

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

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof C2288) {
            C2288 r7 = (C2288) obj;
            if (this.f7909 != r7.f7909) {
                return false;
            }
            for (int i = 0; i < this.f7909; i++) {
                try {
                    K r3 = m5972(i);
                    V r4 = m5973(i);
                    Object obj2 = r7.get(r3);
                    if (r4 == null) {
                        if (obj2 != null || !r7.containsKey(r3)) {
                            return false;
                        }
                    } else if (!r4.equals(obj2)) {
                        return false;
                    }
                } catch (ClassCastException | NullPointerException unused) {
                    return false;
                }
            }
            return true;
        }
        if (obj instanceof Map) {
            Map map = (Map) obj;
            if (this.f7909 != map.size()) {
                return false;
            }
            for (int i2 = 0; i2 < this.f7909; i2++) {
                try {
                    K r32 = m5972(i2);
                    V r42 = m5973(i2);
                    Object obj3 = map.get(r32);
                    if (r42 == null) {
                        if (obj3 != null || !map.containsKey(r32)) {
                            return false;
                        }
                    } else if (!r42.equals(obj3)) {
                        return false;
                    }
                } catch (ClassCastException | NullPointerException unused2) {
                }
            }
            return true;
        }
        return false;
    }

    public V get(Object obj) {
        return getOrDefault(obj, null);
    }

    public V getOrDefault(Object obj, V v) {
        int r1 = m5977(obj);
        return r1 >= 0 ? (V) this.f7907[(r1 << 1) + 1] : v;
    }

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

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

    public V put(K k, V v) {
        int i;
        int i2;
        int i3 = this.f7909;
        if (k == null) {
            i2 = m5976();
            i = 0;
        } else {
            int hashCode = k.hashCode();
            i = hashCode;
            i2 = m5978(k, hashCode);
        }
        if (i2 >= 0) {
            int i4 = (i2 << 1) + 1;
            Object[] objArr = this.f7907;
            V v2 = (V) objArr[i4];
            objArr[i4] = v;
            return v2;
        }
        int i5 = ~i2;
        if (i3 >= this.f7908.length) {
            int i6 = 4;
            if (i3 >= 8) {
                i6 = (i3 >> 1) + i3;
            } else if (i3 >= 4) {
                i6 = 8;
            }
            int[] iArr = this.f7908;
            Object[] objArr2 = this.f7907;
            m5980(i6);
            if (i3 == this.f7909) {
                int[] iArr2 = this.f7908;
                if (iArr2.length > 0) {
                    System.arraycopy(iArr, 0, iArr2, 0, iArr.length);
                    System.arraycopy(objArr2, 0, this.f7907, 0, objArr2.length);
                }
                m5971(iArr, objArr2, i3);
            } else {
                throw new ConcurrentModificationException();
            }
        }
        if (i5 < i3) {
            int[] iArr3 = this.f7908;
            int i7 = i5 + 1;
            System.arraycopy(iArr3, i5, iArr3, i7, i3 - i5);
            Object[] objArr3 = this.f7907;
            System.arraycopy(objArr3, i5 << 1, objArr3, i7 << 1, (this.f7909 - i5) << 1);
        }
        int i8 = this.f7909;
        if (i3 == i8) {
            int[] iArr4 = this.f7908;
            if (i5 < iArr4.length) {
                iArr4[i5] = i;
                Object[] objArr4 = this.f7907;
                int i9 = i5 << 1;
                objArr4[i9] = k;
                objArr4[i9 + 1] = v;
                this.f7909 = i8 + 1;
                return null;
            }
        }
        throw new ConcurrentModificationException();
    }

    public V putIfAbsent(K k, V v) {
        V orDefault = getOrDefault(k, null);
        return orDefault == null ? put(k, v) : orDefault;
    }

    public V remove(Object obj) {
        int r1 = m5977(obj);
        if (r1 >= 0) {
            return m5982(r1);
        }
        return null;
    }

    public V replace(K k, V v) {
        int r1 = m5977((Object) k);
        if (r1 >= 0) {
            return m5979(r1, v);
        }
        return null;
    }

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

    public String toString() {
        if (isEmpty()) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f7909 * 28);
        sb.append('{');
        for (int i = 0; i < this.f7909; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            K r2 = m5972(i);
            if (r2 != this) {
                sb.append((Object) r2);
            } else {
                sb.append("(this Map)");
            }
            sb.append('=');
            V r22 = m5973(i);
            if (r22 != this) {
                sb.append((Object) r22);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public K m5972(int i) {
        return (K) this.f7907[i << 1];
    }

    /* renamed from: ඓ  reason: contains not printable characters */
    public V m5973(int i) {
        return (V) this.f7907[(i << 1) + 1];
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m5975(int i) {
        int i2 = this.f7909;
        int[] iArr = this.f7908;
        if (iArr.length < i) {
            Object[] objArr = this.f7907;
            m5980(i);
            if (this.f7909 > 0) {
                System.arraycopy(iArr, 0, this.f7908, 0, i2);
                System.arraycopy(objArr, 0, this.f7907, 0, i2 << 1);
            }
            m5971(iArr, objArr, i2);
        }
        if (this.f7909 != i2) {
            throw new ConcurrentModificationException();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m5978(Object obj, int i) {
        int i2 = this.f7909;
        if (i2 == 0) {
            return -1;
        }
        try {
            int r2 = C2287.m5968(this.f7908, i2, i);
            if (r2 < 0 || obj.equals(this.f7907[r2 << 1])) {
                return r2;
            }
            int i3 = r2 + 1;
            while (i3 < i2 && this.f7908[i3] == i) {
                if (obj.equals(this.f7907[i3 << 1])) {
                    return i3;
                }
                i3++;
            }
            int i4 = r2 - 1;
            while (i4 >= 0 && this.f7908[i4] == i) {
                if (obj.equals(this.f7907[i4 << 1])) {
                    return i4;
                }
                i4--;
            }
            return ~i3;
        } catch (ArrayIndexOutOfBoundsException unused) {
            throw new ConcurrentModificationException();
        }
    }

    /* renamed from: 㸾  reason: contains not printable characters */
    public V m5982(int i) {
        int i2;
        Object[] objArr = this.f7907;
        int i3 = i << 1;
        V v = (V) objArr[i3 + 1];
        int i4 = this.f7909;
        if (i4 <= 1) {
            m5971(this.f7908, objArr, i4);
            this.f7908 = C2287.f7902;
            this.f7907 = C2287.f7900;
            i2 = 0;
        } else {
            i2 = i4 - 1;
            int[] iArr = this.f7908;
            int i5 = 8;
            if (iArr.length <= 8 || i4 >= iArr.length / 3) {
                if (i < i2) {
                    int[] iArr2 = this.f7908;
                    int i6 = i + 1;
                    int i7 = i2 - i;
                    System.arraycopy(iArr2, i6, iArr2, i, i7);
                    Object[] objArr2 = this.f7907;
                    System.arraycopy(objArr2, i6 << 1, objArr2, i3, i7 << 1);
                }
                Object[] objArr3 = this.f7907;
                int i8 = i2 << 1;
                objArr3[i8] = null;
                objArr3[i8 + 1] = null;
            } else {
                if (i4 > 8) {
                    i5 = i4 + (i4 >> 1);
                }
                int[] iArr3 = this.f7908;
                Object[] objArr4 = this.f7907;
                m5980(i5);
                if (i4 == this.f7909) {
                    if (i > 0) {
                        System.arraycopy(iArr3, 0, this.f7908, 0, i);
                        System.arraycopy(objArr4, 0, this.f7907, 0, i3);
                    }
                    if (i < i2) {
                        int i9 = i + 1;
                        int i10 = i2 - i;
                        System.arraycopy(iArr3, i9, this.f7908, i, i10);
                        System.arraycopy(objArr4, i9 << 1, this.f7907, i3, i10 << 1);
                    }
                } else {
                    throw new ConcurrentModificationException();
                }
            }
        }
        if (i4 == this.f7909) {
            this.f7909 = i2;
            return v;
        }
        throw new ConcurrentModificationException();
    }

    public boolean remove(Object obj, Object obj2) {
        int r2 = m5977(obj);
        if (r2 < 0) {
            return false;
        }
        V r0 = m5973(r2);
        if (obj2 != r0 && (obj2 == null || !obj2.equals(r0))) {
            return false;
        }
        m5982(r2);
        return true;
    }

    public boolean replace(K k, V v, V v2) {
        int r2 = m5977((Object) k);
        if (r2 < 0) {
            return false;
        }
        V r0 = m5973(r2);
        if (r0 != v && (v == null || !v.equals(r0))) {
            return false;
        }
        m5979(r2, v2);
        return true;
    }

    public C2288(int i) {
        if (i == 0) {
            this.f7908 = C2287.f7902;
            this.f7907 = C2287.f7900;
        } else {
            m5980(i);
        }
        this.f7909 = 0;
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m5976() {
        int i = this.f7909;
        if (i == 0) {
            return -1;
        }
        try {
            int r2 = C2287.m5968(this.f7908, i, 0);
            if (r2 < 0 || this.f7907[r2 << 1] == null) {
                return r2;
            }
            int i2 = r2 + 1;
            while (i2 < i && this.f7908[i2] == 0) {
                if (this.f7907[i2 << 1] == null) {
                    return i2;
                }
                i2++;
            }
            int i3 = r2 - 1;
            while (i3 >= 0 && this.f7908[i3] == 0) {
                if (this.f7907[i3 << 1] == null) {
                    return i3;
                }
                i3--;
            }
            return ~i2;
        } catch (ArrayIndexOutOfBoundsException unused) {
            throw new ConcurrentModificationException();
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public int m5974(Object obj) {
        int i = this.f7909 * 2;
        Object[] objArr = this.f7907;
        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;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m5980(int i) {
        if (i == 8) {
            synchronized (C2288.class) {
                if (f7904 != null) {
                    Object[] objArr = f7904;
                    this.f7907 = objArr;
                    f7904 = (Object[]) objArr[0];
                    this.f7908 = (int[]) objArr[1];
                    objArr[1] = null;
                    objArr[0] = null;
                    f7906--;
                    return;
                }
            }
        } else if (i == 4) {
            synchronized (C2288.class) {
                if (f7903 != null) {
                    Object[] objArr2 = f7903;
                    this.f7907 = objArr2;
                    f7903 = (Object[]) objArr2[0];
                    this.f7908 = (int[]) objArr2[1];
                    objArr2[1] = null;
                    objArr2[0] = null;
                    f7905--;
                    return;
                }
            }
        }
        this.f7908 = new int[i];
        this.f7907 = new Object[(i << 1)];
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m5971(int[] iArr, Object[] objArr, int i) {
        if (iArr.length == 8) {
            synchronized (C2288.class) {
                if (f7906 < 10) {
                    objArr[0] = f7904;
                    objArr[1] = iArr;
                    for (int i2 = (i << 1) - 1; i2 >= 2; i2--) {
                        objArr[i2] = null;
                    }
                    f7904 = objArr;
                    f7906++;
                }
            }
        } else if (iArr.length == 4) {
            synchronized (C2288.class) {
                if (f7905 < 10) {
                    objArr[0] = f7903;
                    objArr[1] = iArr;
                    for (int i3 = (i << 1) - 1; i3 >= 2; i3--) {
                        objArr[i3] = null;
                    }
                    f7903 = objArr;
                    f7905++;
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m5977(Object obj) {
        return obj == null ? m5976() : m5978(obj, obj.hashCode());
    }

    /* renamed from: K  reason: contains not printable characters */
    public V m5979(int i, V v) {
        int i2 = (i << 1) + 1;
        Object[] objArr = this.f7907;
        V v2 = (V) objArr[i2];
        objArr[i2] = v;
        return v2;
    }

    /* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: ῲ.㴹.㿎<K, V> */
    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: K  reason: contains not printable characters */
    public void m5981(C2288<? extends K, ? extends V> r5) {
        int i = r5.f7909;
        m5975(this.f7909 + i);
        if (this.f7909 != 0) {
            for (int i2 = 0; i2 < i; i2++) {
                put(r5.m5972(i2), r5.m5973(i2));
            }
        } else if (i > 0) {
            System.arraycopy(r5.f7908, 0, this.f7908, 0, i);
            System.arraycopy(r5.f7907, 0, this.f7907, 0, i << 1);
            this.f7909 = i;
        }
    }
}
