package com.fyber.inneractive.sdk.protobuf; import com.fyber.inneractive.sdk.protobuf.y; import java.nio.charset.Charset; import java.util.AbstractList; import java.util.Arrays; import java.util.Collection; import java.util.RandomAccess; /* loaded from: classes2.dex */ public final class g extends c implements y.a, RandomAccess, x0 { public static final g d; public boolean[] b; public int c; static { g gVar = new g(new boolean[0], 0); d = gVar; gVar.a = false; } public g() { this(new boolean[10], 0); } @Override // java.util.AbstractList, java.util.List public final void add(int i, Object obj) { int i2; boolean booleanValue = ((Boolean) obj).booleanValue(); e(); if (i < 0 || i > (i2 = this.c)) { StringBuilder a = com.fyber.inneractive.sdk.bidder.h.a("Index:", i, ", Size:"); a.append(this.c); throw new IndexOutOfBoundsException(a.toString()); } boolean[] zArr = this.b; if (i2 < zArr.length) { System.arraycopy(zArr, i, zArr, i + 1, i2 - i); } else { boolean[] zArr2 = new boolean[((i2 * 3) / 2) + 1]; System.arraycopy(zArr, 0, zArr2, 0, i); System.arraycopy(this.b, i, zArr2, i + 1, this.c - i); this.b = zArr2; } this.b[i] = booleanValue; this.c++; ((AbstractList) this).modCount++; } @Override // com.fyber.inneractive.sdk.protobuf.c, java.util.AbstractCollection, java.util.Collection, java.util.List public final boolean addAll(Collection collection) { e(); Charset charset = y.a; collection.getClass(); if (!(collection instanceof g)) { return super.addAll(collection); } g gVar = (g) collection; int i = gVar.c; if (i == 0) { return false; } int i2 = this.c; if (Integer.MAX_VALUE - i2 < i) { throw new OutOfMemoryError(); } int i3 = i2 + i; boolean[] zArr = this.b; if (i3 > zArr.length) { this.b = Arrays.copyOf(zArr, i3); } System.arraycopy(gVar.b, 0, this.b, this.c, gVar.c); this.c = i3; ((AbstractList) this).modCount++; return true; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.List public final boolean contains(Object obj) { return indexOf(obj) != -1; } @Override // com.fyber.inneractive.sdk.protobuf.c, java.util.AbstractList, java.util.Collection, java.util.List public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof g)) { return super.equals(obj); } g gVar = (g) obj; if (this.c != gVar.c) { return false; } boolean[] zArr = gVar.b; for (int i = 0; i < this.c; i++) { if (this.b[i] != zArr[i]) { return false; } } return true; } @Override // java.util.AbstractList, java.util.List public final int indexOf(Object obj) { if (!(obj instanceof Boolean)) { return -1; } boolean booleanValue = ((Boolean) obj).booleanValue(); int i = this.c; for (int i2 = 0; i2 < i; i2++) { if (this.b[i2] == booleanValue) { return i2; } } return -1; } @Override // com.fyber.inneractive.sdk.protobuf.c, java.util.AbstractList, java.util.List public final Object remove(int i) { int i2; e(); if (i < 0 || i >= (i2 = this.c)) { StringBuilder a = com.fyber.inneractive.sdk.bidder.h.a("Index:", i, ", Size:"); a.append(this.c); throw new IndexOutOfBoundsException(a.toString()); } boolean[] zArr = this.b; boolean z = zArr[i]; if (i < i2 - 1) { System.arraycopy(zArr, i + 1, zArr, i, (i2 - i) - 1); } this.c--; ((AbstractList) this).modCount++; return Boolean.valueOf(z); } @Override // java.util.AbstractList public final void removeRange(int i, int i2) { e(); if (i2 < i) { throw new IndexOutOfBoundsException("toIndex < fromIndex"); } boolean[] zArr = this.b; System.arraycopy(zArr, i2, zArr, i, this.c - i2); this.c -= i2 - i; ((AbstractList) this).modCount++; } @Override // java.util.AbstractList, java.util.List public final Object set(int i, Object obj) { boolean booleanValue = ((Boolean) obj).booleanValue(); e(); if (i < 0 || i >= this.c) { StringBuilder a = com.fyber.inneractive.sdk.bidder.h.a("Index:", i, ", Size:"); a.append(this.c); throw new IndexOutOfBoundsException(a.toString()); } boolean[] zArr = this.b; boolean z = zArr[i]; zArr[i] = booleanValue; return Boolean.valueOf(z); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.List public final int size() { return this.c; } public g(boolean[] zArr, int i) { this.b = zArr; this.c = i; } public final void a(boolean z) { e(); int i = this.c; boolean[] zArr = this.b; if (i == zArr.length) { boolean[] zArr2 = new boolean[((i * 3) / 2) + 1]; System.arraycopy(zArr, 0, zArr2, 0, i); this.b = zArr2; } boolean[] zArr3 = this.b; int i2 = this.c; this.c = i2 + 1; zArr3[i2] = z; } @Override // java.util.AbstractList, java.util.List public final Object get(int i) { if (i >= 0 && i < this.c) { return Boolean.valueOf(this.b[i]); } StringBuilder a = com.fyber.inneractive.sdk.bidder.h.a("Index:", i, ", Size:"); a.append(this.c); throw new IndexOutOfBoundsException(a.toString()); } @Override // com.fyber.inneractive.sdk.protobuf.c, java.util.AbstractList, java.util.Collection, java.util.List public final int hashCode() { int i = 1; for (int i2 = 0; i2 < this.c; i2++) { int i3 = i * 31; boolean z = this.b[i2]; Charset charset = y.a; i = i3 + (z ? 1231 : 1237); } return i; } @Override // com.fyber.inneractive.sdk.protobuf.y.j /* renamed from: c, reason: merged with bridge method [inline-methods] */ public final g a(int i) { if (i >= this.c) { return new g(Arrays.copyOf(this.b, i), this.c); } throw new IllegalArgumentException(); } @Override // com.fyber.inneractive.sdk.protobuf.c, java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List public final boolean add(Object obj) { a(((Boolean) obj).booleanValue()); return true; } }