package androidx.collection; /* loaded from: classes.dex */ public class d implements Cloneable { /* renamed from: e, reason: collision with root package name */ private static final Object f1282e = new Object(); /* renamed from: a, reason: collision with root package name */ private boolean f1283a; /* renamed from: b, reason: collision with root package name */ private long[] f1284b; /* renamed from: c, reason: collision with root package name */ private Object[] f1285c; /* renamed from: d, reason: collision with root package name */ private int f1286d; public d() { this(10); } private void e() { int i10 = this.f1286d; long[] jArr = this.f1284b; Object[] objArr = this.f1285c; int i11 = 0; for (int i12 = 0; i12 < i10; i12++) { Object obj = objArr[i12]; if (obj != f1282e) { if (i12 != i11) { jArr[i11] = jArr[i12]; objArr[i11] = obj; objArr[i12] = null; } i11++; } } this.f1283a = false; this.f1286d = i11; } public void a(long j10, Object obj) { int i10 = this.f1286d; if (i10 != 0 && j10 <= this.f1284b[i10 - 1]) { j(j10, obj); return; } if (this.f1283a && i10 >= this.f1284b.length) { e(); } int i11 = this.f1286d; if (i11 >= this.f1284b.length) { int f10 = c.f(i11 + 1); long[] jArr = new long[f10]; Object[] objArr = new Object[f10]; long[] jArr2 = this.f1284b; System.arraycopy(jArr2, 0, jArr, 0, jArr2.length); Object[] objArr2 = this.f1285c; System.arraycopy(objArr2, 0, objArr, 0, objArr2.length); this.f1284b = jArr; this.f1285c = objArr; } this.f1284b[i11] = j10; this.f1285c[i11] = obj; this.f1286d = i11 + 1; } public void b() { int i10 = this.f1286d; Object[] objArr = this.f1285c; for (int i11 = 0; i11 < i10; i11++) { objArr[i11] = null; } this.f1286d = 0; this.f1283a = false; } /* renamed from: d, reason: merged with bridge method [inline-methods] */ public d clone() { try { d dVar = (d) super.clone(); dVar.f1284b = (long[]) this.f1284b.clone(); dVar.f1285c = (Object[]) this.f1285c.clone(); return dVar; } catch (CloneNotSupportedException e10) { throw new AssertionError(e10); } } public Object f(long j10) { return g(j10, null); } public Object g(long j10, Object obj) { Object obj2; int b10 = c.b(this.f1284b, this.f1286d, j10); return (b10 < 0 || (obj2 = this.f1285c[b10]) == f1282e) ? obj : obj2; } public int h(long j10) { if (this.f1283a) { e(); } return c.b(this.f1284b, this.f1286d, j10); } public long i(int i10) { if (this.f1283a) { e(); } return this.f1284b[i10]; } public void j(long j10, Object obj) { int b10 = c.b(this.f1284b, this.f1286d, j10); if (b10 >= 0) { this.f1285c[b10] = obj; return; } int i10 = ~b10; int i11 = this.f1286d; if (i10 < i11) { Object[] objArr = this.f1285c; if (objArr[i10] == f1282e) { this.f1284b[i10] = j10; objArr[i10] = obj; return; } } if (this.f1283a && i11 >= this.f1284b.length) { e(); i10 = ~c.b(this.f1284b, this.f1286d, j10); } int i12 = this.f1286d; if (i12 >= this.f1284b.length) { int f10 = c.f(i12 + 1); long[] jArr = new long[f10]; Object[] objArr2 = new Object[f10]; long[] jArr2 = this.f1284b; System.arraycopy(jArr2, 0, jArr, 0, jArr2.length); Object[] objArr3 = this.f1285c; System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length); this.f1284b = jArr; this.f1285c = objArr2; } int i13 = this.f1286d; if (i13 - i10 != 0) { long[] jArr3 = this.f1284b; int i14 = i10 + 1; System.arraycopy(jArr3, i10, jArr3, i14, i13 - i10); Object[] objArr4 = this.f1285c; System.arraycopy(objArr4, i10, objArr4, i14, this.f1286d - i10); } this.f1284b[i10] = j10; this.f1285c[i10] = obj; this.f1286d++; } public void k(long j10) { int b10 = c.b(this.f1284b, this.f1286d, j10); if (b10 >= 0) { Object[] objArr = this.f1285c; Object obj = objArr[b10]; Object obj2 = f1282e; if (obj != obj2) { objArr[b10] = obj2; this.f1283a = true; } } } public void l(int i10) { Object[] objArr = this.f1285c; Object obj = objArr[i10]; Object obj2 = f1282e; if (obj != obj2) { objArr[i10] = obj2; this.f1283a = true; } } public int m() { if (this.f1283a) { e(); } return this.f1286d; } public Object n(int i10) { if (this.f1283a) { e(); } return this.f1285c[i10]; } public String toString() { if (m() <= 0) { return "{}"; } StringBuilder sb = new StringBuilder(this.f1286d * 28); sb.append('{'); for (int i10 = 0; i10 < this.f1286d; i10++) { if (i10 > 0) { sb.append(", "); } sb.append(i(i10)); sb.append('='); Object n10 = n(i10); if (n10 != this) { sb.append(n10); } else { sb.append("(this Map)"); } } sb.append('}'); return sb.toString(); } public d(int i10) { this.f1283a = false; if (i10 == 0) { this.f1284b = c.f1280b; this.f1285c = c.f1281c; } else { int f10 = c.f(i10); this.f1284b = new long[f10]; this.f1285c = new Object[f10]; } } }