package p037m;

import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

/* renamed from: m.f */
/* loaded from: classes.dex */
public abstract class AbstractC1451f<K, V> {

    /* renamed from: a */
    public AbstractC1451f<K, V>.C1453b f3178a;

    /* renamed from: b */
    public AbstractC1451f<K, V>.C1454c f3179b;

    /* renamed from: c */
    public AbstractC1451f<K, V>.C1456e f3180c;

    /* renamed from: m.f$a */
    /* loaded from: classes.dex */
    public final class C1452a<T> implements Iterator<T> {

        /* renamed from: d */
        public final int f3181d;

        /* renamed from: e */
        public int f3182e;

        /* renamed from: f */
        public int f3183f;

        /* renamed from: g */
        public boolean f3184g = false;

        public C1452a(int i) {
            this.f3181d = i;
            this.f3182e = AbstractC1451f.this.mo1347d();
        }

        @Override // java.util.Iterator
        public boolean hasNext() {
            return this.f3183f < this.f3182e;
        }

        @Override // java.util.Iterator
        public T next() {
            if (hasNext()) {
                T t = (T) AbstractC1451f.this.mo1349b(this.f3183f, this.f3181d);
                this.f3183f++;
                this.f3184g = true;
                return t;
            }
            throw new NoSuchElementException();
        }

        @Override // java.util.Iterator
        public void remove() {
            if (!this.f3184g) {
                throw new IllegalStateException();
            }
            int i = this.f3183f - 1;
            this.f3183f = i;
            this.f3182e--;
            this.f3184g = false;
            AbstractC1451f.this.mo1343h(i);
        }
    }

    /* renamed from: m.f$b */
    /* loaded from: classes.dex */
    public final class C1453b implements Set<Map.Entry<K, V>> {
        public C1453b() {
        }

        @Override // java.util.Set, java.util.Collection
        /* renamed from: a */
        public boolean add(Map.Entry<K, V> entry) {
            throw new UnsupportedOperationException();
        }

        @Override // java.util.Set, java.util.Collection
        public boolean addAll(Collection<? extends Map.Entry<K, V>> collection) {
            int mo1347d = AbstractC1451f.this.mo1347d();
            for (Map.Entry<K, V> entry : collection) {
                AbstractC1451f.this.mo1344g(entry.getKey(), entry.getValue());
            }
            return mo1347d != AbstractC1451f.this.mo1347d();
        }

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

        @Override // java.util.Set, java.util.Collection
        public boolean contains(Object obj) {
            if (obj instanceof Map.Entry) {
                Map.Entry entry = (Map.Entry) obj;
                int mo1346e = AbstractC1451f.this.mo1346e(entry.getKey());
                if (mo1346e < 0) {
                    return false;
                }
                return C1448c.m1372c(AbstractC1451f.this.mo1349b(mo1346e, 1), entry.getValue());
            }
            return false;
        }

        @Override // java.util.Set, java.util.Collection
        public boolean containsAll(Collection<?> collection) {
            Iterator<?> it = collection.iterator();
            while (it.hasNext()) {
                if (!contains(it.next())) {
                    return false;
                }
            }
            return true;
        }

        @Override // java.util.Set, java.util.Collection
        public boolean equals(Object obj) {
            return AbstractC1451f.m1340k(this, obj);
        }

        @Override // java.util.Set, java.util.Collection
        public int hashCode() {
            int i = 0;
            for (int mo1347d = AbstractC1451f.this.mo1347d() - 1; mo1347d >= 0; mo1347d--) {
                Object mo1349b = AbstractC1451f.this.mo1349b(mo1347d, 0);
                Object mo1349b2 = AbstractC1451f.this.mo1349b(mo1347d, 1);
                i += (mo1349b == null ? 0 : mo1349b.hashCode()) ^ (mo1349b2 == null ? 0 : mo1349b2.hashCode());
            }
            return i;
        }

        @Override // java.util.Set, java.util.Collection
        public boolean isEmpty() {
            return AbstractC1451f.this.mo1347d() == 0;
        }

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

        @Override // java.util.Set, java.util.Collection
        public boolean remove(Object obj) {
            throw new UnsupportedOperationException();
        }

