package p037m; import java.util.ConcurrentModificationException; import java.util.Map; /* renamed from: m.g */ /* loaded from: classes.dex */ public class C1457g { /* renamed from: g */ public static Object[] f3193g; /* renamed from: h */ public static int f3194h; /* renamed from: i */ public static Object[] f3195i; /* renamed from: j */ public static int f3196j; /* renamed from: d */ public int[] f3197d; /* renamed from: e */ public Object[] f3198e; /* renamed from: f */ public int f3199f; public C1457g() { this.f3197d = C1448c.f3162a; this.f3198e = C1448c.f3164c; this.f3199f = 0; } public C1457g(int i) { if (i == 0) { this.f3197d = C1448c.f3162a; this.f3198e = C1448c.f3164c; } else { m1330a(i); } this.f3199f = 0; } /* renamed from: a */ private void m1330a(int i) { if (i == 8) { synchronized (C1457g.class) { Object[] objArr = f3195i; if (objArr != null) { this.f3198e = objArr; f3195i = (Object[]) objArr[0]; this.f3197d = (int[]) objArr[1]; objArr[1] = null; objArr[0] = null; f3196j--; return; } } } else if (i == 4) { synchronized (C1457g.class) { Object[] objArr2 = f3193g; if (objArr2 != null) { this.f3198e = objArr2; f3193g = (Object[]) objArr2[0]; this.f3197d = (int[]) objArr2[1]; objArr2[1] = null; objArr2[0] = null; f3194h--; return; } } } this.f3197d = new int[i]; this.f3198e = new Object[i << 1]; } /* renamed from: b */ public static int m1329b(int[] iArr, int i, int i2) { try { return C1448c.m1374a(iArr, i, i2); } catch (ArrayIndexOutOfBoundsException unused) { throw new ConcurrentModificationException(); } } /* renamed from: d */ public static void m1327d(int[] iArr, Object[] objArr, int i) { if (iArr.length == 8) { synchronized (C1457g.class) { if (f3196j < 10) { objArr[0] = f3195i; objArr[1] = iArr; for (int i2 = (i << 1) - 1; i2 >= 2; i2--) { objArr[i2] = null; } f3195i = objArr; f3196j++; } } } else if (iArr.length == 4) { synchronized (C1457g.class) { if (f3194h < 10) { objArr[0] = f3193g; objArr[1] = iArr; for (int i3 = (i << 1) - 1; i3 >= 2; i3--) { objArr[i3] = null; } f3193g = objArr; f3194h++; } } } } /* renamed from: c */ public void m1328c(int i) { int i2 = this.f3199f; int[] iArr = this.f3197d; if (iArr.length < i) { Object[] objArr = this.f3198e; m1330a(i); if (this.f3199f > 0) { System.arraycopy(iArr, 0, this.f3197d, 0, i2); System.arraycopy(objArr, 0, this.f3198e, 0, i2 << 1); } m1327d(iArr, objArr, i2); } if (this.f3199f != i2) { throw new ConcurrentModificationException(); } } public void clear() { int i = this.f3199f; if (i > 0) { int[] iArr = this.f3197d; Object[] objArr = this.f3198e; this.f3197d = C1448c.f3162a; this.f3198e = C1448c.f3164c; this.f3199f = 0; m1327d(iArr, objArr, i); } if (this.f3199f > 0) { throw new ConcurrentModificationException(); } } public boolean containsKey(Object obj) { return m1325f(obj) >= 0; } public boolean containsValue(Object obj) { return m1323h(obj) >= 0; } /* renamed from: e */ public int m1326e(Object obj, int i) { int i2 = this.f3199f; if (i2 == 0) { return -1; } int m1329b = m1329b(this.f3197d, i2, i); if (m1329b >= 0 && !obj.equals(this.f3198e[m1329b << 1])) { int i3 = m1329b + 1; while (i3 < i2 && this.f3197d[i3] == i) { if (obj.equals(this.f3198e[i3 << 1])) { return i3; } i3++; } for (int i4 = m1329b - 1; i4 >= 0 && this.f3197d[i4] == i; i4--) { if (obj.equals(this.f3198e[i4 << 1])) { return i4; } } return i3 ^ (-1); } return m1329b; } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof C1457g) { C1457g c1457g = (C1457g) obj; if (size() != c1457g.size()) { return false; } for (int i = 0; i < this.f3199f; i++) { try { K m1322i = m1322i(i); V m1319l = m1319l(i); Object obj2 = c1457g.get(m1322i); if (m1319l == null) { if (obj2 != null || !c1457g.containsKey(m1322i)) { return false; } } else if (!m1319l.equals(obj2)) { return false; } } catch (ClassCastException | NullPointerException unused) { return false; } } return true; } if (obj instanceof Map) { Map map = (Map) obj; if (size() != map.size()) { return false; } for (int i2 = 0; i2 < this.f3199f; i2++) { try { K m1322i2 = m1322i(i2); V m1319l2 = m1319l(i2); Object obj3 = map.get(m1322i2); if (m1319l2 == null) { if (obj3 != null || !map.containsKey(m1322i2)) { return false; } } else if (!m1319l2.equals(obj3)) { return false; } } catch (ClassCastException | NullPointerException unused2) { } } return true; } return false; } /* renamed from: f */ public int m1325f(Object obj) { return obj == null ? m1324g() : m1326e(obj, obj.hashCode()); } /* renamed from: g */ public int m1324g() { int i = this.f3199f; if (i == 0) { return -1; } int m1329b = m1329b(this.f3197d, i, 0); if (m1329b >= 0 && this.f3198e[m1329b << 1] != null) { int i2 = m1329b + 1; while (i2 < i && this.f3197d[i2] == 0) { if (this.f3198e[i2 << 1] == null) { return i2; } i2++; } for (int i3 = m1329b - 1; i3 >= 0 && this.f3197d[i3] == 0; i3--) { if (this.f3198e[i3 << 1] == null) { return i3; } } return i2 ^ (-1); } return m1329b; } public V get(Object obj) { return getOrDefault(obj, null); } public V getOrDefault(Object obj, V v) { int m1325f = m1325f(obj); return m1325f >= 0 ? (V) this.f3198e[(m1325f << 1) + 1] : v; } /* renamed from: h */ public int m1323h(Object obj) { int i = this.f3199f * 2; Object[] objArr = this.f3198e; if (obj == null) { for (int i2 = 1; i2 < i; i2 += 2) { if (objArr[i2] == null) { return i2 >> 1; } } return -1; } for (int i3 = 1; i3 < i; i3 += 2) { if (obj.equals(objArr[i3])) { return i3 >> 1; } } return -1; } public int hashCode() { int[] iArr = this.f3197d; Object[] objArr = this.f3198e; int i = this.f3199f; int i2 = 1; int i3 = 0; int i4 = 0; while (i3 < i) { Object obj = objArr[i2]; i4 += (obj == null ? 0 : obj.hashCode()) ^ iArr[i3]; i3++; i2 += 2; } return i4; } /* renamed from: i */ public K m1322i(int i) { return (K) this.f3198e[i << 1]; } public boolean isEmpty() { return this.f3199f <= 0; } /* renamed from: j */ public V m1321j(int i) { Object[] objArr = this.f3198e; int i2 = i << 1; V v = (V) objArr[i2 + 1]; int i3 = this.f3199f; int i4 = 0; if (i3 <= 1) { m1327d(this.f3197d, objArr, i3); this.f3197d = C1448c.f3162a; this.f3198e = C1448c.f3164c; } else { int i5 = i3 - 1; int[] iArr = this.f3197d; if (iArr.length <= 8 || i3 >= iArr.length / 3) { if (i < i5) { int i6 = i + 1; int i7 = i5 - i; System.arraycopy(iArr, i6, iArr, i, i7); Object[] objArr2 = this.f3198e; System.arraycopy(objArr2, i6 << 1, objArr2, i2, i7 << 1); } Object[] objArr3 = this.f3198e; int i8 = i5 << 1; objArr3[i8] = null; objArr3[i8 + 1] = null; } else { m1330a(i3 > 8 ? i3 + (i3 >> 1) : 8); if (i3 != this.f3199f) { throw new ConcurrentModificationException(); } if (i > 0) { System.arraycopy(iArr, 0, this.f3197d, 0, i); System.arraycopy(objArr, 0, this.f3198e, 0, i2); } if (i < i5) { int i9 = i + 1; int i10 = i5 - i; System.arraycopy(iArr, i9, this.f3197d, i, i10); System.arraycopy(objArr, i9 << 1, this.f3198e, i2, i10 << 1); } } i4 = i5; } if (i3 == this.f3199f) { this.f3199f = i4; return v; } throw new ConcurrentModificationException(); } /* renamed from: k */ public V m1320k(int i, V v) { int i2 = (i << 1) + 1; Object[] objArr = this.f3198e; V v2 = (V) objArr[i2]; objArr[i2] = v; return v2; } /* renamed from: l */ public V m1319l(int i) { return (V) this.f3198e[(i << 1) + 1]; } public V put(K k, V v) { int i; int m1326e; int i2 = this.f3199f; if (k == null) { m1326e = m1324g(); i = 0; } else { int hashCode = k.hashCode(); i = hashCode; m1326e = m1326e(k, hashCode); } if (m1326e >= 0) { int i3 = (m1326e << 1) + 1; Object[] objArr = this.f3198e; V v2 = (V) objArr[i3]; objArr[i3] = v; return v2; } int i4 = m1326e ^ (-1); int[] iArr = this.f3197d; if (i2 >= iArr.length) { int i5 = 8; if (i2 >= 8) { i5 = (i2 >> 1) + i2; } else if (i2 < 4) { i5 = 4; } Object[] objArr2 = this.f3198e; m1330a(i5); if (i2 != this.f3199f) { throw new ConcurrentModificationException(); } int[] iArr2 = this.f3197d; if (iArr2.length > 0) { System.arraycopy(iArr, 0, iArr2, 0, iArr.length); System.arraycopy(objArr2, 0, this.f3198e, 0, objArr2.length); } m1327d(iArr, objArr2, i2); } if (i4 < i2) { int[] iArr3 = this.f3197d; int i6 = i4 + 1; System.arraycopy(iArr3, i4, iArr3, i6, i2 - i4); Object[] objArr3 = this.f3198e; System.arraycopy(objArr3, i4 << 1, objArr3, i6 << 1, (this.f3199f - i4) << 1); } int i7 = this.f3199f; if (i2 == i7) { int[] iArr4 = this.f3197d; if (i4 < iArr4.length) { iArr4[i4] = i; Object[] objArr4 = this.f3198e; int i8 = i4 << 1; objArr4[i8] = k; objArr4[i8 + 1] = v; this.f3199f = i7 + 1; return null; } } throw new ConcurrentModificationException(); } public V putIfAbsent(K k, V v) { V v2 = get(k); return v2 == null ? put(k, v) : v2; } public V remove(Object obj) { int m1325f = m1325f(obj); if (m1325f >= 0) { return m1321j(m1325f); } return null; } public boolean remove(Object obj, Object obj2) { int m1325f = m1325f(obj); if (m1325f >= 0) { V m1319l = m1319l(m1325f); if (obj2 == m1319l || (obj2 != null && obj2.equals(m1319l))) { m1321j(m1325f); return true; } return false; } return false; } public V replace(K k, V v) { int m1325f = m1325f(k); if (m1325f >= 0) { return m1320k(m1325f, v); } return null; } public boolean replace(K k, V v, V v2) { int m1325f = m1325f(k); if (m1325f >= 0) { V m1319l = m1319l(m1325f); if (m1319l == v || (v != null && v.equals(m1319l))) { m1320k(m1325f, v2); return true; } return false; } return false; } public int size() { return this.f3199f; } public String toString() { if (isEmpty()) { return "{}"; } StringBuilder sb = new StringBuilder(this.f3199f * 28); sb.append('{'); for (int i = 0; i < this.f3199f; i++) { if (i > 0) { sb.append(", "); } K m1322i = m1322i(i); if (m1322i != this) { sb.append(m1322i); } else { sb.append("(this Map)"); } sb.append('='); V m1319l = m1319l(i); if (m1319l != this) { sb.append(m1319l); } else { sb.append("(this Map)"); } } sb.append('}'); return sb.toString(); } }