package gnu.trove; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; /* loaded from: classes2.dex */ public class TFloatDoubleHashMap extends TFloatHash { protected transient double[] _values; private static final class EqProcedure implements TFloatDoubleProcedure { private final TFloatDoubleHashMap a; EqProcedure(TFloatDoubleHashMap tFloatDoubleHashMap) { this.a = tFloatDoubleHashMap; } private static boolean a(double d, double d2) { return d == d2; } @Override // gnu.trove.TFloatDoubleProcedure public final boolean a(float f, double d) { return this.a.index(f) >= 0 && a(d, this.a.get(f)); } } private final class HashProcedure implements TFloatDoubleProcedure { private int a; HashProcedure() { } public int a() { return this.a; } @Override // gnu.trove.TFloatDoubleProcedure public final boolean a(float f, double d) { this.a += TFloatDoubleHashMap.this._hashingStrategy.computeHashCode(f) ^ HashFunctions.a(d); return true; } } public TFloatDoubleHashMap() { } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); int readInt = objectInputStream.readInt(); setUp(readInt); while (true) { int i = readInt - 1; if (readInt <= 0) { return; } put(objectInputStream.readFloat(), objectInputStream.readDouble()); readInt = i; } } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); objectOutputStream.writeInt(this._size); SerializationProcedure serializationProcedure = new SerializationProcedure(objectOutputStream); if (!forEachEntry(serializationProcedure)) { throw serializationProcedure.b; } } public boolean adjustValue(float f, double d) { int index = index(f); if (index < 0) { return false; } double[] dArr = this._values; dArr[index] = dArr[index] + d; return true; } @Override // gnu.trove.THash public void clear() { super.clear(); float[] fArr = this._set; double[] dArr = this._values; if (dArr == null) { return; } byte[] bArr = this._states; int length = fArr.length; while (true) { int i = length - 1; if (length <= 0) { return; } fArr[i] = 0.0f; dArr[i] = 0.0d; bArr[i] = 0; length = i; } } @Override // gnu.trove.TFloatHash, gnu.trove.TPrimitiveHash, gnu.trove.THash public Object clone() { TFloatDoubleHashMap tFloatDoubleHashMap = (TFloatDoubleHashMap) super.clone(); double[] dArr = this._values; tFloatDoubleHashMap._values = dArr == null ? null : (double[]) dArr.clone(); return tFloatDoubleHashMap; } public boolean containsKey(float f) { return contains(f); } public boolean containsValue(double d) { byte[] bArr = this._states; double[] dArr = this._values; if (bArr == null) { return false; } int length = bArr.length; while (true) { int i = length - 1; if (length <= 0) { return false; } if (bArr[i] == 1 && d == dArr[i]) { return true; } length = i; } } public boolean equals(Object obj) { if (!(obj instanceof TFloatDoubleHashMap)) { return false; } TFloatDoubleHashMap tFloatDoubleHashMap = (TFloatDoubleHashMap) obj; if (tFloatDoubleHashMap.size() != size()) { return false; } return forEachEntry(new EqProcedure(tFloatDoubleHashMap)); } public boolean forEachEntry(TFloatDoubleProcedure tFloatDoubleProcedure) { byte[] bArr = this._states; float[] fArr = this._set; double[] dArr = this._values; if (bArr != null) { int length = bArr.length; while (true) { int i = length - 1; if (length <= 0) { break; } if (bArr[i] == 1 && !tFloatDoubleProcedure.a(fArr[i], dArr[i])) { return false; } length = i; } } return true; } public boolean forEachKey(TFloatProcedure tFloatProcedure) { return forEach(tFloatProcedure); } public boolean forEachValue(TDoubleProcedure tDoubleProcedure) { byte[] bArr = this._states; double[] dArr = this._values; if (bArr != null) { int length = bArr.length; while (true) { int i = length - 1; if (length <= 0) { break; } if (bArr[i] == 1 && !tDoubleProcedure.a(dArr[i])) { return false; } length = i; } } return true; } public double get(float f) { int index = index(f); if (index < 0) { return 0.0d; } return this._values[index]; } public double[] getValues() { double[] dArr = new double[size()]; double[] dArr2 = this._values; byte[] bArr = this._states; if (bArr != null) { int length = bArr.length; int i = 0; while (true) { int i2 = length - 1; if (length <= 0) { break; } if (bArr[i2] == 1) { dArr[i] = dArr2[i2]; i++; } length = i2; } } return dArr; } public int hashCode() { HashProcedure hashProcedure = new HashProcedure(); forEachEntry(hashProcedure); return hashProcedure.a(); } public boolean increment(float f) { return adjustValue(f, 1.0d); } public TFloatDoubleIterator iterator() { return new TFloatDoubleIterator(this); } public float[] keys() { float[] fArr = new float[size()]; float[] fArr2 = this._set; byte[] bArr = this._states; if (bArr != null) { int length = bArr.length; int i = 0; while (true) { int i2 = length - 1; if (length <= 0) { break; } if (bArr[i2] == 1) { fArr[i] = fArr2[i2]; i++; } length = i2; } } return fArr; } public double put(float f, double d) { double d2; boolean z; int insertionIndex = insertionIndex(f); if (insertionIndex < 0) { insertionIndex = (-insertionIndex) - 1; d2 = this._values[insertionIndex]; z = false; } else { d2 = 0.0d; z = true; } byte[] bArr = this._states; byte b = bArr[insertionIndex]; this._set[insertionIndex] = f; bArr[insertionIndex] = 1; this._values[insertionIndex] = d; if (z) { postInsertHook(b == 0); } return d2; } @Override // gnu.trove.THash protected void rehash(int i) { int capacity = capacity(); float[] fArr = this._set; double[] dArr = this._values; byte[] bArr = this._states; this._set = new float[i]; this._values = new double[i]; this._states = new byte[i]; while (true) { int i2 = capacity - 1; if (capacity <= 0) { return; } if (bArr[i2] == 1) { float f = fArr[i2]; int insertionIndex = insertionIndex(f); this._set[insertionIndex] = f; this._values[insertionIndex] = dArr[i2]; this._states[insertionIndex] = 1; } capacity = i2; } } public double remove(float f) { int index = index(f); if (index < 0) { return 0.0d; } double d = this._values[index]; removeAt(index); return d; } @Override // gnu.trove.TFloatHash, gnu.trove.TPrimitiveHash, gnu.trove.THash protected void removeAt(int i) { this._values[i] = 0.0d; super.removeAt(i); } public boolean retainEntries(TFloatDoubleProcedure tFloatDoubleProcedure) { byte[] bArr = this._states; float[] fArr = this._set; double[] dArr = this._values; boolean z = false; if (bArr != null) { int length = bArr.length; while (true) { int i = length - 1; if (length <= 0) { break; } if (bArr[i] != 1 || tFloatDoubleProcedure.a(fArr[i], dArr[i])) { length = i; } else { removeAt(i); length = i; z = true; } } } return z; } @Override // gnu.trove.TFloatHash, gnu.trove.TPrimitiveHash, gnu.trove.THash protected int setUp(int i) { int up = super.setUp(i); this._values = i == -1 ? null : new double[up]; return up; } public String toString() { final StringBuilder sb = new StringBuilder(); forEachEntry(new TFloatDoubleProcedure(this) { // from class: gnu.trove.TFloatDoubleHashMap.1 @Override // gnu.trove.TFloatDoubleProcedure public boolean a(float f, double d) { if (sb.length() != 0) { StringBuilder sb2 = sb; sb2.append(','); sb2.append(' '); } sb.append(f); sb.append('='); sb.append(d); return true; } }); sb.append('}'); sb.insert(0, '{'); return sb.toString(); } public void transformValues(TDoubleFunction tDoubleFunction) { byte[] bArr = this._states; double[] dArr = this._values; if (bArr == null) { return; } int length = bArr.length; while (true) { int i = length - 1; if (length <= 0) { return; } if (bArr[i] == 1) { dArr[i] = tDoubleFunction.a(dArr[i]); } length = i; } } public TFloatDoubleHashMap(int i) { super(i); } public TFloatDoubleHashMap(int i, float f) { super(i, f); } public TFloatDoubleHashMap(TFloatHashingStrategy tFloatHashingStrategy) { super(tFloatHashingStrategy); } public TFloatDoubleHashMap(int i, TFloatHashingStrategy tFloatHashingStrategy) { super(i, tFloatHashingStrategy); } public TFloatDoubleHashMap(int i, float f, TFloatHashingStrategy tFloatHashingStrategy) { super(i, f, tFloatHashingStrategy); } }