        @Override // java.util.Set, java.util.Collection
        public boolean removeAll(Collection<?> collection) {
            throw new UnsupportedOperationException();
        }

        @Override // java.util.Set, java.util.Collection
        public boolean retainAll(Collection<?> collection) {
            throw new UnsupportedOperationException();
        }

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

        @Override // java.util.Set, java.util.Collection
        public Object[] toArray() {
            throw new UnsupportedOperationException();
        }

        @Override // java.util.Set, java.util.Collection
        public <T> T[] toArray(T[] tArr) {
            throw new UnsupportedOperationException();
        }
    }

    /* renamed from: m.f$c */
    /* loaded from: classes.dex */
    public final class C1454c implements Set<K> {
        public C1454c() {
        }

        @Override // java.util.Set, java.util.Collection
        public boolean add(K k) {
            throw new UnsupportedOperationException();
        }

        @Override // java.util.Set, java.util.Collection
        public boolean addAll(Collection<? extends K> collection) {
            throw new UnsupportedOperationException();
        }

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

        @Override // java.util.Set, java.util.Collection
        public boolean contains(Object obj) {
            return AbstractC1451f.this.mo1346e(obj) >= 0;
        }

        @Override // java.util.Set, java.util.Collection
        public boolean containsAll(Collection<?> collection) {
            return AbstractC1451f.m1341j(AbstractC1451f.this.mo1348c(), collection);
        }

        @Override // java.util.Set, java.util.Collection
        public boolean equals(Object obj) {
            return AbstractC1451f.m1340k(this, obj);
        }

        @Override // java.util.Set, java.util.Collection
        public int hashCode() {
            int i = 0;
            for (int mo1347d = AbstractC1451f.this.mo1347d() - 1; mo1347d >= 0; mo1347d--) {
                Object mo1349b = AbstractC1451f.this.mo1349b(mo1347d, 0);
                i += mo1349b == null ? 0 : mo1349b.hashCode();
            }
            return i;
        }

        @Override // java.util.Set, java.util.Collection
        public boolean isEmpty() {
            return AbstractC1451f.this.mo1347d() == 0;
        }

        @Override // java.util.Set, java.util.Collection, java.lang.Iterable
        public Iterator<K> iterator() {
            return new C1452a(0);
        }

        @Override // java.util.Set, java.util.Collection
        public boolean remove(Object obj) {
            int mo1346e = AbstractC1451f.this.mo1346e(obj);
            if (mo1346e >= 0) {
                AbstractC1451f.this.mo1343h(mo1346e);
                return true;
            }
            return false;
        }

        @Override // java.util.Set, java.util.Collection
        public boolean removeAll(Collection<?> collection) {
            return AbstractC1451f.m1336o(AbstractC1451f.this.mo1348c(), collection);
        }

        @Override // java.util.Set, java.util.Collection
        public boolean retainAll(Collection<?> collection) {
            return AbstractC1451f.m1335p(AbstractC1451f.this.mo1348c(), collection);
        }

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

        @Override // java.util.Set, java.util.Collection
        public Object[] toArray() {
            return AbstractC1451f.this.m1334q(0);
        }

        @Override // java.util.Set, java.util.Collection
        public <T> T[] toArray(T[] tArr) {
            return (T[]) AbstractC1451f.this.m1333r(tArr, 0);
        }
    }

    /* renamed from: m.f$d */
    /* loaded from: classes.dex */
    public final class C1455d implements Iterator<Map.Entry<K, V>>, Map.Entry<K, V> {

        /* renamed from: d */
        public int f3188d;

        /* renamed from: f */
        public boolean f3190f = false;

        /* renamed from: e */
        public int f3189e = -1;

        public C1455d() {
            this.f3188d = AbstractC1451f.this.mo1347d() - 1;
        }

        @Override // java.util.Iterator
        /* renamed from: a */
        public Map.Entry<K, V> next() {
            if (hasNext()) {
                this.f3189e++;
                this.f3190f = true;
                return this;
            }
            throw new NoSuchElementException();
        }

