package ra; import java.io.Serializable; import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.AbstractSet; import java.util.Arrays; import java.util.Collection; import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ class k extends AbstractMap implements Serializable { /* renamed from: s reason: collision with root package name */ private static final Object f21704s = new Object(); /* renamed from: j reason: collision with root package name */ private transient Object f21705j; /* renamed from: k reason: collision with root package name */ transient int[] f21706k; /* renamed from: l reason: collision with root package name */ transient Object[] f21707l; /* renamed from: m reason: collision with root package name */ transient Object[] f21708m; /* renamed from: n reason: collision with root package name */ private transient int f21709n; /* renamed from: o reason: collision with root package name */ private transient int f21710o; /* renamed from: p reason: collision with root package name */ private transient Set f21711p; /* renamed from: q reason: collision with root package name */ private transient Set> f21712q; /* renamed from: r reason: collision with root package name */ private transient Collection f21713r; /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ class a extends k.e { a() { super(k.this, null); } @Override // ra.k.e K c(int i10) { return (K) k.this.f21707l[i10]; } } /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ class b extends k.e> { b() { super(k.this, null); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: e */ public Map.Entry c(int i10) { return new g(i10); } } /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ class c extends k.e { c() { super(k.this, null); } @Override // ra.k.e V c(int i10) { return (V) k.this.f21708m[i10]; } } /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ class d extends AbstractSet> { d() { } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public void clear() { k.this.clear(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { Map s10 = k.this.s(); if (s10 != null) { return s10.entrySet().contains(obj); } if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; int d10 = k.d(k.this, entry.getKey()); return d10 != -1 && qa.g.a(k.this.f21708m[d10], entry.getValue()); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return k.this.t(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(Object obj) { Map s10 = k.this.s(); if (s10 != null) { return s10.entrySet().remove(obj); } if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; if (k.this.D()) { return false; } int e10 = k.e(k.this); Object key = entry.getKey(); Object value = entry.getValue(); Object f2 = k.f(k.this); k kVar = k.this; int f10 = l.f(key, value, e10, f2, kVar.f21706k, kVar.f21707l, kVar.f21708m); if (f10 == -1) { return false; } k.this.C(f10, e10); k.h(k.this); k.this.x(); return true; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return k.this.size(); } } /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ private abstract class e implements Iterator { /* renamed from: j reason: collision with root package name */ int f21718j; /* renamed from: k reason: collision with root package name */ int f21719k; /* renamed from: l reason: collision with root package name */ int f21720l; private e() { this.f21718j = k.a(k.this); this.f21719k = k.this.u(); this.f21720l = -1; } /* synthetic */ e(k kVar, a aVar) { this(); } private void b() { if (k.a(k.this) != this.f21718j) { throw new ConcurrentModificationException(); } } abstract T c(int i10); void d() { this.f21718j += 32; } @Override // java.util.Iterator public boolean hasNext() { return this.f21719k >= 0; } @Override // java.util.Iterator public T next() { b(); if (hasNext()) { int i10 = this.f21719k; this.f21720l = i10; T c10 = c(i10); this.f21719k = k.this.v(this.f21719k); return c10; } throw new NoSuchElementException(); } @Override // java.util.Iterator public void remove() { b(); i.c(this.f21720l >= 0); d(); k kVar = k.this; kVar.remove(kVar.f21707l[this.f21720l]); this.f21719k = k.this.j(this.f21719k, this.f21720l); this.f21720l = -1; } } /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ class f extends AbstractSet { f() { } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public void clear() { k.this.clear(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { return k.this.containsKey(obj); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator iterator() { return k.this.B(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(Object obj) { Map s10 = k.this.s(); return s10 != null ? s10.keySet().remove(obj) : k.b(k.this, obj) != k.c(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return k.this.size(); } } /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ final class g extends e { /* renamed from: j reason: collision with root package name */ private final K f21723j; /* renamed from: k reason: collision with root package name */ private int f21724k; g(int i10) { this.f21723j = (K) k.this.f21707l[i10]; this.f21724k = i10; } private void a() { int i10 = this.f21724k; if (i10 == -1 || i10 >= k.this.size() || !qa.g.a(this.f21723j, k.this.f21707l[this.f21724k])) { this.f21724k = k.d(k.this, this.f21723j); } } @Override // ra.e, java.util.Map.Entry public K getKey() { return this.f21723j; } @Override // ra.e, java.util.Map.Entry public V getValue() { Map s10 = k.this.s(); if (s10 != null) { return s10.get(this.f21723j); } a(); int i10 = this.f21724k; if (i10 == -1) { return null; } return (V) k.this.f21708m[i10]; } @Override // java.util.Map.Entry public V setValue(V v10) { Map s10 = k.this.s(); if (s10 != null) { return s10.put(this.f21723j, v10); } a(); int i10 = this.f21724k; if (i10 == -1) { k.this.put(this.f21723j, v10); return null; } Object[] objArr = k.this.f21708m; V v11 = (V) objArr[i10]; objArr[i10] = v10; return v11; } } /* compiled from: CompactHashMap.java */ /* loaded from: classes4.dex */ class h extends AbstractCollection { h() { } @Override // java.util.AbstractCollection, java.util.Collection public void clear() { k.this.clear(); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator iterator() { return k.this.J(); } @Override // java.util.AbstractCollection, java.util.Collection public int size() { return k.this.size(); } } k() { z(3); } k(int i10) { z(i10); } private Object E(Object obj) { if (D()) { return f21704s; } int w10 = w(); int f2 = l.f(obj, null, w10, this.f21705j, this.f21706k, this.f21707l, null); if (f2 == -1) { return f21704s; } Object obj2 = this.f21708m[f2]; C(f2, w10); this.f21710o--; x(); return obj2; } private void G(int i10) { int min; int length = this.f21706k.length; if (i10 > length && (min = Math.min(1073741823, (Math.max(1, length >>> 1) + length) | 1)) != length) { F(min); } } private int H(int i10, int i11, int i12, int i13) { Object a10 = l.a(i11); int i14 = i11 - 1; if (i13 != 0) { l.i(a10, i12 & i14, i13 + 1); } Object obj = this.f21705j; int[] iArr = this.f21706k; for (int i15 = 0; i15 <= i10; i15++) { int h10 = l.h(obj, i15); while (h10 != 0) { int i16 = h10 - 1; int i17 = iArr[i16]; int b10 = l.b(i17, i10) | i15; int i18 = b10 & i14; int h11 = l.h(a10, i18); l.i(a10, i18, h10); iArr[i16] = l.d(b10, h11, i14); h10 = l.c(i17, i10); } } this.f21705j = a10; I(i14); return i14; } private void I(int i10) { this.f21709n = l.d(this.f21709n, 32 - Integer.numberOfLeadingZeros(i10), 31); } static /* synthetic */ int a(k kVar) { return kVar.f21709n; } static /* synthetic */ Object b(k kVar, Object obj) { return kVar.E(obj); } static /* synthetic */ Object c() { return f21704s; } static /* synthetic */ int d(k kVar, Object obj) { return kVar.y(obj); } static /* synthetic */ int e(k kVar) { return kVar.w(); } static /* synthetic */ Object f(k kVar) { return kVar.f21705j; } static /* synthetic */ int h(k kVar) { int i10 = kVar.f21710o; kVar.f21710o = i10 - 1; return i10; } public static k m() { return new k<>(); } public static k r(int i10) { return new k<>(i10); } private int w() { return (1 << (this.f21709n & 31)) - 1; } private int y(Object obj) { if (D()) { return -1; } int c10 = p.c(obj); int w10 = w(); int h10 = l.h(this.f21705j, c10 & w10); if (h10 == 0) { return -1; } int b10 = l.b(c10, w10); do { int i10 = h10 - 1; int i11 = this.f21706k[i10]; if (l.b(i11, w10) == b10 && qa.g.a(obj, this.f21707l[i10])) { return i10; } h10 = l.c(i11, w10); } while (h10 != 0); return -1; } void A(int i10, K k2, V v10, int i11, int i12) { this.f21706k[i10] = l.d(i11, 0, i12); this.f21707l[i10] = k2; this.f21708m[i10] = v10; } Iterator B() { Map s10 = s(); return s10 != null ? s10.keySet().iterator() : new a(); } void C(int i10, int i11) { int size = size() - 1; if (i10 < size) { Object[] objArr = this.f21707l; Object obj = objArr[size]; objArr[i10] = obj; Object[] objArr2 = this.f21708m; objArr2[i10] = objArr2[size]; objArr[size] = null; objArr2[size] = null; int[] iArr = this.f21706k; iArr[i10] = iArr[size]; iArr[size] = 0; int c10 = p.c(obj) & i11; int h10 = l.h(this.f21705j, c10); int i12 = size + 1; if (h10 == i12) { l.i(this.f21705j, c10, i10 + 1); return; } while (true) { int i13 = h10 - 1; int i14 = this.f21706k[i13]; int c11 = l.c(i14, i11); if (c11 == i12) { this.f21706k[i13] = l.d(i14, i10 + 1, i11); return; } h10 = c11; } } else { this.f21707l[i10] = null; this.f21708m[i10] = null; this.f21706k[i10] = 0; } } boolean D() { return this.f21705j == null; } void F(int i10) { this.f21706k = Arrays.copyOf(this.f21706k, i10); this.f21707l = Arrays.copyOf(this.f21707l, i10); this.f21708m = Arrays.copyOf(this.f21708m, i10); } Iterator J() { Map s10 = s(); return s10 != null ? s10.values().iterator() : new c(); } @Override // java.util.AbstractMap, java.util.Map public void clear() { if (!D()) { x(); if (s() != null) { this.f21709n = ua.c.e(size(), 3, 1073741823); this.f21705j = null; this.f21710o = 0; return; } Arrays.fill(this.f21707l, 0, this.f21710o, (Object) null); Arrays.fill(this.f21708m, 0, this.f21710o, (Object) null); l.g(this.f21705j); Arrays.fill(this.f21706k, 0, this.f21710o, 0); this.f21710o = 0; } } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(Object obj) { Map s10 = s(); return s10 != null ? s10.containsKey(obj) : y(obj) != -1; } @Override // java.util.AbstractMap, java.util.Map public boolean containsValue(Object obj) { Map s10 = s(); if (s10 != null) { return s10.containsValue(obj); } for (int i10 = 0; i10 < this.f21710o; i10++) { if (qa.g.a(obj, this.f21708m[i10])) { return true; } } return false; } @Override // java.util.AbstractMap, java.util.Map public Set> entrySet() { Set> set = this.f21712q; if (set != null) { return set; } Set> n10 = n(); this.f21712q = n10; return n10; } @Override // java.util.AbstractMap, java.util.Map public V get(Object obj) { Map s10 = s(); if (s10 != null) { return s10.get(obj); } int y10 = y(obj); if (y10 == -1) { return null; } i(y10); return (V) this.f21708m[y10]; } void i(int i10) { } @Override // java.util.AbstractMap, java.util.Map public boolean isEmpty() { return size() == 0; } int j(int i10, int i11) { return i10 - 1; } int k() { qa.h.p(D(), "Arrays already allocated"); int i10 = this.f21709n; int j10 = l.j(i10); this.f21705j = l.a(j10); I(j10 - 1); this.f21706k = new int[i10]; this.f21707l = new Object[i10]; this.f21708m = new Object[i10]; return i10; } @Override // java.util.AbstractMap, java.util.Map public Set keySet() { Set set = this.f21711p; if (set != null) { return set; } Set p10 = p(); this.f21711p = p10; return p10; } Map l() { Map o2 = o(w() + 1); int u10 = u(); while (u10 >= 0) { o2.put((K) this.f21707l[u10], (V) this.f21708m[u10]); u10 = v(u10); } this.f21705j = o2; this.f21706k = null; this.f21707l = null; this.f21708m = null; x(); return o2; } Set> n() { return new d(); } Map o(int i10) { return new LinkedHashMap(i10, 1.0f); } Set p() { return new f(); } @Override // java.util.AbstractMap, java.util.Map public V put(K k2, V v10) { int i10; if (D()) { k(); } Map s10 = s(); if (s10 != null) { return s10.put(k2, v10); } int[] iArr = this.f21706k; Object[] objArr = this.f21707l; Object[] objArr2 = this.f21708m; int i11 = this.f21710o; int i12 = i11 + 1; int c10 = p.c(k2); int w10 = w(); int i13 = c10 & w10; int h10 = l.h(this.f21705j, i13); if (h10 != 0) { int b10 = l.b(c10, w10); int i14 = 0; while (true) { int i15 = h10 - 1; int i16 = iArr[i15]; if (l.b(i16, w10) != b10 || !qa.g.a(k2, objArr[i15])) { int c11 = l.c(i16, w10); i14++; if (c11 != 0) { h10 = c11; } else if (i14 >= 9) { return l().put(k2, v10); } else { if (i12 > w10) { i10 = H(w10, l.e(w10), c10, i11); } else { iArr[i15] = l.d(i16, i12, w10); } } } else { V v11 = (V) objArr2[i15]; objArr2[i15] = v10; i(i15); return v11; } } } else if (i12 > w10) { i10 = H(w10, l.e(w10), c10, i11); } else { l.i(this.f21705j, i13, i12); i10 = w10; } G(i12); A(i11, k2, v10, c10, i10); this.f21710o = i12; x(); return null; } Collection q() { return new h(); } @Override // java.util.AbstractMap, java.util.Map public V remove(Object obj) { Map s10 = s(); if (s10 != null) { return s10.remove(obj); } V v10 = (V) E(obj); if (v10 == f21704s) { return null; } return v10; } Map s() { Object obj = this.f21705j; if (obj instanceof Map) { return (Map) obj; } return null; } @Override // java.util.AbstractMap, java.util.Map public int size() { Map s10 = s(); return s10 != null ? s10.size() : this.f21710o; } Iterator> t() { Map s10 = s(); return s10 != null ? s10.entrySet().iterator() : new b(); } int u() { return isEmpty() ? -1 : 0; } int v(int i10) { int i11 = i10 + 1; if (i11 < this.f21710o) { return i11; } return -1; } @Override // java.util.AbstractMap, java.util.Map public Collection values() { Collection collection = this.f21713r; if (collection != null) { return collection; } Collection q10 = q(); this.f21713r = q10; return q10; } void x() { this.f21709n += 32; } void z(int i10) { qa.h.e(i10 >= 0, "Expected size must be >= 0"); this.f21709n = ua.c.e(i10, 1, 1073741823); } }