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;

/* renamed from: ːʢʣˑ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1941 extends AbstractMap {

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public Map f7818;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public int f7819;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public volatile C3326 f7820;

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

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public boolean f7822;

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

    public C1941() {
        Map map = Collections.EMPTY_MAP;
        this.f7823 = map;
        this.f7818 = map;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final void clear() {
        m5459();
        if (this.f7819 != 0) {
            this.f7821 = null;
            this.f7819 = 0;
        }
        if (this.f7823.isEmpty()) {
            return;
        }
        this.f7823.clear();
    }

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

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

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C1941)) {
            return super.equals(obj);
        }
        C1941 c1941 = (C1941) obj;
        int size = size();
        if (size == c1941.size()) {
            int i = this.f7819;
            if (i != c1941.f7819) {
                return entrySet().equals(c1941.entrySet());
            }
            for (int i2 = 0; i2 < i; i2++) {
                if (m5461(i2).equals(c1941.m5461(i2))) {
                }
            }
            if (i != size) {
                return this.f7823.equals(c1941.f7823);
            }
            return true;
        }
        return false;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object get(Object obj) {
        Comparable comparable = (Comparable) obj;
        int iM5457 = m5457(comparable);
        return iM5457 >= 0 ? ((C2072) this.f7821[iM5457]).f8251 : this.f7823.get(comparable);
    }

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

    @Override // java.util.AbstractMap, java.util.Map
    public final Object remove(Object obj) {
        m5459();
        Comparable comparable = (Comparable) obj;
        int iM5457 = m5457(comparable);
        if (iM5457 >= 0) {
            return m5463(iM5457);
        }
        if (this.f7823.isEmpty()) {
            return null;
        }
        return this.f7823.remove(comparable);
    }

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

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final int m5457(Comparable comparable) {
        int i = this.f7819;
        int i2 = i - 1;
        int i3 = 0;
        if (i2 >= 0) {
            int iCompareTo = comparable.compareTo(((C2072) this.f7821[i2]).f8252);
            if (iCompareTo > 0) {
                return -(i + 1);
            }
            if (iCompareTo == 0) {
                return i2;
            }
        }
        while (i3 <= i2) {
            int i4 = (i3 + i2) / 2;
            int iCompareTo2 = comparable.compareTo(((C2072) this.f7821[i4]).f8252);
            if (iCompareTo2 < 0) {
                i2 = i4 - 1;
            } else {
                if (iCompareTo2 <= 0) {
                    return i4;
                }
                i3 = i4 + 1;
            }
        }
        return -(i3 + 1);
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final SortedMap m5458() {
        m5459();
        if (this.f7823.isEmpty() && !(this.f7823 instanceof TreeMap)) {
            TreeMap treeMap = new TreeMap();
            this.f7823 = treeMap;
            this.f7818 = treeMap.descendingMap();
        }
        return (SortedMap) this.f7823;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m5459() {
        if (this.f7822) {
            C2585.m6504();
        }
    }

    @Override // java.util.AbstractMap, java.util.Map
    /* renamed from: ˏᵙ, reason: contains not printable characters and merged with bridge method [inline-methods] */
    public final Object put(Comparable comparable, Object obj) {
        m5459();
        int iM5457 = m5457(comparable);
        if (iM5457 >= 0) {
            return ((C2072) this.f7821[iM5457]).setValue(obj);
        }
        m5459();
        if (this.f7821 == null) {
            this.f7821 = new Object[16];
        }
        int i = -(iM5457 + 1);
        if (i >= 16) {
            return m5458().put(comparable, obj);
        }
        if (this.f7819 == 16) {
            C2072 c2072 = (C2072) this.f7821[15];
            this.f7819 = 15;
            m5458().put(c2072.f8252, c2072.f8251);
        }
        Object[] objArr = this.f7821;
        int length = objArr.length;
        System.arraycopy(objArr, i, objArr, i + 1, 15 - i);
        this.f7821[i] = new C2072(this, comparable, obj);
        this.f7819++;
        return null;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C2072 m5461(int i) {
        if (i < this.f7819) {
            return (C2072) this.f7821[i];
        }
        throw new ArrayIndexOutOfBoundsException(i);
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Set m5462() {
        return this.f7823.isEmpty() ? Collections.EMPTY_SET : this.f7823.entrySet();
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final Object m5463(int i) {
        m5459();
        Object[] objArr = this.f7821;
        Object obj = ((C2072) objArr[i]).f8251;
        System.arraycopy(objArr, i + 1, objArr, i, (this.f7819 - i) - 1);
        this.f7819--;
        if (!this.f7823.isEmpty()) {
            Iterator it = m5458().entrySet().iterator();
            Object[] objArr2 = this.f7821;
            int i2 = this.f7819;
            Map.Entry entry = (Map.Entry) it.next();
            objArr2[i2] = new C2072(this, (Comparable) entry.getKey(), entry.getValue());
            this.f7819++;
            it.remove();
        }
        return obj;
    }
}
