package defpackage;

import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
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 C0167 extends AbstractMap {

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public static final /* synthetic */ int f1583 = 0;

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

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public Map f1585;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public List f1586;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public volatile C3326 f1587;

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

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static C0167 m1338() {
        C0167 c0167 = new C0167();
        c0167.f1586 = Collections.EMPTY_LIST;
        Map map = Collections.EMPTY_MAP;
        c0167.f1584 = map;
        c0167.f1585 = map;
        return c0167;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final void clear() {
        m1343();
        if (!this.f1586.isEmpty()) {
            this.f1586.clear();
        }
        if (this.f1584.isEmpty()) {
            return;
        }
        this.f1584.clear();
    }

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

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

    @Override // java.util.AbstractMap, java.util.Map
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C0167)) {
            return super.equals(obj);
        }
        C0167 c0167 = (C0167) obj;
        int size = size();
        if (size == c0167.size()) {
            int size2 = this.f1586.size();
            if (size2 != c0167.f1586.size()) {
                return ((AbstractSet) entrySet()).equals(c0167.entrySet());
            }
            for (int i = 0; i < size2; i++) {
                if (m1341(i).equals(c0167.m1341(i))) {
                }
            }
            if (size2 != size) {
                return this.f1584.equals(c0167.f1584);
            }
            return true;
        }
        return false;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object get(Object obj) {
        Comparable comparable = (Comparable) obj;
        int iM1342 = m1342(comparable);
        return iM1342 >= 0 ? ((C3892) this.f1586.get(iM1342)).f14502 : this.f1584.get(comparable);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final int hashCode() {
        int size = this.f1586.size();
        int iHashCode = 0;
        for (int i = 0; i < size; i++) {
            iHashCode += ((C3892) this.f1586.get(i)).hashCode();
        }
        return this.f1584.size() > 0 ? this.f1584.hashCode() + iHashCode : iHashCode;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public final Object remove(Object obj) {
        m1343();
        Comparable comparable = (Comparable) obj;
        int iM1342 = m1342(comparable);
        if (iM1342 >= 0) {
            return m1344(iM1342);
        }
        if (this.f1584.isEmpty()) {
            return null;
        }
        return this.f1584.remove(comparable);
    }

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

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final SortedMap m1339() {
        m1343();
        if (this.f1584.isEmpty() && !(this.f1584 instanceof TreeMap)) {
            TreeMap treeMap = new TreeMap();
            this.f1584 = treeMap;
            this.f1585 = treeMap.descendingMap();
        }
        return (SortedMap) this.f1584;
    }

    @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) {
        m1343();
        int iM1342 = m1342(comparable);
        if (iM1342 >= 0) {
            return ((C3892) this.f1586.get(iM1342)).setValue(obj);
        }
        m1343();
        if (this.f1586.isEmpty() && !(this.f1586 instanceof ArrayList)) {
            this.f1586 = new ArrayList(16);
        }
        int i = -(iM1342 + 1);
        if (i >= 16) {
            return m1339().put(comparable, obj);
        }
        if (this.f1586.size() == 16) {
            C3892 c3892 = (C3892) this.f1586.remove(15);
            m1339().put(c3892.f14503, c3892.f14502);
        }
        this.f1586.add(i, new C3892(this, comparable, obj));
        return null;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final Map.Entry m1341(int i) {
        return (Map.Entry) this.f1586.get(i);
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0024  */
    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final int m1342(java.lang.Comparable r5) {
        /*
            r4 = this;
            java.util.List r0 = r4.f1586
            int r0 = r0.size()
            int r1 = r0 + (-1)
            if (r1 < 0) goto L21
            java.util.List r2 = r4.f1586
            java.lang.Object r2 = r2.get(r1)
            ᵪᐧʟʩ r2 = (defpackage.C3892) r2
            java.lang.Comparable r2 = r2.f14503
            int r2 = r5.compareTo(r2)
            if (r2 <= 0) goto L1e
            int r0 = r0 + 1
        L1c:
            int r4 = -r0
            return r4
        L1e:
            if (r2 != 0) goto L21
            return r1
        L21:
            r0 = 0
        L22:
            if (r0 > r1) goto L43
            int r2 = r0 + r1
            int r2 = r2 / 2
            java.util.List r3 = r4.f1586
            java.lang.Object r3 = r3.get(r2)
            ᵪᐧʟʩ r3 = (defpackage.C3892) r3
            java.lang.Comparable r3 = r3.f14503
            int r3 = r5.compareTo(r3)
            if (r3 >= 0) goto L3c
            int r2 = r2 + (-1)
            r1 = r2
            goto L22
        L3c:
            if (r3 <= 0) goto L42
            int r2 = r2 + 1
            r0 = r2
            goto L22
        L42:
            return r2
        L43:
            int r0 = r0 + 1
            goto L1c
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0167.m1342(java.lang.Comparable):int");
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m1343() {
        if (this.f1588) {
            C2585.m6504();
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final Object m1344(int i) {
        m1343();
        Object obj = ((C3892) this.f1586.remove(i)).f14502;
        if (!this.f1584.isEmpty()) {
            Iterator it = m1339().entrySet().iterator();
            List list = this.f1586;
            Map.Entry entry = (Map.Entry) it.next();
            list.add(new C3892(this, (Comparable) entry.getKey(), entry.getValue()));
            it.remove();
        }
        return obj;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final Set m1345() {
        return this.f1584.isEmpty() ? Collections.EMPTY_SET : this.f1584.entrySet();
    }
}
