package o; import com.google.common.base.Objects; import java.util.AbstractMap; import java.util.AbstractSet; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; /* loaded from: classes2.dex */ public class YjD extends AbstractMap implements Cloneable { int b; Object[] c; public static YjD c() { return new YjD<>(); } public final V d(int i) { int i2; if (i < 0 || i >= this.b || (i2 = (i << 1) + 1) < 0) { return null; } return (V) this.c[i2]; } public final V e(int i, V v) { int i2 = this.b; if (i < 0 || i >= i2) { throw new IndexOutOfBoundsException(); } int i3 = (i << 1) + 1; V v2 = i3 < 0 ? null : (V) this.c[i3]; this.c[i3] = v; return v2; } @Override // java.util.AbstractMap, java.util.Map public final boolean containsKey(Object obj) { return -2 != e(obj); } @Override // java.util.AbstractMap, java.util.Map public final V get(Object obj) { int e = e(obj) + 1; if (e < 0) { return null; } return (V) this.c[e]; } @Override // java.util.AbstractMap, java.util.Map public final V remove(Object obj) { return b(e(obj)); } private int e(Object obj) { int i = this.b; Object[] objArr = this.c; for (int i2 = 0; i2 < (i << 1); i2 += 2) { Object obj2 = objArr[i2]; if (obj == null) { if (obj2 == null) { return i2; } } else { if (obj.equals(obj2)) { return i2; } } } return -2; } final V b(int i) { int i2 = this.b << 1; if (i < 0 || i >= i2) { return null; } int i3 = i + 1; V v = i3 < 0 ? null : (V) this.c[i3]; Object[] objArr = this.c; int i4 = (i2 - i) - 2; if (i4 != 0) { System.arraycopy(objArr, i + 2, objArr, i, i4); } this.b--; Object[] objArr2 = this.c; objArr2[i2 - 2] = null; objArr2[i2 - 1] = null; return v; } @Override // java.util.AbstractMap, java.util.Map public final boolean containsValue(Object obj) { int i = this.b; Object[] objArr = this.c; for (int i2 = 1; i2 < (i << 1); i2 += 2) { Object obj2 = objArr[i2]; if (obj == null) { if (obj2 == null) { return true; } } else { if (obj.equals(obj2)) { return true; } } } return false; } @Override // java.util.AbstractMap, java.util.Map public final Set> entrySet() { return new RVV(this); } @Override // java.util.AbstractMap /* renamed from: a, reason: merged with bridge method [inline-methods] */ public final YjD clone() { try { YjD yjD = (YjD) super.clone(); Object[] objArr = this.c; if (objArr != null) { int length = objArr.length; Object[] objArr2 = new Object[length]; yjD.c = objArr2; System.arraycopy(objArr, 0, objArr2, 0, length); } return yjD; } catch (CloneNotSupportedException unused) { return null; } } /* loaded from: classes2.dex */ final class RVV extends AbstractSet> { private YjD e; RVV(YjD yjD) { this.e = yjD; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public final Iterator> iterator() { return new IeS(this.e); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public final int size() { return this.e.b; } } /* loaded from: classes2.dex */ final class IeS implements Iterator> { private YjD a; private boolean c; private int d; IeS(YjD yjD) { this.a = yjD; } @Override // java.util.Iterator public final /* synthetic */ Object next() { int i = this.d; if (i == this.a.b) { throw new NoSuchElementException(); } this.d++; this.c = false; return new Sts(this.a, i); } @Override // java.util.Iterator public final boolean hasNext() { return this.d < this.a.b; } @Override // java.util.Iterator public final void remove() { int i = this.d - 1; if (this.c || i < 0) { throw new IllegalArgumentException(); } this.a.b(i << 1); this.d--; this.c = true; } } /* loaded from: classes2.dex */ final class Sts implements Map.Entry { private YjD d; private int e; Sts(YjD yjD, int i) { this.d = yjD; this.e = i; } @Override // java.util.Map.Entry public final K getKey() { YjD yjD = this.d; int i = this.e; if (i < 0 || i >= yjD.b) { return null; } return (K) yjD.c[i << 1]; } @Override // java.util.Map.Entry public final V getValue() { return (V) this.d.d(this.e); } @Override // java.util.Map.Entry public final V setValue(V v) { return (V) this.d.e(this.e, v); } @Override // java.util.Map.Entry public final int hashCode() { Object key = getKey(); Object value = getValue(); return (key != null ? key.hashCode() : 0) ^ (value != null ? value.hashCode() : 0); } @Override // java.util.Map.Entry public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) obj; return Objects.equal(getKey(), entry.getKey()) && Objects.equal(getValue(), entry.getValue()); } } @Override // java.util.AbstractMap, java.util.Map public final V put(K k, V v) { int e = e(k) >> 1; if (e == -1) { e = this.b; } if (e < 0) { throw new IndexOutOfBoundsException(); } int i = e + 1; if (i >= 0) { Object[] objArr = this.c; int i2 = i << 1; int length = objArr == null ? 0 : objArr.length; V v2 = null; if (i2 > length) { int i3 = (length / 2) * 3; int i4 = i3 + 1; if (i4 % 2 != 0) { i4 = i3 + 2; } if (i4 >= i2) { i2 = i4; } if (i2 == 0) { this.c = null; } else { int i5 = this.b; if (i5 == 0 || i2 != objArr.length) { Object[] objArr2 = new Object[i2]; this.c = objArr2; if (i5 != 0) { System.arraycopy(objArr, 0, objArr2, 0, i5 << 1); } } } } int i6 = e << 1; int i7 = i6 + 1; if (i7 >= 0) { v2 = (V) this.c[i7]; } Object[] objArr3 = this.c; objArr3[i6] = k; objArr3[i7] = v; if (i > this.b) { this.b = i; } return v2; } throw new IndexOutOfBoundsException(); } @Override // java.util.AbstractMap, java.util.Map public final int size() { return this.b; } @Override // java.util.AbstractMap, java.util.Map public void clear() { this.b = 0; this.c = null; } }