        @Override // java.util.Map.Entry
        public boolean equals(Object obj) {
            if (this.f3190f) {
                if (obj instanceof Map.Entry) {
                    Map.Entry entry = (Map.Entry) obj;
                    return C1448c.m1372c(entry.getKey(), AbstractC1451f.this.mo1349b(this.f3189e, 0)) && C1448c.m1372c(entry.getValue(), AbstractC1451f.this.mo1349b(this.f3189e, 1));
                }
                return false;
            }
            throw new IllegalStateException("This container does not support retaining Map.Entry objects");
        }

        @Override // java.util.Map.Entry
        public K getKey() {
            if (this.f3190f) {
                return (K) AbstractC1451f.this.mo1349b(this.f3189e, 0);
            }
            throw new IllegalStateException("This container does not support retaining Map.Entry objects");
        }

        @Override // java.util.Map.Entry
        public V getValue() {
            if (this.f3190f) {
                return (V) AbstractC1451f.this.mo1349b(this.f3189e, 1);
            }
            throw new IllegalStateException("This container does not support retaining Map.Entry objects");
        }

        @Override // java.util.Iterator
        public boolean hasNext() {
            return this.f3189e < this.f3188d;
        }

        @Override // java.util.Map.Entry
        public int hashCode() {
            if (this.f3190f) {
                Object mo1349b = AbstractC1451f.this.mo1349b(this.f3189e, 0);
                Object mo1349b2 = AbstractC1451f.this.mo1349b(this.f3189e, 1);
                return (mo1349b == null ? 0 : mo1349b.hashCode()) ^ (mo1349b2 != null ? mo1349b2.hashCode() : 0);
            }
            throw new IllegalStateException("This container does not support retaining Map.Entry objects");
        }

        @Override // java.util.Iterator
        public void remove() {
            if (!this.f3190f) {
                throw new IllegalStateException();
            }
            AbstractC1451f.this.mo1343h(this.f3189e);
            this.f3189e--;
            this.f3188d--;
            this.f3190f = false;
        }

        @Override // java.util.Map.Entry
        public V setValue(V v) {
            if (this.f3190f) {
                return (V) AbstractC1451f.this.mo1342i(this.f3189e, v);
            }
            throw new IllegalStateException("This container does not support retaining Map.Entry objects");
        }

        public String toString() {
            return getKey() + "=" + getValue();
        }
    }

    /* renamed from: m.f$e */
    /* loaded from: classes.dex */
    public final class C1456e implements Collection<V> {
        public C1456e() {
        }

        @Override // java.util.Collection
        public boolean add(V v) {
            throw new UnsupportedOperationException();
        }

        @Override // java.util.Collection
        public boolean addAll(Collection<? extends V> collection) {
            throw new UnsupportedOperationException();
        }

        @Override // java.util.Collection
        public void clear() {
            AbstractC1451f.this.mo1350a();
        }

        @Override // java.util.Collection
        public boolean contains(Object obj) {
            return AbstractC1451f.this.mo1345f(obj) >= 0;
        }

        @Override // java.util.Collection
        public boolean containsAll(Collection<?> collection) {
            Iterator<?> it = collection.iterator();
            while (it.hasNext()) {
                if (!contains(it.next())) {
                    return false;
                }
            }
            return true;
        }

        @Override // java.util.Collection
        public boolean isEmpty() {
            return AbstractC1451f.this.mo1347d() == 0;
        }

        @Override // java.util.Collection, java.lang.Iterable
        public Iterator<V> iterator() {
            return new C1452a(1);
        }

        @Override // java.util.Collection
        public boolean remove(Object obj) {
            int mo1345f = AbstractC1451f.this.mo1345f(obj);
            if (mo1345f >= 0) {
                AbstractC1451f.this.mo1343h(mo1345f);
                return true;
            }
            return false;
        }

        @Override // java.util.Collection
        public boolean removeAll(Collection<?> collection) {
            int mo1347d = AbstractC1451f.this.mo1347d();
            int i = 0;
            boolean z = false;
            while (i < mo1347d) {
                if (collection.contains(AbstractC1451f.this.mo1349b(i, 1))) {
                    AbstractC1451f.this.mo1343h(i);
                    i--;
                    mo1347d--;
                    z = true;
                }
                i++;
            }
            return z;
        }

