Initial commit
This commit is contained in:
150
sources/gnu/trove/TIntHash.java
Normal file
150
sources/gnu/trove/TIntHash.java
Normal file
@@ -0,0 +1,150 @@
|
||||
package gnu.trove;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class TIntHash extends TPrimitiveHash implements TIntHashingStrategy {
|
||||
protected final TIntHashingStrategy _hashingStrategy;
|
||||
protected transient int[] _set;
|
||||
|
||||
public TIntHash() {
|
||||
this._hashingStrategy = this;
|
||||
}
|
||||
|
||||
@Override // gnu.trove.TPrimitiveHash, gnu.trove.THash
|
||||
public Object clone() {
|
||||
TIntHash tIntHash = (TIntHash) super.clone();
|
||||
int[] iArr = this._set;
|
||||
tIntHash._set = iArr == null ? null : (int[]) iArr.clone();
|
||||
return tIntHash;
|
||||
}
|
||||
|
||||
@Override // gnu.trove.TIntHashingStrategy
|
||||
public final int computeHashCode(int i) {
|
||||
HashFunctions.a(i);
|
||||
return i;
|
||||
}
|
||||
|
||||
public boolean contains(int i) {
|
||||
return index(i) >= 0;
|
||||
}
|
||||
|
||||
public boolean forEach(TIntProcedure tIntProcedure) {
|
||||
byte[] bArr = this._states;
|
||||
int[] iArr = this._set;
|
||||
if (bArr != null) {
|
||||
int length = bArr.length;
|
||||
while (true) {
|
||||
int i = length - 1;
|
||||
if (length <= 0) {
|
||||
break;
|
||||
}
|
||||
if (bArr[i] == 1 && !tIntProcedure.a(iArr[i])) {
|
||||
return false;
|
||||
}
|
||||
length = i;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected int index(int i) {
|
||||
byte[] bArr = this._states;
|
||||
if (bArr == null) {
|
||||
return -1;
|
||||
}
|
||||
int[] iArr = this._set;
|
||||
int length = bArr.length;
|
||||
int computeHashCode = this._hashingStrategy.computeHashCode(i) & Integer.MAX_VALUE;
|
||||
int i2 = computeHashCode % length;
|
||||
if (bArr[i2] != 0 && (bArr[i2] == 2 || iArr[i2] != i)) {
|
||||
int i3 = (computeHashCode % (length - 2)) + 1;
|
||||
while (true) {
|
||||
i2 -= i3;
|
||||
if (i2 < 0) {
|
||||
i2 += length;
|
||||
}
|
||||
if (bArr[i2] == 0 || (bArr[i2] != 2 && iArr[i2] == i)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bArr[i2] == 0) {
|
||||
return -1;
|
||||
}
|
||||
return i2;
|
||||
}
|
||||
|
||||
protected int insertionIndex(int i) {
|
||||
if (this._set == null) {
|
||||
setUp(6);
|
||||
}
|
||||
byte[] bArr = this._states;
|
||||
int[] iArr = this._set;
|
||||
int length = bArr.length;
|
||||
int computeHashCode = this._hashingStrategy.computeHashCode(i) & Integer.MAX_VALUE;
|
||||
int i2 = computeHashCode % length;
|
||||
if (bArr[i2] == 0) {
|
||||
return i2;
|
||||
}
|
||||
if (bArr[i2] == 1 && iArr[i2] == i) {
|
||||
return (-i2) - 1;
|
||||
}
|
||||
int i3 = (computeHashCode % (length - 2)) + 1;
|
||||
do {
|
||||
i2 -= i3;
|
||||
if (i2 < 0) {
|
||||
i2 += length;
|
||||
}
|
||||
if (bArr[i2] != 1) {
|
||||
break;
|
||||
}
|
||||
} while (iArr[i2] != i);
|
||||
if (bArr[i2] != 2) {
|
||||
return bArr[i2] == 1 ? (-i2) - 1 : i2;
|
||||
}
|
||||
int i4 = i2;
|
||||
while (bArr[i4] != 0 && (bArr[i4] == 2 || iArr[i4] != i)) {
|
||||
i4 -= i3;
|
||||
if (i4 < 0) {
|
||||
i4 += length;
|
||||
}
|
||||
}
|
||||
return bArr[i4] == 1 ? (-i4) - 1 : i2;
|
||||
}
|
||||
|
||||
@Override // gnu.trove.TPrimitiveHash, gnu.trove.THash
|
||||
protected void removeAt(int i) {
|
||||
this._set[i] = 0;
|
||||
super.removeAt(i);
|
||||
}
|
||||
|
||||
@Override // gnu.trove.TPrimitiveHash, gnu.trove.THash
|
||||
protected int setUp(int i) {
|
||||
int up = super.setUp(i);
|
||||
this._set = i == -1 ? null : new int[up];
|
||||
return up;
|
||||
}
|
||||
|
||||
public TIntHash(int i) {
|
||||
super(i);
|
||||
this._hashingStrategy = this;
|
||||
}
|
||||
|
||||
public TIntHash(int i, float f) {
|
||||
super(i, f);
|
||||
this._hashingStrategy = this;
|
||||
}
|
||||
|
||||
public TIntHash(TIntHashingStrategy tIntHashingStrategy) {
|
||||
this._hashingStrategy = tIntHashingStrategy;
|
||||
}
|
||||
|
||||
public TIntHash(int i, TIntHashingStrategy tIntHashingStrategy) {
|
||||
super(i);
|
||||
this._hashingStrategy = tIntHashingStrategy;
|
||||
}
|
||||
|
||||
public TIntHash(int i, float f, TIntHashingStrategy tIntHashingStrategy) {
|
||||
super(i, f);
|
||||
this._hashingStrategy = tIntHashingStrategy;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user