package defpackage;

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

/* renamed from: ᵛᵹ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public class C2771 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public Object[] f10696;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public int[] f10697;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public int f10698;

    public C2771(int i) {
        this.f10697 = i == 0 ? ᵛᵾˏ.ᵥᵯˎ : new int[i];
        this.f10696 = i == 0 ? ᵛᵾˏ.ᵴᵳ : new Object[i << 1];
    }

    public void clear() {
        if (this.f10698 > 0) {
            this.f10697 = ᵛᵾˏ.ᵥᵯˎ;
            this.f10696 = ᵛᵾˏ.ᵴᵳ;
            this.f10698 = 0;
        }
        if (this.f10698 > 0) {
            throw new ConcurrentModificationException();
        }
    }

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

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

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        try {
            if (obj instanceof C2771) {
                int i = this.f10698;
                if (i != ((C2771) obj).f10698) {
                    return false;
                }
                C2771 c2771 = (C2771) obj;
                for (int i2 = 0; i2 < i; i2++) {
                    Object objM6838 = m6838(i2);
                    Object objM6842 = m6842(i2);
                    Object obj2 = c2771.get(objM6838);
                    if (objM6842 == null) {
                        if (obj2 != null || !c2771.containsKey(objM6838)) {
                            return false;
                        }
                    } else if (!objM6842.equals(obj2)) {
                        return false;
                    }
                }
                return true;
            }
            if (!(obj instanceof Map) || this.f10698 != ((Map) obj).size()) {
                return false;
            }
            int i3 = this.f10698;
            for (int i4 = 0; i4 < i3; i4++) {
                Object objM68382 = m6838(i4);
                Object objM68422 = m6842(i4);
                Object obj3 = ((Map) obj).get(objM68382);
                if (objM68422 == null) {
                    if (obj3 != null || !((Map) obj).containsKey(objM68382)) {
                        return false;
                    }
                } else if (!objM68422.equals(obj3)) {
                    return false;
                }
            }
            return true;
        } catch (ClassCastException | NullPointerException unused) {
        }
        return false;
    }

    public Object get(Object obj) {
        int iM6843 = m6843(obj);
        if (iM6843 >= 0) {
            return this.f10696[(iM6843 << 1) + 1];
        }
        return null;
    }

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

    public int hashCode() {
        int[] iArr = this.f10697;
        Object[] objArr = this.f10696;
        int i = this.f10698;
        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.f10698 <= 0;
    }

    public Object put(Object obj, Object obj2) {
        int i = this.f10698;
        int iHashCode = obj != null ? obj.hashCode() : 0;
        int iM6839 = obj != null ? m6839(iHashCode, obj) : m6837();
        if (iM6839 >= 0) {
            int i2 = (iM6839 << 1) + 1;
            Object[] objArr = this.f10696;
            Object obj3 = objArr[i2];
            objArr[i2] = obj2;
            return obj3;
        }
        int i3 = ~iM6839;
        int[] iArr = this.f10697;
        if (i >= iArr.length) {
            int i4 = 8;
            if (i >= 8) {
                i4 = (i >> 1) + i;
            } else if (i < 4) {
                i4 = 4;
            }
            this.f10697 = Arrays.copyOf(iArr, i4);
            this.f10696 = Arrays.copyOf(this.f10696, i4 << 1);
            if (i != this.f10698) {
                throw new ConcurrentModificationException();
            }
        }
        if (i3 < i) {
            int[] iArr2 = this.f10697;
            int i5 = i3 + 1;
            AbstractC1658.m4716(i5, i3, i, iArr2, iArr2);
            Object[] objArr2 = this.f10696;
            AbstractC1658.m4726(i5 << 1, i3 << 1, this.f10698 << 1, objArr2, objArr2);
        }
        int i6 = this.f10698;
        if (i == i6) {
            int[] iArr3 = this.f10697;
            if (i3 < iArr3.length) {
                iArr3[i3] = iHashCode;
                Object[] objArr3 = this.f10696;
                int i7 = i3 << 1;
                objArr3[i7] = obj;
                objArr3[i7 + 1] = obj2;
                this.f10698 = 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 iM6843 = m6843(obj);
        if (iM6843 >= 0) {
            return mo1308(iM6843);
        }
        return null;
    }

    public final boolean remove(Object obj, Object obj2) {
        int iM6843 = m6843(obj);
        if (iM6843 < 0 || !ᵲᵝᵪ.ᵹᵝᵶ(obj2, m6842(iM6843))) {
            return false;
        }
        mo1308(iM6843);
        return true;
    }

    public final Object replace(Object obj, Object obj2) {
        int iM6843 = m6843(obj);
        if (iM6843 >= 0) {
            return mo1307(iM6843, obj2);
        }
        return null;
    }

    public final boolean replace(Object obj, Object obj2, Object obj3) {
        int iM6843 = m6843(obj);
        if (iM6843 < 0 || !ᵲᵝᵪ.ᵹᵝᵶ(obj2, m6842(iM6843))) {
            return false;
        }
        mo1307(iM6843, obj3);
        return true;
    }

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

    public final String toString() {
        if (isEmpty()) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f10698 * 28);
        sb.append('{');
        int i = this.f10698;
        for (int i2 = 0; i2 < i; i2++) {
            if (i2 > 0) {
                sb.append(", ");
            }
            Object objM6838 = m6838(i2);
            if (objM6838 != sb) {
                sb.append(objM6838);
            } else {
                sb.append("(this Map)");
            }
            sb.append('=');
            Object objM6842 = m6842(i2);
            if (objM6842 != sb) {
                sb.append(objM6842);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        return sb.toString();
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final int m6837() {
        int i = this.f10698;
        if (i == 0) {
            return -1;
        }
        int i2 = ᵛᵾˏ.ᵻᵢﹳᵰ(this.f10697, i, 0);
        if (i2 < 0 || this.f10696[i2 << 1] == null) {
            return i2;
        }
        int i3 = i2 + 1;
        while (i3 < i && this.f10697[i3] == 0) {
            if (this.f10696[i3 << 1] == null) {
                return i3;
            }
            i3++;
        }
        for (int i4 = i2 - 1; i4 >= 0 && this.f10697[i4] == 0; i4--) {
            if (this.f10696[i4 << 1] == null) {
                return i4;
            }
        }
        return ~i3;
    }

    /* renamed from: ˎˏʜʾ */
    public void mo1306(C1200 c1200) {
        int i = c1200.f10698;
        m6841(this.f10698 + i);
        if (this.f10698 != 0) {
            for (int i2 = 0; i2 < i; i2++) {
                put(c1200.m6838(i2), c1200.m6842(i2));
            }
        } else if (i > 0) {
            AbstractC1658.m4716(0, 0, i, c1200.f10697, this.f10697);
            AbstractC1658.m4726(0, 0, i << 1, c1200.f10696, this.f10696);
            this.f10698 = i;
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final Object m6838(int i) {
        if (i >= 0 && i < this.f10698) {
            return this.f10696[i << 1];
        }
        ᵯᵽᵦ.ˀᵗᵩ("Expected index to be within 0..size()-1, but was " + i);
        throw null;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final int m6839(int i, Object obj) {
        int i2 = this.f10698;
        if (i2 == 0) {
            return -1;
        }
        int i3 = ᵛᵾˏ.ᵻᵢﹳᵰ(this.f10697, i2, i);
        if (i3 < 0 || ᵲᵝᵪ.ᵹᵝᵶ(obj, this.f10696[i3 << 1])) {
            return i3;
        }
        int i4 = i3 + 1;
        while (i4 < i2 && this.f10697[i4] == i) {
            if (ᵲᵝᵪ.ᵹᵝᵶ(obj, this.f10696[i4 << 1])) {
                return i4;
            }
            i4++;
        }
        for (int i5 = i3 - 1; i5 >= 0 && this.f10697[i5] == i; i5--) {
            if (ᵲᵝᵪ.ᵹᵝᵶ(obj, this.f10696[i5 << 1])) {
                return i5;
            }
        }
        return ~i4;
    }

    /* renamed from: ᵝᵵᵺ */
    public Object mo1307(int i, Object obj) {
        if (i < 0 || i >= this.f10698) {
            ᵯᵽᵦ.ˀᵗᵩ("Expected index to be within 0..size()-1, but was " + i);
            throw null;
        }
        int i2 = (i << 1) + 1;
        Object[] objArr = this.f10696;
        Object obj2 = objArr[i2];
        objArr[i2] = obj;
        return obj2;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final int m6840(Object obj) {
        int i = this.f10698 * 2;
        Object[] objArr = this.f10696;
        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 m6841(int i) {
        int i2 = this.f10698;
        int[] iArr = this.f10697;
        if (iArr.length < i) {
            this.f10697 = Arrays.copyOf(iArr, i);
            this.f10696 = Arrays.copyOf(this.f10696, i * 2);
        }
        if (this.f10698 != i2) {
            throw new ConcurrentModificationException();
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final Object m6842(int i) {
        if (i >= 0 && i < this.f10698) {
            return this.f10696[(i << 1) + 1];
        }
        ᵯᵽᵦ.ˀᵗᵩ("Expected index to be within 0..size()-1, but was " + i);
        throw null;
    }

    /* renamed from: ᵹᵝᵶ */
    public Object mo1308(int i) {
        int i2;
        if (i < 0 || i >= (i2 = this.f10698)) {
            ᵯᵽᵦ.ˀᵗᵩ("Expected index to be within 0..size()-1, but was " + i);
            throw null;
        }
        Object[] objArr = this.f10696;
        int i3 = i << 1;
        Object obj = objArr[i3 + 1];
        if (i2 <= 1) {
            clear();
            return obj;
        }
        int i4 = i2 - 1;
        int[] iArr = this.f10697;
        if (iArr.length <= 8 || i2 >= iArr.length / 3) {
            if (i < i4) {
                int i5 = i + 1;
                AbstractC1658.m4716(i, i5, i2, iArr, iArr);
                Object[] objArr2 = this.f10696;
                AbstractC1658.m4726(i3, i5 << 1, i2 << 1, objArr2, objArr2);
            }
            Object[] objArr3 = this.f10696;
            int i6 = i4 << 1;
            objArr3[i6] = null;
            objArr3[i6 + 1] = null;
        } else {
            int i7 = i2 > 8 ? i2 + (i2 >> 1) : 8;
            this.f10697 = Arrays.copyOf(iArr, i7);
            this.f10696 = Arrays.copyOf(this.f10696, i7 << 1);
            if (i2 != this.f10698) {
                throw new ConcurrentModificationException();
            }
            if (i > 0) {
                AbstractC1658.m4716(0, 0, i, iArr, this.f10697);
                AbstractC1658.m4726(0, 0, i3, objArr, this.f10696);
            }
            if (i < i4) {
                int i8 = i + 1;
                AbstractC1658.m4716(i, i8, i2, iArr, this.f10697);
                AbstractC1658.m4726(i3, i8 << 1, i2 << 1, objArr, this.f10696);
            }
        }
        if (i2 != this.f10698) {
            throw new ConcurrentModificationException();
        }
        this.f10698 = i4;
        return obj;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final int m6843(Object obj) {
        return obj == null ? m6837() : m6839(obj.hashCode(), obj);
    }
}
