package androidx.collection; /* loaded from: classes.dex */ public class h implements Cloneable { /* renamed from: e, reason: collision with root package name */ private static final Object f1309e = new Object(); /* renamed from: a, reason: collision with root package name */ private boolean f1310a; /* renamed from: b, reason: collision with root package name */ private int[] f1311b; /* renamed from: c, reason: collision with root package name */ private Object[] f1312c; /* renamed from: d, reason: collision with root package name */ private int f1313d; public h() { this(10); } private void e() { int i10 = this.f1313d; int[] iArr = this.f1311b; Object[] objArr = this.f1312c; int i11 = 0; for (int i12 = 0; i12 < i10; i12++) { Object obj = objArr[i12]; if (obj != f1309e) { if (i12 != i11) { iArr[i11] = iArr[i12]; objArr[i11] = obj; objArr[i12] = null; } i11++; } } this.f1310a = false; this.f1313d = i11; } public void a(int i10, Object obj) { int i11 = this.f1313d; if (i11 != 0 && i10 <= this.f1311b[i11 - 1]) { j(i10, obj); return; } if (this.f1310a && i11 >= this.f1311b.length) { e(); } int i12 = this.f1313d; if (i12 >= this.f1311b.length) { int e10 = c.e(i12 + 1); int[] iArr = new int[e10]; Object[] objArr = new Object[e10]; int[] iArr2 = this.f1311b; System.arraycopy(iArr2, 0, iArr, 0, iArr2.length); Object[] objArr2 = this.f1312c; System.arraycopy(objArr2, 0, objArr, 0, objArr2.length); this.f1311b = iArr; this.f1312c = objArr; } this.f1311b[i12] = i10; this.f1312c[i12] = obj; this.f1313d = i12 + 1; } public void b() { int i10 = this.f1313d; Object[] objArr = this.f1312c; for (int i11 = 0; i11 < i10; i11++) { objArr[i11] = null; } this.f1313d = 0; this.f1310a = false; } /* renamed from: d, reason: merged with bridge method [inline-methods] */ public h clone() { try { h hVar = (h) super.clone(); hVar.f1311b = (int[]) this.f1311b.clone(); hVar.f1312c = (Object[]) this.f1312c.clone(); return hVar; } catch (CloneNotSupportedException e10) { throw new AssertionError(e10); } } public Object f(int i10) { return g(i10, null); } public Object g(int i10, Object obj) { Object obj2; int a10 = c.a(this.f1311b, this.f1313d, i10); return (a10 < 0 || (obj2 = this.f1312c[a10]) == f1309e) ? obj : obj2; } public int h(Object obj) { if (this.f1310a) { e(); } for (int i10 = 0; i10 < this.f1313d; i10++) { if (this.f1312c[i10] == obj) { return i10; } } return -1; } public int i(int i10) { if (this.f1310a) { e(); } return this.f1311b[i10]; } public void j(int i10, Object obj) { int a10 = c.a(this.f1311b, this.f1313d, i10); if (a10 >= 0) { this.f1312c[a10] = obj; return; } int i11 = ~a10; int i12 = this.f1313d; if (i11 < i12) { Object[] objArr = this.f1312c; if (objArr[i11] == f1309e) { this.f1311b[i11] = i10; objArr[i11] = obj; return; } } if (this.f1310a && i12 >= this.f1311b.length) { e(); i11 = ~c.a(this.f1311b, this.f1313d, i10); } int i13 = this.f1313d; if (i13 >= this.f1311b.length) { int e10 = c.e(i13 + 1); int[] iArr = new int[e10]; Object[] objArr2 = new Object[e10]; int[] iArr2 = this.f1311b; System.arraycopy(iArr2, 0, iArr, 0, iArr2.length); Object[] objArr3 = this.f1312c; System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length); this.f1311b = iArr; this.f1312c = objArr2; } int i14 = this.f1313d; if (i14 - i11 != 0) { int[] iArr3 = this.f1311b; int i15 = i11 + 1; System.arraycopy(iArr3, i11, iArr3, i15, i14 - i11); Object[] objArr4 = this.f1312c; System.arraycopy(objArr4, i11, objArr4, i15, this.f1313d - i11); } this.f1311b[i11] = i10; this.f1312c[i11] = obj; this.f1313d++; } public int k() { if (this.f1310a) { e(); } return this.f1313d; } public Object l(int i10) { if (this.f1310a) { e(); } return this.f1312c[i10]; } public String toString() { if (k() <= 0) { return "{}"; } StringBuilder sb = new StringBuilder(this.f1313d * 28); sb.append('{'); for (int i10 = 0; i10 < this.f1313d; i10++) { if (i10 > 0) { sb.append(", "); } sb.append(i(i10)); sb.append('='); Object l10 = l(i10); if (l10 != this) { sb.append(l10); } else { sb.append("(this Map)"); } } sb.append('}'); return sb.toString(); } public h(int i10) { this.f1310a = false; if (i10 == 0) { this.f1311b = c.f1279a; this.f1312c = c.f1281c; } else { int e10 = c.e(i10); this.f1311b = new int[e10]; this.f1312c = new Object[e10]; } } }