        @Override // java.util.Collection
        public boolean retainAll(Collection<?> collection) {
            int mo1347d = AbstractC1451f.this.mo1347d();
            int i = 0;
            boolean z = false;
            while (i < mo1347d) {
                if (!collection.contains(AbstractC1451f.this.mo1349b(i, 1))) {
                    AbstractC1451f.this.mo1343h(i);
                    i--;
                    mo1347d--;
                    z = true;
                }
                i++;
            }
            return z;
        }

        @Override // java.util.Collection
        public int size() {
            return AbstractC1451f.this.mo1347d();
        }

        @Override // java.util.Collection
        public Object[] toArray() {
            return AbstractC1451f.this.m1334q(1);
        }

        @Override // java.util.Collection
        public <T> T[] toArray(T[] tArr) {
            return (T[]) AbstractC1451f.this.m1333r(tArr, 1);
        }
    }

    /* renamed from: j */
    public static <K, V> boolean m1341j(Map<K, V> map, Collection<?> collection) {
        Iterator<?> it = collection.iterator();
        while (it.hasNext()) {
            if (!map.containsKey(it.next())) {
                return false;
            }
        }
        return true;
    }

    /* renamed from: k */
    public static <T> boolean m1340k(Set<T> set, Object obj) {
        if (set == obj) {
            return true;
        }
        if (obj instanceof Set) {
            Set set2 = (Set) obj;
            try {
                if (set.size() == set2.size()) {
                    if (set.containsAll(set2)) {
                        return true;
                    }
                }
                return false;
            } catch (ClassCastException | NullPointerException unused) {
            }
        }
        return false;
    }

    /* renamed from: o */
    public static <K, V> boolean m1336o(Map<K, V> map, Collection<?> collection) {
        int size = map.size();
        Iterator<?> it = collection.iterator();
        while (it.hasNext()) {
            map.remove(it.next());
        }
        return size != map.size();
    }

    /* renamed from: p */
    public static <K, V> boolean m1335p(Map<K, V> map, Collection<?> collection) {
        int size = map.size();
        Iterator<K> it = map.keySet().iterator();
        while (it.hasNext()) {
            if (!collection.contains(it.next())) {
                it.remove();
            }
        }
        return size != map.size();
    }

    /* renamed from: a */
    public abstract void mo1350a();

    /* renamed from: b */
    public abstract Object mo1349b(int i, int i2);

    /* renamed from: c */
    public abstract Map<K, V> mo1348c();

    /* renamed from: d */
    public abstract int mo1347d();

    /* renamed from: e */
    public abstract int mo1346e(Object obj);

    /* renamed from: f */
    public abstract int mo1345f(Object obj);

    /* renamed from: g */
    public abstract void mo1344g(K k, V v);

    /* renamed from: h */
    public abstract void mo1343h(int i);

    /* renamed from: i */
    public abstract V mo1342i(int i, V v);

    /* renamed from: l */
    public Set<Map.Entry<K, V>> m1339l() {
        if (this.f3178a == null) {
            this.f3178a = new C1453b();
        }
        return this.f3178a;
    }

    /* renamed from: m */
    public Set<K> m1338m() {
        if (this.f3179b == null) {
            this.f3179b = new C1454c();
        }
        return this.f3179b;
    }

    /* renamed from: n */
    public Collection<V> m1337n() {
        if (this.f3180c == null) {
            this.f3180c = new C1456e();
        }
        return this.f3180c;
    }

    /* renamed from: q */
    public Object[] m1334q(int i) {
        int mo1347d = mo1347d();
        Object[] objArr = new Object[mo1347d];
        for (int i2 = 0; i2 < mo1347d; i2++) {
            objArr[i2] = mo1349b(i2, i);
        }
        return objArr;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: r */
    public <T> T[] m1333r(T[] tArr, int i) {
        int mo1347d = mo1347d();
        if (tArr.length < mo1347d) {
            tArr = (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), mo1347d));
        }
        for (int i2 = 0; i2 < mo1347d; i2++) {
            tArr[i2] = mo1349b(i2, i);
        }
        if (tArr.length > mo1347d) {
            tArr[mo1347d] = null;
        }
        return tArr;
    }
}