package com.google.android.gms.internal.vision; import java.util.Arrays; import java.util.Collection; import java.util.RandomAccess; /* loaded from: classes2.dex */ final class zzem extends zzef implements zzge, zzhr, RandomAccess { private static final zzem zzrv; private int size; private boolean[] zzrw; zzem() { this(new boolean[10], 0); } private zzem(boolean[] zArr, int i) { this.zzrw = zArr; this.size = i; } @Override // java.util.AbstractList protected final void removeRange(int i, int i2) { zzcj(); if (i2 < i) { throw new IndexOutOfBoundsException("toIndex < fromIndex"); } boolean[] zArr = this.zzrw; System.arraycopy(zArr, i2, zArr, i, this.size - i2); this.size -= i2 - i; this.modCount++; } @Override // com.google.android.gms.internal.vision.zzef, java.util.AbstractList, java.util.Collection, java.util.List public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof zzem)) { return super.equals(obj); } zzem zzemVar = (zzem) obj; if (this.size != zzemVar.size) { return false; } boolean[] zArr = zzemVar.zzrw; for (int i = 0; i < this.size; i++) { if (this.zzrw[i] != zArr[i]) { return false; } } return true; } @Override // com.google.android.gms.internal.vision.zzef, java.util.AbstractList, java.util.Collection, java.util.List public final int hashCode() { int i = 1; for (int i2 = 0; i2 < this.size; i2++) { i = (i * 31) + zzga.zzj(this.zzrw[i2]); } return i; } public final void addBoolean(boolean z) { zza(this.size, z); } private final void zza(int i, boolean z) { int i2; zzcj(); if (i < 0 || i > (i2 = this.size)) { throw new IndexOutOfBoundsException(zzag(i)); } boolean[] zArr = this.zzrw; 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.zzrw, i, zArr2, i + 1, this.size - i); this.zzrw = zArr2; } this.zzrw[i] = z; this.size++; this.modCount++; } @Override // com.google.android.gms.internal.vision.zzef, java.util.AbstractCollection, java.util.Collection, java.util.List public final boolean addAll(Collection collection) { zzcj(); zzga.checkNotNull(collection); if (!(collection instanceof zzem)) { return super.addAll(collection); } zzem zzemVar = (zzem) collection; int i = zzemVar.size; if (i == 0) { return false; } int i2 = this.size; if (Integer.MAX_VALUE - i2 < i) { throw new OutOfMemoryError(); } int i3 = i2 + i; boolean[] zArr = this.zzrw; if (i3 > zArr.length) { this.zzrw = Arrays.copyOf(zArr, i3); } System.arraycopy(zzemVar.zzrw, 0, this.zzrw, this.size, zzemVar.size); this.size = i3; this.modCount++; return true; } @Override // com.google.android.gms.internal.vision.zzef, java.util.AbstractCollection, java.util.Collection, java.util.List public final boolean remove(Object obj) { zzcj(); for (int i = 0; i < this.size; i++) { if (obj.equals(Boolean.valueOf(this.zzrw[i]))) { boolean[] zArr = this.zzrw; System.arraycopy(zArr, i + 1, zArr, i, this.size - i); this.size--; this.modCount++; return true; } } return false; } private final void zzaf(int i) { if (i < 0 || i >= this.size) { throw new IndexOutOfBoundsException(zzag(i)); } } private final String zzag(int i) { int i2 = this.size; StringBuilder sb = new StringBuilder(35); sb.append("Index:"); sb.append(i); sb.append(", Size:"); sb.append(i2); return sb.toString(); } @Override // com.google.android.gms.internal.vision.zzef, java.util.AbstractList, java.util.List public final /* synthetic */ Object set(int i, Object obj) { boolean booleanValue = ((Boolean) obj).booleanValue(); zzcj(); zzaf(i); boolean[] zArr = this.zzrw; boolean z = zArr[i]; zArr[i] = booleanValue; return Boolean.valueOf(z); } @Override // com.google.android.gms.internal.vision.zzef, java.util.AbstractList, java.util.List public final /* synthetic */ Object remove(int i) { zzcj(); zzaf(i); boolean[] zArr = this.zzrw; boolean z = zArr[i]; int i2 = this.size; if (i < i2 - 1) { System.arraycopy(zArr, i + 1, zArr, i, i2 - i); } this.size--; this.modCount++; return Boolean.valueOf(z); } @Override // com.google.android.gms.internal.vision.zzef, java.util.AbstractList, java.util.List public final /* synthetic */ void add(int i, Object obj) { zza(i, ((Boolean) obj).booleanValue()); } @Override // com.google.android.gms.internal.vision.zzge public final /* synthetic */ zzge zzah(int i) { if (i < this.size) { throw new IllegalArgumentException(); } return new zzem(Arrays.copyOf(this.zzrw, i), this.size); } @Override // java.util.AbstractList, java.util.List public final /* synthetic */ Object get(int i) { zzaf(i); return Boolean.valueOf(this.zzrw[i]); } static { zzem zzemVar = new zzem(); zzrv = zzemVar; zzemVar.zzci(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.List public final int size() { return this.size; } }