package p138.p176.p328;

import java.lang.Comparable;
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.NoSuchElementException;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import p138.p176.p328.C6026;

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

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

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public List<C6054<K, V>.C6059> f16944 = Collections.emptyList();

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

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

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public volatile C6054<K, V>.C6061 f16947;

    /* JADX INFO: Add missing generic type declarations: [FieldDescriptorType] */
    /* JADX INFO: renamed from: ދ.ހ.ނ.ސ$֏, reason: contains not printable characters */
    public static class C6055<FieldDescriptorType> extends C6054<FieldDescriptorType, Object> {
        public C6055(int i) {
            super(i, null);
        }

        @Override // p138.p176.p328.C6054, java.util.AbstractMap, java.util.Map
        public /* bridge */ /* synthetic */ Object put(Object obj, Object obj2) {
            return super.put((C6026.InterfaceC6027) obj, obj2);
        }

        @Override // p138.p176.p328.C6054
        /* JADX INFO: renamed from: ނ */
        public void mo9433() {
            if (!this.f16946) {
                for (int i = 0; i < m9429(); i++) {
                    Map.Entry<FieldDescriptorType, Object> entryM9427 = m9427(i);
                    if (((C6026.InterfaceC6027) entryM9427.getKey()).mo9388()) {
                        entryM9427.setValue(Collections.unmodifiableList((List) entryM9427.getValue()));
                    }
                }
                for (Map.Entry<FieldDescriptorType, Object> entry : m9431()) {
                    if (((C6026.InterfaceC6027) entry.getKey()).mo9388()) {
                        entry.setValue(Collections.unmodifiableList((List) entry.getValue()));
                    }
                }
            }
            super.mo9433();
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ނ.ސ$ؠ, reason: contains not printable characters */
    public static class C6056 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static final Iterator<Object> f16948 = new C6057();

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public static final Iterable<Object> f16949 = new C6058();

        /* JADX INFO: renamed from: ދ.ހ.ނ.ސ$ؠ$֏, reason: contains not printable characters */
        public static class C6057 implements Iterator<Object> {
            @Override // java.util.Iterator
            public boolean hasNext() {
                return false;
            }

            @Override // java.util.Iterator
            public Object next() {
                throw new NoSuchElementException();
            }

            @Override // java.util.Iterator
            public void remove() {
                throw new UnsupportedOperationException();
            }
        }

        /* JADX INFO: renamed from: ދ.ހ.ނ.ސ$ؠ$ؠ, reason: contains not printable characters */
        public static class C6058 implements Iterable<Object> {
            @Override // java.lang.Iterable
            public Iterator<Object> iterator() {
                return C6056.f16948;
            }
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ނ.ސ$ހ, reason: contains not printable characters */
    public class C6059 implements Map.Entry<K, V>, Comparable<C6054<K, V>.C6059> {

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

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public V f16951;

        public C6059(K k, V v) {
            this.f16950 = k;
            this.f16951 = v;
        }

        public C6059(C6054 c6054, Map.Entry<K, V> entry) {
            K key = entry.getKey();
            V value = entry.getValue();
            C6054.this = c6054;
            this.f16950 = key;
            this.f16951 = value;
        }

        @Override // java.lang.Comparable
        public int compareTo(Object obj) {
            return this.f16950.compareTo(((C6059) obj).f16950);
        }

        @Override // java.util.Map.Entry
        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            }
            if (!(obj instanceof Map.Entry)) {
                return false;
            }
            Map.Entry entry = (Map.Entry) obj;
            K k = this.f16950;
            Object key = entry.getKey();
            if (k == null ? key == null : k.equals(key)) {
                V v = this.f16951;
                Object value = entry.getValue();
                if (v == null ? value == null : v.equals(value)) {
                    return true;
                }
            }
            return false;
        }

        @Override // java.util.Map.Entry
        public Object getKey() {
            return this.f16950;
        }

        @Override // java.util.Map.Entry
        public V getValue() {
            return this.f16951;
        }

        @Override // java.util.Map.Entry
        public int hashCode() {
            K k = this.f16950;
            int iHashCode = k == null ? 0 : k.hashCode();
            V v = this.f16951;
            return iHashCode ^ (v != null ? v.hashCode() : 0);
        }

        @Override // java.util.Map.Entry
        public V setValue(V v) {
            C6054.this.m9428();
            V v2 = this.f16951;
            this.f16951 = v;
            return v2;
        }

        public String toString() {
            return this.f16950 + "=" + this.f16951;
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ނ.ސ$ށ, reason: contains not printable characters */
    public class C6060 implements Iterator<Map.Entry<K, V>> {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public int f16953 = -1;

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

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public Iterator<Map.Entry<K, V>> f16955;

        public /* synthetic */ C6060(C6055 c6055) {
        }

        @Override // java.util.Iterator
        public boolean hasNext() {
            return this.f16953 + 1 < C6054.this.f16944.size() || m9434().hasNext();
        }

        @Override // java.util.Iterator
        public Object next() {
            this.f16954 = true;
            int i = this.f16953 + 1;
            this.f16953 = i;
            return i < C6054.this.f16944.size() ? C6054.this.f16944.get(this.f16953) : m9434().next();
        }

        @Override // java.util.Iterator
        public void remove() {
            if (!this.f16954) {
                throw new IllegalStateException("remove() was called before next()");
            }
            this.f16954 = false;
            C6054.this.m9428();
            if (this.f16953 >= C6054.this.f16944.size()) {
                m9434().remove();
                return;
            }
            C6054 c6054 = C6054.this;
            int i = this.f16953;
            this.f16953 = i - 1;
            c6054.m9430(i);
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final Iterator<Map.Entry<K, V>> m9434() {
            if (this.f16955 == null) {
                this.f16955 = C6054.this.f16945.entrySet().iterator();
            }
            return this.f16955;
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.ނ.ސ$ނ, reason: contains not printable characters */
    public class C6061 extends AbstractSet<Map.Entry<K, V>> {
        public /* synthetic */ C6061(C6055 c6055) {
        }

        /* JADX WARN: Multi-variable type inference failed */
        @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
        public boolean add(Object obj) {
            Map.Entry entry = (Map.Entry) obj;
            if (contains(entry)) {
                return false;
            }
            C6054.this.put((Comparable) entry.getKey(), entry.getValue());
            return true;
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
        public void clear() {
            C6054.this.clear();
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
        public boolean contains(Object obj) {
            Map.Entry entry = (Map.Entry) obj;
            Object obj2 = C6054.this.get(entry.getKey());
            Object value = entry.getValue();
            return obj2 == value || (obj2 != null && obj2.equals(value));
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
        public Iterator<Map.Entry<K, V>> iterator() {
            return new C6060(null);
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
        public boolean remove(Object obj) {
            Map.Entry entry = (Map.Entry) obj;
            if (!contains(entry)) {
                return false;
            }
            C6054.this.remove(entry.getKey());
            return true;
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
        public int size() {
            return C6054.this.size();
        }
    }

    public /* synthetic */ C6054(int i, C6055 c6055) {
        this.f16943 = i;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static <FieldDescriptorType extends C6026.InterfaceC6027<FieldDescriptorType>> C6054<FieldDescriptorType, Object> m9424(int i) {
        return new C6055(i);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public void clear() {
        m9428();
        if (!this.f16944.isEmpty()) {
            this.f16944.clear();
        }
        if (this.f16945.isEmpty()) {
            return;
        }
        this.f16945.clear();
    }

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

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

    @Override // java.util.AbstractMap, java.util.Map
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C6054)) {
            return super.equals(obj);
        }
        C6054 c6054 = (C6054) obj;
        int size = size();
        if (size != c6054.size()) {
            return false;
        }
        int iM9429 = m9429();
        if (iM9429 != c6054.m9429()) {
            return entrySet().equals(c6054.entrySet());
        }
        for (int i = 0; i < iM9429; i++) {
            if (!m9427(i).equals(c6054.m9427(i))) {
                return false;
            }
        }
        if (iM9429 != size) {
            return this.f16945.equals(c6054.f16945);
        }
        return true;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public V get(Object obj) {
        Comparable comparable = (Comparable) obj;
        int iM9425 = m9425(comparable);
        return iM9425 >= 0 ? this.f16944.get(iM9425).f16951 : this.f16945.get(comparable);
    }

    @Override // java.util.AbstractMap, java.util.Map
    public int hashCode() {
        int iM9429 = m9429();
        int iHashCode = 0;
        for (int i = 0; i < iM9429; i++) {
            iHashCode += this.f16944.get(i).hashCode();
        }
        return this.f16945.size() > 0 ? iHashCode + this.f16945.hashCode() : iHashCode;
    }

    @Override // java.util.AbstractMap, java.util.Map
    public V remove(Object obj) {
        m9428();
        Comparable comparable = (Comparable) obj;
        int iM9425 = m9425(comparable);
        if (iM9425 >= 0) {
            return m9430(iM9425);
        }
        if (this.f16945.isEmpty()) {
            return null;
        }
        return this.f16945.remove(comparable);
    }

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

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m9425(K k) {
        int size = this.f16944.size() - 1;
        if (size >= 0) {
            int iCompareTo = k.compareTo(this.f16944.get(size).f16950);
            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.f16944.get(i2).f16950);
            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 V put(K k, V v) {
        m9428();
        int iM9425 = m9425(k);
        if (iM9425 >= 0) {
            C6054<K, V>.C6059 c6059 = this.f16944.get(iM9425);
            C6054.this.m9428();
            V v2 = c6059.f16951;
            c6059.f16951 = v;
            return v2;
        }
        m9428();
        if (this.f16944.isEmpty() && !(this.f16944 instanceof ArrayList)) {
            this.f16944 = new ArrayList(this.f16943);
        }
        int i = -(iM9425 + 1);
        if (i >= this.f16943) {
            return m9432().put(k, v);
        }
        int size = this.f16944.size();
        int i2 = this.f16943;
        if (size == i2) {
            C6054<K, V>.C6059 c6059Remove = this.f16944.remove(i2 - 1);
            m9432().put(c6059Remove.f16950, c6059Remove.f16951);
        }
        this.f16944.add(i, new C6059(k, v));
        return null;
    }

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

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

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

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final V m9430(int i) {
        m9428();
        V v = this.f16944.remove(i).f16951;
        if (!this.f16945.isEmpty()) {
            Iterator<Map.Entry<K, V>> it = m9432().entrySet().iterator();
            this.f16944.add(new C6059(this, it.next()));
            it.remove();
        }
        return v;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public Iterable<Map.Entry<K, V>> m9431() {
        return this.f16945.isEmpty() ? (Iterable<Map.Entry<K, V>>) C6056.f16949 : this.f16945.entrySet();
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final SortedMap<K, V> m9432() {
        m9428();
        if (this.f16945.isEmpty() && !(this.f16945 instanceof TreeMap)) {
            this.f16945 = new TreeMap();
        }
        return (SortedMap) this.f16945;
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public void mo9433() {
        if (this.f16946) {
            return;
        }
        this.f16945 = this.f16945.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(this.f16945);
        this.f16946 = true;
    }
}
