jimu-decompiled/sources/gnu/trove/TFloatHashSet.java
2025-05-13 19:24:51 +02:00

283 lines
7.4 KiB
Java

package gnu.trove;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
/* loaded from: classes2.dex */
public class TFloatHashSet extends TFloatHash {
private final class HashProcedure implements TFloatProcedure {
private int a;
HashProcedure() {
}
public int a() {
return this.a;
}
@Override // gnu.trove.TFloatProcedure
public final boolean a(float f) {
this.a += TFloatHashSet.this._hashingStrategy.computeHashCode(f);
return true;
}
}
public TFloatHashSet() {
}
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;
}
add(objectInputStream.readFloat());
readInt = i;
}
}
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
objectOutputStream.defaultWriteObject();
objectOutputStream.writeInt(this._size);
SerializationProcedure serializationProcedure = new SerializationProcedure(objectOutputStream);
if (!forEach(serializationProcedure)) {
throw serializationProcedure.b;
}
}
public boolean add(float f) {
int insertionIndex = insertionIndex(f);
if (insertionIndex < 0) {
return false;
}
byte[] bArr = this._states;
byte b = bArr[insertionIndex];
this._set[insertionIndex] = f;
bArr[insertionIndex] = 1;
postInsertHook(b == 0);
return true;
}
public boolean addAll(float[] fArr) {
int length = fArr.length;
boolean z = false;
while (true) {
int i = length - 1;
if (length <= 0) {
return z;
}
if (add(fArr[i])) {
z = true;
}
length = i;
}
}
@Override // gnu.trove.THash
public void clear() {
super.clear();
float[] fArr = this._set;
byte[] bArr = this._states;
if (bArr == null) {
return;
}
int length = fArr.length;
while (true) {
int i = length - 1;
if (length <= 0) {
return;
}
fArr[i] = 0.0f;
bArr[i] = 0;
length = i;
}
}
public boolean containsAll(float[] fArr) {
int length = fArr.length;
while (true) {
int i = length - 1;
if (length <= 0) {
return true;
}
if (!contains(fArr[i])) {
return false;
}
length = i;
}
}
public boolean equals(Object obj) {
if (!(obj instanceof TFloatHashSet)) {
return false;
}
final TFloatHashSet tFloatHashSet = (TFloatHashSet) obj;
if (tFloatHashSet.size() != size()) {
return false;
}
return forEach(new TFloatProcedure(this) { // from class: gnu.trove.TFloatHashSet.1
@Override // gnu.trove.TFloatProcedure
public final boolean a(float f) {
return tFloatHashSet.contains(f);
}
});
}
public int hashCode() {
HashProcedure hashProcedure = new HashProcedure();
forEach(hashProcedure);
return hashProcedure.a();
}
public TFloatIterator iterator() {
return new TFloatIterator(this);
}
@Override // gnu.trove.THash
protected void rehash(int i) {
int capacity = capacity();
float[] fArr = this._set;
byte[] bArr = this._states;
this._set = new float[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._states[insertionIndex] = 1;
}
capacity = i2;
}
}
public boolean remove(float f) {
int index = index(f);
if (index < 0) {
return false;
}
removeAt(index);
return true;
}
public boolean removeAll(float[] fArr) {
int length = fArr.length;
boolean z = false;
while (true) {
int i = length - 1;
if (length <= 0) {
return z;
}
if (remove(fArr[i])) {
z = true;
}
length = i;
}
}
public boolean retainAll(float[] fArr) {
Arrays.sort(fArr);
float[] fArr2 = this._set;
byte[] bArr = this._states;
boolean z = false;
if (fArr2 != null) {
int length = fArr2.length;
while (true) {
int i = length - 1;
if (length <= 0) {
break;
}
if (bArr[i] != 1 || Arrays.binarySearch(fArr, fArr2[i]) >= 0) {
length = i;
} else {
remove(fArr2[i]);
length = i;
z = true;
}
}
}
return z;
}
public float[] toArray() {
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 String toString() {
final StringBuilder sb = new StringBuilder();
forEach(new TFloatProcedure(this) { // from class: gnu.trove.TFloatHashSet.2
@Override // gnu.trove.TFloatProcedure
public boolean a(float f) {
if (sb.length() != 0) {
StringBuilder sb2 = sb;
sb2.append(',');
sb2.append(' ');
}
sb.append(f);
return true;
}
});
sb.append(']');
sb.insert(0, '[');
return sb.toString();
}
public TFloatHashSet(int i) {
super(i);
}
public TFloatHashSet(int i, float f) {
super(i, f);
}
public TFloatHashSet(float[] fArr) {
this(fArr.length);
addAll(fArr);
}
public TFloatHashSet(TFloatHashingStrategy tFloatHashingStrategy) {
super(tFloatHashingStrategy);
}
public TFloatHashSet(int i, TFloatHashingStrategy tFloatHashingStrategy) {
super(i, tFloatHashingStrategy);
}
public TFloatHashSet(int i, float f, TFloatHashingStrategy tFloatHashingStrategy) {
super(i, f, tFloatHashingStrategy);
}
public TFloatHashSet(float[] fArr, TFloatHashingStrategy tFloatHashingStrategy) {
this(fArr.length, tFloatHashingStrategy);
addAll(fArr);
}
}