283 lines
7.3 KiB
Java
283 lines
7.3 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 TIntHashSet extends TIntHash {
|
|
|
|
private final class HashProcedure implements TIntProcedure {
|
|
private int a;
|
|
|
|
HashProcedure() {
|
|
}
|
|
|
|
public int a() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // gnu.trove.TIntProcedure
|
|
public final boolean a(int i) {
|
|
this.a += TIntHashSet.this._hashingStrategy.computeHashCode(i);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public TIntHashSet() {
|
|
}
|
|
|
|
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.readInt());
|
|
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(int i) {
|
|
int insertionIndex = insertionIndex(i);
|
|
if (insertionIndex < 0) {
|
|
return false;
|
|
}
|
|
byte[] bArr = this._states;
|
|
byte b = bArr[insertionIndex];
|
|
this._set[insertionIndex] = i;
|
|
bArr[insertionIndex] = 1;
|
|
postInsertHook(b == 0);
|
|
return true;
|
|
}
|
|
|
|
public boolean addAll(int[] iArr) {
|
|
int length = iArr.length;
|
|
boolean z = false;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
return z;
|
|
}
|
|
if (add(iArr[i])) {
|
|
z = true;
|
|
}
|
|
length = i;
|
|
}
|
|
}
|
|
|
|
@Override // gnu.trove.THash
|
|
public void clear() {
|
|
super.clear();
|
|
int[] iArr = this._set;
|
|
byte[] bArr = this._states;
|
|
if (bArr == null) {
|
|
return;
|
|
}
|
|
int length = iArr.length;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
return;
|
|
}
|
|
iArr[i] = 0;
|
|
bArr[i] = 0;
|
|
length = i;
|
|
}
|
|
}
|
|
|
|
public boolean containsAll(int[] iArr) {
|
|
int length = iArr.length;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
return true;
|
|
}
|
|
if (!contains(iArr[i])) {
|
|
return false;
|
|
}
|
|
length = i;
|
|
}
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (!(obj instanceof TIntHashSet)) {
|
|
return false;
|
|
}
|
|
final TIntHashSet tIntHashSet = (TIntHashSet) obj;
|
|
if (tIntHashSet.size() != size()) {
|
|
return false;
|
|
}
|
|
return forEach(new TIntProcedure(this) { // from class: gnu.trove.TIntHashSet.1
|
|
@Override // gnu.trove.TIntProcedure
|
|
public final boolean a(int i) {
|
|
return tIntHashSet.contains(i);
|
|
}
|
|
});
|
|
}
|
|
|
|
public int hashCode() {
|
|
HashProcedure hashProcedure = new HashProcedure();
|
|
forEach(hashProcedure);
|
|
return hashProcedure.a();
|
|
}
|
|
|
|
public TIntIterator iterator() {
|
|
return new TIntIterator(this);
|
|
}
|
|
|
|
@Override // gnu.trove.THash
|
|
protected void rehash(int i) {
|
|
int capacity = capacity();
|
|
int[] iArr = this._set;
|
|
byte[] bArr = this._states;
|
|
this._set = new int[i];
|
|
this._states = new byte[i];
|
|
while (true) {
|
|
int i2 = capacity - 1;
|
|
if (capacity <= 0) {
|
|
return;
|
|
}
|
|
if (bArr[i2] == 1) {
|
|
int i3 = iArr[i2];
|
|
int insertionIndex = insertionIndex(i3);
|
|
this._set[insertionIndex] = i3;
|
|
this._states[insertionIndex] = 1;
|
|
}
|
|
capacity = i2;
|
|
}
|
|
}
|
|
|
|
public boolean remove(int i) {
|
|
int index = index(i);
|
|
if (index < 0) {
|
|
return false;
|
|
}
|
|
removeAt(index);
|
|
return true;
|
|
}
|
|
|
|
public boolean removeAll(int[] iArr) {
|
|
int length = iArr.length;
|
|
boolean z = false;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
return z;
|
|
}
|
|
if (remove(iArr[i])) {
|
|
z = true;
|
|
}
|
|
length = i;
|
|
}
|
|
}
|
|
|
|
public boolean retainAll(int[] iArr) {
|
|
Arrays.sort(iArr);
|
|
int[] iArr2 = this._set;
|
|
byte[] bArr = this._states;
|
|
boolean z = false;
|
|
if (iArr2 != null) {
|
|
int length = iArr2.length;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
break;
|
|
}
|
|
if (bArr[i] != 1 || Arrays.binarySearch(iArr, iArr2[i]) >= 0) {
|
|
length = i;
|
|
} else {
|
|
remove(iArr2[i]);
|
|
length = i;
|
|
z = true;
|
|
}
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public int[] toArray() {
|
|
int[] iArr = new int[size()];
|
|
int[] iArr2 = 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) {
|
|
iArr[i] = iArr2[i2];
|
|
i++;
|
|
}
|
|
length = i2;
|
|
}
|
|
}
|
|
return iArr;
|
|
}
|
|
|
|
public String toString() {
|
|
final StringBuilder sb = new StringBuilder();
|
|
forEach(new TIntProcedure(this) { // from class: gnu.trove.TIntHashSet.2
|
|
@Override // gnu.trove.TIntProcedure
|
|
public boolean a(int i) {
|
|
if (sb.length() != 0) {
|
|
StringBuilder sb2 = sb;
|
|
sb2.append(',');
|
|
sb2.append(' ');
|
|
}
|
|
sb.append(i);
|
|
return true;
|
|
}
|
|
});
|
|
sb.append(']');
|
|
sb.insert(0, '[');
|
|
return sb.toString();
|
|
}
|
|
|
|
public TIntHashSet(int i) {
|
|
super(i);
|
|
}
|
|
|
|
public TIntHashSet(int i, float f) {
|
|
super(i, f);
|
|
}
|
|
|
|
public TIntHashSet(int[] iArr) {
|
|
this(iArr.length);
|
|
addAll(iArr);
|
|
}
|
|
|
|
public TIntHashSet(TIntHashingStrategy tIntHashingStrategy) {
|
|
super(tIntHashingStrategy);
|
|
}
|
|
|
|
public TIntHashSet(int i, TIntHashingStrategy tIntHashingStrategy) {
|
|
super(i, tIntHashingStrategy);
|
|
}
|
|
|
|
public TIntHashSet(int i, float f, TIntHashingStrategy tIntHashingStrategy) {
|
|
super(i, f, tIntHashingStrategy);
|
|
}
|
|
|
|
public TIntHashSet(int[] iArr, TIntHashingStrategy tIntHashingStrategy) {
|
|
this(iArr.length, tIntHashingStrategy);
|
|
addAll(iArr);
|
|
}
|
|
}
|