package p138.p176.p177.p242.p258.p263;

import java.lang.Comparable;
import java.util.AbstractMap;
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;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ރ.ނ.ཪ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C4701<K extends Comparable<K>, V> extends AbstractMap<K, V> {

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final int f14210;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public boolean f14213;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public volatile C4379 f14214;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public List<C4674> f14211 = Collections.emptyList();

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public Map<K, V> f14212 = Collections.emptyMap();

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public Map<K, V> f14215 = Collections.emptyMap();

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static <FieldDescriptorType extends InterfaceC4432<FieldDescriptorType>> C4701<FieldDescriptorType, Object> m7864(int i) {
        return new C4698(i);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public void clear() {
        m7871();
        if (!this.f14211.isEmpty()) {
            this.f14211.clear();
        }
        if (this.f14212.isEmpty()) {
            return;
        }
        this.f14212.clear();
    }

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

    @Override // java.util.AbstractMap, java.util.Map
    public Set<Map.Entry<K, V>> entrySet() {
        if (this.f14214 == null) {
            this.f14214 = new C4379(this, null);
        }
        return this.f14214;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C4701)) {
            return super.equals(obj);
        }
        C4701 c4701 = (C4701) obj;
        int size = size();
        if (size != c4701.size()) {
            return false;
        }
        int iM7868 = m7868();
        if (iM7868 != c4701.m7868()) {
            return entrySet().equals(c4701.entrySet());
        }
        for (int i = 0; i < iM7868; i++) {
            if (!m7867(i).equals(c4701.m7867(i))) {
                return false;
            }
        }
        if (iM7868 != size) {
            return this.f14212.equals(c4701.f14212);
        }
        return true;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public V get(Object obj) {
        Comparable comparable = (Comparable) obj;
        int iM7865 = m7865(comparable);
        return iM7865 >= 0 ? this.f14211.get(iM7865).f14158 : this.f14212.get(comparable);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public int hashCode() {
        int iM7868 = m7868();
        int iHashCode = 0;
        for (int i = 0; i < iM7868; i++) {
            iHashCode += this.f14211.get(i).hashCode();
        }
        return this.f14212.size() > 0 ? iHashCode + this.f14212.hashCode() : iHashCode;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public V remove(Object obj) {
        m7871();
        Comparable comparable = (Comparable) obj;
        int iM7865 = m7865(comparable);
        if (iM7865 >= 0) {
            return m7869(iM7865);
        }
        if (this.f14212.isEmpty()) {
            return null;
        }
        return this.f14212.remove(comparable);
    }

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

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m7865(K k) {
        int size = this.f14211.size() - 1;
        if (size >= 0) {
            int iCompareTo = k.compareTo(this.f14211.get(size).f14157);
            if (iCompareTo > 0) {
                return -(size + 2);
            }
            if (iCompareTo == 0) {
                return size;
            }
        }
        int i = 0;
        while (i <= size) {
            int i2 = (i + size) / 2;
            int iCompareTo2 = k.compareTo(this.f14211.get(i2).f14157);
            if (iCompareTo2 < 0) {
                size = i2 - 1;
            } else {
                if (iCompareTo2 <= 0) {
                    return i2;
                }
                i = i2 + 1;
            }
        }
        return -(i + 1);
    }

    @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 V put(K k, V v) {
        m7871();
        int iM7865 = m7865(k);
        if (iM7865 >= 0) {
            C4674 c4674 = this.f14211.get(iM7865);
            c4674.f14159.m7871();
            V v2 = c4674.f14158;
            c4674.f14158 = v;
            return v2;
        }
        m7871();
        if (this.f14211.isEmpty() && !(this.f14211 instanceof ArrayList)) {
            this.f14211 = new ArrayList(this.f14210);
        }
        int i = -(iM7865 + 1);
        if (i >= this.f14210) {
            return m7872().put(k, v);
        }
        int size = this.f14211.size();
        int i2 = this.f14210;
        if (size == i2) {
            C4674 c4674Remove = this.f14211.remove(i2 - 1);
            m7872().put(c4674Remove.f14157, c4674Remove.f14158);
        }
        this.f14211.add(i, new C4674(this, k, v));
        return null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Map.Entry<K, V> m7867(int i) {
        return this.f14211.get(i);
    }

    /* JADX INFO: renamed from: ֏ */
    public void mo7857() {
        if (this.f14213) {
            return;
        }
        this.f14212 = this.f14212.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(this.f14212);
        this.f14215 = this.f14215.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(this.f14215);
        this.f14213 = true;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final int m7868() {
        return this.f14211.size();
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final V m7869(int i) {
        m7871();
        V v = this.f14211.remove(i).f14158;
        if (!this.f14212.isEmpty()) {
            Iterator<Map.Entry<K, V>> it = m7872().entrySet().iterator();
            this.f14211.add(new C4674(this, it.next()));
            it.remove();
        }
        return v;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final Iterable<Map.Entry<K, V>> m7870() {
        return this.f14212.isEmpty() ? (Iterable<Map.Entry<K, V>>) C4370.f13652 : this.f14212.entrySet();
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final void m7871() {
        if (this.f14213) {
            throw new UnsupportedOperationException();
        }
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final SortedMap<K, V> m7872() {
        m7871();
        if (this.f14212.isEmpty() && !(this.f14212 instanceof TreeMap)) {
            TreeMap treeMap = new TreeMap();
            this.f14212 = treeMap;
            this.f14215 = treeMap.descendingMap();
        }
        return (SortedMap) this.f14212;
    }
}
