package androidx.collection; 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; /* loaded from: classes.dex */ abstract class f { /* renamed from: a, reason: collision with root package name */ b f1287a; /* renamed from: b, reason: collision with root package name */ c f1288b; /* renamed from: c, reason: collision with root package name */ e f1289c; final class a implements Iterator { /* renamed from: a, reason: collision with root package name */ final int f1290a; /* renamed from: b, reason: collision with root package name */ int f1291b; /* renamed from: c, reason: collision with root package name */ int f1292c; /* renamed from: d, reason: collision with root package name */ boolean f1293d = false; a(int i10) { this.f1290a = i10; this.f1291b = f.this.d(); } @Override // java.util.Iterator public boolean hasNext() { return this.f1292c < this.f1291b; } @Override // java.util.Iterator public Object next() { if (!hasNext()) { throw new NoSuchElementException(); } Object b10 = f.this.b(this.f1292c, this.f1290a); this.f1292c++; this.f1293d = true; return b10; } @Override // java.util.Iterator public void remove() { if (!this.f1293d) { throw new IllegalStateException(); } int i10 = this.f1292c - 1; this.f1292c = i10; this.f1291b--; this.f1293d = false; f.this.h(i10); } } final class b implements Set { b() { } @Override // java.util.Set, java.util.Collection /* renamed from: a, reason: merged with bridge method [inline-methods] */ public boolean add(Map.Entry entry) { throw new UnsupportedOperationException(); } @Override // java.util.Set, java.util.Collection public boolean addAll(Collection collection) { int d10 = f.this.d(); Iterator it = collection.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); f.this.g(entry.getKey(), entry.getValue()); } return d10 != f.this.d(); } @Override // java.util.Set, java.util.Collection public void clear() { f.this.a(); } @Override // java.util.Set, java.util.Collection public boolean contains(Object obj) { if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; int e10 = f.this.e(entry.getKey()); if (e10 < 0) { return false; } return androidx.collection.c.c(f.this.b(e10, 1), entry.getValue()); } @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 f.k(this, obj); } @Override // java.util.Set, java.util.Collection public int hashCode() { int i10 = 0; for (int d10 = f.this.d() - 1; d10 >= 0; d10--) { Object b10 = f.this.b(d10, 0); Object b11 = f.this.b(d10, 1); i10 += (b10 == null ? 0 : b10.hashCode()) ^ (b11 == null ? 0 : b11.hashCode()); } return i10; } @Override // java.util.Set, java.util.Collection public boolean isEmpty() { return f.this.d() == 0; } @Override // java.util.Set, java.util.Collection, java.lang.Iterable public Iterator iterator() { return f.this.new d(); } @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 f.this.d(); } @Override // java.util.Set, java.util.Collection public Object[] toArray() { throw new UnsupportedOperationException(); } @Override // java.util.Set, java.util.Collection public Object[] toArray(Object[] objArr) { throw new UnsupportedOperationException(); } } final class c implements Set { c() { } @Override // java.util.Set, java.util.Collection public boolean add(Object obj) { throw new UnsupportedOperationException(); } @Override // java.util.Set, java.util.Collection public boolean addAll(Collection collection) { throw new UnsupportedOperationException(); } @Override // java.util.Set, java.util.Collection public void clear() { f.this.a(); } @Override // java.util.Set, java.util.Collection public boolean contains(Object obj) { return f.this.e(obj) >= 0; } @Override // java.util.Set, java.util.Collection public boolean containsAll(Collection collection) { return f.j(f.this.c(), collection); } @Override // java.util.Set, java.util.Collection public boolean equals(Object obj) { return f.k(this, obj); } @Override // java.util.Set, java.util.Collection public int hashCode() { int i10 = 0; for (int d10 = f.this.d() - 1; d10 >= 0; d10--) { Object b10 = f.this.b(d10, 0); i10 += b10 == null ? 0 : b10.hashCode(); } return i10; } @Override // java.util.Set, java.util.Collection public boolean isEmpty() { return f.this.d() == 0; } @Override // java.util.Set, java.util.Collection, java.lang.Iterable public Iterator iterator() { return f.this.new a(0); } @Override // java.util.Set, java.util.Collection public boolean remove(Object obj) { int e10 = f.this.e(obj); if (e10 < 0) { return false; } f.this.h(e10); return true; } @Override // java.util.Set, java.util.Collection public boolean removeAll(Collection collection) { return f.o(f.this.c(), collection); } @Override // java.util.Set, java.util.Collection public boolean retainAll(Collection collection) { return f.p(f.this.c(), collection); } @Override // java.util.Set, java.util.Collection public int size() { return f.this.d(); } @Override // java.util.Set, java.util.Collection public Object[] toArray() { return f.this.q(0); } @Override // java.util.Set, java.util.Collection public Object[] toArray(Object[] objArr) { return f.this.r(objArr, 0); } } final class d implements Iterator, Map.Entry { /* renamed from: a, reason: collision with root package name */ int f1297a; /* renamed from: c, reason: collision with root package name */ boolean f1299c = false; /* renamed from: b, reason: collision with root package name */ int f1298b = -1; d() { this.f1297a = f.this.d() - 1; } @Override // java.util.Iterator /* renamed from: a, reason: merged with bridge method [inline-methods] */ public Map.Entry next() { if (!hasNext()) { throw new NoSuchElementException(); } this.f1298b++; this.f1299c = true; return this; } @Override // java.util.Map.Entry public boolean equals(Object obj) { if (!this.f1299c) { throw new IllegalStateException("This container does not support retaining Map.Entry objects"); } if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; return androidx.collection.c.c(entry.getKey(), f.this.b(this.f1298b, 0)) && androidx.collection.c.c(entry.getValue(), f.this.b(this.f1298b, 1)); } @Override // java.util.Map.Entry public Object getKey() { if (this.f1299c) { return f.this.b(this.f1298b, 0); } throw new IllegalStateException("This container does not support retaining Map.Entry objects"); } @Override // java.util.Map.Entry public Object getValue() { if (this.f1299c) { return f.this.b(this.f1298b, 1); } throw new IllegalStateException("This container does not support retaining Map.Entry objects"); } @Override // java.util.Iterator public boolean hasNext() { return this.f1298b < this.f1297a; } @Override // java.util.Map.Entry public int hashCode() { if (!this.f1299c) { throw new IllegalStateException("This container does not support retaining Map.Entry objects"); } Object b10 = f.this.b(this.f1298b, 0); Object b11 = f.this.b(this.f1298b, 1); return (b10 == null ? 0 : b10.hashCode()) ^ (b11 != null ? b11.hashCode() : 0); } @Override // java.util.Iterator public void remove() { if (!this.f1299c) { throw new IllegalStateException(); } f.this.h(this.f1298b); this.f1298b--; this.f1297a--; this.f1299c = false; } @Override // java.util.Map.Entry public Object setValue(Object obj) { if (this.f1299c) { return f.this.i(this.f1298b, obj); } throw new IllegalStateException("This container does not support retaining Map.Entry objects"); } public String toString() { return getKey() + "=" + getValue(); } } final class e implements Collection { e() { } @Override // java.util.Collection public boolean add(Object obj) { throw new UnsupportedOperationException(); } @Override // java.util.Collection public boolean addAll(Collection collection) { throw new UnsupportedOperationException(); } @Override // java.util.Collection public void clear() { f.this.a(); } @Override // java.util.Collection public boolean contains(Object obj) { return f.this.f(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 f.this.d() == 0; } @Override // java.util.Collection, java.lang.Iterable public Iterator iterator() { return f.this.new a(1); } @Override // java.util.Collection public boolean remove(Object obj) { int f10 = f.this.f(obj); if (f10 < 0) { return false; } f.this.h(f10); return true; } @Override // java.util.Collection public boolean removeAll(Collection collection) { int d10 = f.this.d(); int i10 = 0; boolean z10 = false; while (i10 < d10) { if (collection.contains(f.this.b(i10, 1))) { f.this.h(i10); i10--; d10--; z10 = true; } i10++; } return z10; } @Override // java.util.Collection public boolean retainAll(Collection collection) { int d10 = f.this.d(); int i10 = 0; boolean z10 = false; while (i10 < d10) { if (!collection.contains(f.this.b(i10, 1))) { f.this.h(i10); i10--; d10--; z10 = true; } i10++; } return z10; } @Override // java.util.Collection public int size() { return f.this.d(); } @Override // java.util.Collection public Object[] toArray() { return f.this.q(1); } @Override // java.util.Collection public Object[] toArray(Object[] objArr) { return f.this.r(objArr, 1); } } f() { } public static boolean j(Map map, Collection collection) { Iterator it = collection.iterator(); while (it.hasNext()) { if (!map.containsKey(it.next())) { return false; } } return true; } public static boolean k(Set 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; } public static boolean o(Map map, Collection collection) { int size = map.size(); Iterator it = collection.iterator(); while (it.hasNext()) { map.remove(it.next()); } return size != map.size(); } public static boolean p(Map map, Collection collection) { int size = map.size(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { if (!collection.contains(it.next())) { it.remove(); } } return size != map.size(); } protected abstract void a(); protected abstract Object b(int i10, int i11); protected abstract Map c(); protected abstract int d(); protected abstract int e(Object obj); protected abstract int f(Object obj); protected abstract void g(Object obj, Object obj2); protected abstract void h(int i10); protected abstract Object i(int i10, Object obj); public Set l() { if (this.f1287a == null) { this.f1287a = new b(); } return this.f1287a; } public Set m() { if (this.f1288b == null) { this.f1288b = new c(); } return this.f1288b; } public Collection n() { if (this.f1289c == null) { this.f1289c = new e(); } return this.f1289c; } public Object[] q(int i10) { int d10 = d(); Object[] objArr = new Object[d10]; for (int i11 = 0; i11 < d10; i11++) { objArr[i11] = b(i11, i10); } return objArr; } public Object[] r(Object[] objArr, int i10) { int d10 = d(); if (objArr.length < d10) { objArr = (Object[]) Array.newInstance(objArr.getClass().getComponentType(), d10); } for (int i11 = 0; i11 < d10; i11++) { objArr[i11] = b(i11, i10); } if (objArr.length > d10) { objArr[d10] = null; } return objArr; } }