package defpackage;

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

/* JADX INFO: renamed from: ᵬᵕ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public class C4053 {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public int[] f15545;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public int f15546;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public Object[] f15547;

    public C4053(int i) {
        this.f15545 = i == 0 ? ᵣˉ.ᵲᵶᵳˈ : new int[i];
        this.f15547 = i == 0 ? ᵣˉ.ʽˈˋ : new Object[i << 1];
    }

    public void clear() {
        if (this.f15546 > 0) {
            this.f15545 = ᵣˉ.ᵲᵶᵳˈ;
            this.f15547 = ᵣˉ.ʽˈˋ;
            this.f15546 = 0;
        }
        if (this.f15546 > 0) {
            throw new ConcurrentModificationException();
        }
    }

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

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

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        try {
            if (obj instanceof C4053) {
                int i = this.f15546;
                if (i != ((C4053) obj).f15546) {
                    return false;
                }
                C4053 c4053 = (C4053) obj;
                for (int i2 = 0; i2 < i; i2++) {
                    Object objM8871 = m8871(i2);
                    Object objM8866 = m8866(i2);
                    Object obj2 = c4053.get(objM8871);
                    if (objM8866 == null) {
                        if (obj2 != null || !c4053.containsKey(objM8871)) {
                            return false;
                        }
                    } else if (!objM8866.equals(obj2)) {
                        return false;
                    }
                }
                return true;
            }
            if (!(obj instanceof Map) || this.f15546 != ((Map) obj).size()) {
                return false;
            }
            int i3 = this.f15546;
            for (int i4 = 0; i4 < i3; i4++) {
                Object objM88712 = m8871(i4);
                Object objM88662 = m8866(i4);
                Object obj3 = ((Map) obj).get(objM88712);
                if (objM88662 == null) {
                    if (obj3 != null || !((Map) obj).containsKey(objM88712)) {
                        return false;
                    }
                } else if (!objM88662.equals(obj3)) {
                    return false;
                }
            }
            return true;
        } catch (ClassCastException | NullPointerException unused) {
        }
        return false;
    }

    public Object get(Object obj) {
        int iM8869 = m8869(obj);
        if (iM8869 >= 0) {
            return this.f15547[(iM8869 << 1) + 1];
        }
        return null;
    }

    public final Object getOrDefault(Object obj, Object obj2) {
        int iM8869 = m8869(obj);
        return iM8869 >= 0 ? this.f15547[(iM8869 << 1) + 1] : obj2;
    }

    public int hashCode() {
        int[] iArr = this.f15545;
        Object[] objArr = this.f15547;
        int i = this.f15546;
        int i2 = 1;
        int i3 = 0;
        int iHashCode = 0;
        while (i3 < i) {
            Object obj = objArr[i2];
            iHashCode += (obj != null ? obj.hashCode() : 0) ^ iArr[i3];
            i3++;
            i2 += 2;
        }
        return iHashCode;
    }

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

    public Object put(Object obj, Object obj2) {
        int i = this.f15546;
        int iHashCode = obj != null ? obj.hashCode() : 0;
        int iM8864 = obj != null ? m8864(iHashCode, obj) : m8865();
        if (iM8864 >= 0) {
            int i2 = (iM8864 << 1) + 1;
            Object[] objArr = this.f15547;
            Object obj3 = objArr[i2];
            objArr[i2] = obj2;
            return obj3;
        }
        int i3 = ~iM8864;
        int[] iArr = this.f15545;
        if (i >= iArr.length) {
            int i4 = 8;
            if (i >= 8) {
                i4 = (i >> 1) + i;
            } else if (i < 4) {
                i4 = 4;
            }
            this.f15545 = Arrays.copyOf(iArr, i4);
            this.f15547 = Arrays.copyOf(this.f15547, i4 << 1);
            if (i != this.f15546) {
                throw new ConcurrentModificationException();
            }
        }
        if (i3 < i) {
            int[] iArr2 = this.f15545;
            int i5 = i3 + 1;
            AbstractC3761.m8421(i5, i3, i, iArr2, iArr2);
            Object[] objArr2 = this.f15547;
            AbstractC3761.m8436(i5 << 1, i3 << 1, this.f15546 << 1, objArr2, objArr2);
        }
        int i6 = this.f15546;
        if (i == i6) {
            int[] iArr3 = this.f15545;
            if (i3 < iArr3.length) {
                iArr3[i3] = iHashCode;
                Object[] objArr3 = this.f15547;
                int i7 = i3 << 1;
                objArr3[i7] = obj;
                objArr3[i7 + 1] = obj2;
                this.f15546 = i6 + 1;
                return null;
            }
        }
        throw new ConcurrentModificationException();
    }

    public final Object putIfAbsent(Object obj, Object obj2) {
        Object obj3 = get(obj);
        return obj3 == null ? put(obj, obj2) : obj3;
    }

    public Object remove(Object obj) {
        int iM8869 = m8869(obj);
        if (iM8869 >= 0) {
            return mo8863(iM8869);
        }
        return null;
    }

    public final boolean remove(Object obj, Object obj2) {
        int iM8869 = m8869(obj);
        if (iM8869 < 0 || !ᵥˈᵛ.ˊᵫᵗ(obj2, m8866(iM8869))) {
            return false;
        }
        mo8863(iM8869);
        return true;
    }

    public final Object replace(Object obj, Object obj2) {
        int iM8869 = m8869(obj);
        if (iM8869 >= 0) {
            return mo8870(iM8869, obj2);
        }
        return null;
    }

    public final boolean replace(Object obj, Object obj2, Object obj3) {
        int iM8869 = m8869(obj);
        if (iM8869 < 0 || !ᵥˈᵛ.ˊᵫᵗ(obj2, m8866(iM8869))) {
            return false;
        }
        mo8870(iM8869, obj3);
        return true;
    }

    public final int size() {
        return this.f15546;
    }

    public final String toString() {
        if (isEmpty()) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f15546 * 28);
        sb.append('{');
        int i = this.f15546;
        for (int i2 = 0; i2 < i; i2++) {
            if (i2 > 0) {
                sb.append(", ");
            }
            Object objM8871 = m8871(i2);
            if (objM8871 != sb) {
                sb.append(objM8871);
            } else {
                sb.append("(this Map)");
            }
            sb.append('=');
            Object objM8866 = m8866(i2);
            if (objM8866 != sb) {
                sb.append(objM8866);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final void m8862(int i) {
        int i2 = this.f15546;
        int[] iArr = this.f15545;
        if (iArr.length < i) {
            this.f15545 = Arrays.copyOf(iArr, i);
            this.f15547 = Arrays.copyOf(this.f15547, i * 2);
        }
        if (this.f15546 != i2) {
            throw new ConcurrentModificationException();
        }
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public Object mo8863(int i) {
        int i2;
        if (i < 0 || i >= (i2 = this.f15546)) {
            AbstractC3481.m7945("Expected index to be within 0..size()-1, but was " + i);
            throw null;
        }
        Object[] objArr = this.f15547;
        int i3 = i << 1;
        Object obj = objArr[i3 + 1];
        if (i2 <= 1) {
            clear();
            return obj;
        }
        int i4 = i2 - 1;
        int[] iArr = this.f15545;
        if (iArr.length <= 8 || i2 >= iArr.length / 3) {
            if (i < i4) {
                int i5 = i + 1;
                AbstractC3761.m8421(i, i5, i2, iArr, iArr);
                Object[] objArr2 = this.f15547;
                AbstractC3761.m8436(i3, i5 << 1, i2 << 1, objArr2, objArr2);
            }
            Object[] objArr3 = this.f15547;
            int i6 = i4 << 1;
            objArr3[i6] = null;
            objArr3[i6 + 1] = null;
        } else {
            int i7 = i2 > 8 ? i2 + (i2 >> 1) : 8;
            this.f15545 = Arrays.copyOf(iArr, i7);
            this.f15547 = Arrays.copyOf(this.f15547, i7 << 1);
            if (i2 != this.f15546) {
                throw new ConcurrentModificationException();
            }
            if (i > 0) {
                AbstractC3761.m8421(0, 0, i, iArr, this.f15545);
                AbstractC3761.m8436(0, 0, i3, objArr, this.f15547);
            }
            if (i < i4) {
                int i8 = i + 1;
                AbstractC3761.m8421(i, i8, i2, iArr, this.f15545);
                AbstractC3761.m8436(i3, i8 << 1, i2 << 1, objArr, this.f15547);
            }
        }
        if (i2 != this.f15546) {
            throw new ConcurrentModificationException();
        }
        this.f15546 = i4;
        return obj;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final int m8864(int i, Object obj) {
        int i2 = this.f15546;
        if (i2 == 0) {
            return -1;
        }
        int i3 = ᵣˉ.ᵨᵣ(this.f15545, i2, i);
        if (i3 < 0 || ᵥˈᵛ.ˊᵫᵗ(obj, this.f15547[i3 << 1])) {
            return i3;
        }
        int i4 = i3 + 1;
        while (i4 < i2 && this.f15545[i4] == i) {
            if (ᵥˈᵛ.ˊᵫᵗ(obj, this.f15547[i4 << 1])) {
                return i4;
            }
            i4++;
        }
        for (int i5 = i3 - 1; i5 >= 0 && this.f15545[i5] == i; i5--) {
            if (ᵥˈᵛ.ˊᵫᵗ(obj, this.f15547[i5 << 1])) {
                return i5;
            }
        }
        return ~i4;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final int m8865() {
        int i = this.f15546;
        if (i == 0) {
            return -1;
        }
        int i2 = ᵣˉ.ᵨᵣ(this.f15545, i, 0);
        if (i2 < 0 || this.f15547[i2 << 1] == null) {
            return i2;
        }
        int i3 = i2 + 1;
        while (i3 < i && this.f15545[i3] == 0) {
            if (this.f15547[i3 << 1] == null) {
                return i3;
            }
            i3++;
        }
        for (int i4 = i2 - 1; i4 >= 0 && this.f15545[i4] == 0; i4--) {
            if (this.f15547[i4 << 1] == null) {
                return i4;
            }
        }
        return ~i3;
    }

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public final Object m8866(int i) {
        if (i >= 0 && i < this.f15546) {
            return this.f15547[(i << 1) + 1];
        }
        AbstractC3481.m7945("Expected index to be within 0..size()-1, but was " + i);
        throw null;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final int m8867(Object obj) {
        int i = this.f15546 * 2;
        Object[] objArr = this.f15547;
        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;
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public void mo8868(C3310 c3310) {
        int i = c3310.f15546;
        m8862(this.f15546 + i);
        if (this.f15546 != 0) {
            for (int i2 = 0; i2 < i; i2++) {
                put(c3310.m8871(i2), c3310.m8866(i2));
            }
        } else if (i > 0) {
            AbstractC3761.m8421(0, 0, i, c3310.f15545, this.f15545);
            AbstractC3761.m8436(0, 0, i << 1, c3310.f15547, this.f15547);
            this.f15546 = i;
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final int m8869(Object obj) {
        return obj == null ? m8865() : m8864(obj.hashCode(), obj);
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public Object mo8870(int i, Object obj) {
        if (i < 0 || i >= this.f15546) {
            AbstractC3481.m7945("Expected index to be within 0..size()-1, but was " + i);
            throw null;
        }
        int i2 = (i << 1) + 1;
        Object[] objArr = this.f15547;
        Object obj2 = objArr[i2];
        objArr[i2] = obj;
        return obj2;
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final Object m8871(int i) {
        if (i >= 0 && i < this.f15546) {
            return this.f15547[i << 1];
        }
        AbstractC3481.m7945("Expected index to be within 0..size()-1, but was " + i);
        throw null;
    }
}
