package defpackage;

import java.util.AbstractMap;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;

/* JADX INFO: renamed from: ᵵᵴˑᵡ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C4770 extends AbstractMap {

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

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

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public int f18152;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public boolean f18153;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public volatile C2528 f18154;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public Map f18155;

    public C4770() {
        Map map = Collections.EMPTY_MAP;
        this.f18151 = map;
        this.f18155 = map;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final void clear() {
        m9960();
        if (this.f18152 != 0) {
            this.f18150 = null;
            this.f18152 = 0;
        }
        if (this.f18151.isEmpty()) {
            return;
        }
        this.f18151.clear();
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean containsKey(Object obj) {
        Comparable comparable = (Comparable) obj;
        return m9956(comparable) >= 0 || this.f18151.containsKey(comparable);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Set entrySet() {
        if (this.f18154 == null) {
            this.f18154 = new C2528(2, this);
        }
        return this.f18154;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C4770)) {
            return super.equals(obj);
        }
        C4770 c4770 = (C4770) obj;
        int size = size();
        if (size == c4770.size()) {
            int i = this.f18152;
            if (i != c4770.f18152) {
                return entrySet().equals(c4770.entrySet());
            }
            for (int i2 = 0; i2 < i; i2++) {
                if (m9957(i2).equals(c4770.m9957(i2))) {
                }
            }
            if (i != size) {
                return this.f18151.equals(c4770.f18151);
            }
            return true;
        }
        return false;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object get(Object obj) {
        Comparable comparable = (Comparable) obj;
        int iM9956 = m9956(comparable);
        return iM9956 >= 0 ? ((C1552) this.f18150[iM9956]).f6235 : this.f18151.get(comparable);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final int hashCode() {
        int i = this.f18152;
        int iHashCode = 0;
        for (int i2 = 0; i2 < i; i2++) {
            iHashCode += this.f18150[i2].hashCode();
        }
        return this.f18151.size() > 0 ? this.f18151.hashCode() + iHashCode : iHashCode;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object remove(Object obj) {
        m9960();
        Comparable comparable = (Comparable) obj;
        int iM9956 = m9956(comparable);
        if (iM9956 >= 0) {
            return m9959(iM9956);
        }
        if (this.f18151.isEmpty()) {
            return null;
        }
        return this.f18151.remove(comparable);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final int size() {
        return this.f18151.size() + this.f18152;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final Set m9954() {
        return this.f18151.isEmpty() ? Collections.EMPTY_SET : this.f18151.entrySet();
    }

    @Override // java.util.AbstractMap, java.util.Map
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters and merged with bridge method [inline-methods] */
    public final Object put(Comparable comparable, Object obj) {
        m9960();
        int iM9956 = m9956(comparable);
        if (iM9956 >= 0) {
            return ((C1552) this.f18150[iM9956]).setValue(obj);
        }
        m9960();
        if (this.f18150 == null) {
            this.f18150 = new Object[16];
        }
        int i = -(iM9956 + 1);
        if (i >= 16) {
            return m9958().put(comparable, obj);
        }
        if (this.f18152 == 16) {
            C1552 c1552 = (C1552) this.f18150[15];
            this.f18152 = 15;
            m9958().put(c1552.f6233, c1552.f6235);
        }
        Object[] objArr = this.f18150;
        int length = objArr.length;
        System.arraycopy(objArr, i, objArr, i + 1, 15 - i);
        this.f18150[i] = new C1552(this, comparable, obj);
        this.f18152++;
        return null;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final int m9956(Comparable comparable) {
        int i = this.f18152;
        int i2 = i - 1;
        int i3 = 0;
        if (i2 >= 0) {
            int iCompareTo = comparable.compareTo(((C1552) this.f18150[i2]).f6233);
            if (iCompareTo > 0) {
                return -(i + 1);
            }
            if (iCompareTo == 0) {
                return i2;
            }
        }
        while (i3 <= i2) {
            int i4 = (i3 + i2) / 2;
            int iCompareTo2 = comparable.compareTo(((C1552) this.f18150[i4]).f6233);
            if (iCompareTo2 < 0) {
                i2 = i4 - 1;
            } else {
                if (iCompareTo2 <= 0) {
                    return i4;
                }
                i3 = i4 + 1;
            }
        }
        return -(i3 + 1);
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final C1552 m9957(int i) {
        if (i < this.f18152) {
            return (C1552) this.f18150[i];
        }
        throw new ArrayIndexOutOfBoundsException(i);
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final SortedMap m9958() {
        m9960();
        if (this.f18151.isEmpty() && !(this.f18151 instanceof TreeMap)) {
            TreeMap treeMap = new TreeMap();
            this.f18151 = treeMap;
            this.f18155 = treeMap.descendingMap();
        }
        return (SortedMap) this.f18151;
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final Object m9959(int i) {
        m9960();
        Object[] objArr = this.f18150;
        Object obj = ((C1552) objArr[i]).f6235;
        System.arraycopy(objArr, i + 1, objArr, i, (this.f18152 - i) - 1);
        this.f18152--;
        if (!this.f18151.isEmpty()) {
            Iterator it = m9958().entrySet().iterator();
            Object[] objArr2 = this.f18150;
            int i2 = this.f18152;
            Map.Entry entry = (Map.Entry) it.next();
            objArr2[i2] = new C1552(this, (Comparable) entry.getKey(), entry.getValue());
            this.f18152++;
            it.remove();
        }
        return obj;
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final void m9960() {
        if (this.f18153) {
            C1390.m3978();
        }
    }
}
