412 lines
11 KiB
Java
412 lines
11 KiB
Java
package gnu.trove;
|
|
|
|
import java.io.IOException;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.ObjectOutputStream;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class TByteIntHashMap extends TByteHash {
|
|
protected transient int[] _values;
|
|
|
|
private static final class EqProcedure implements TByteIntProcedure {
|
|
private final TByteIntHashMap a;
|
|
|
|
EqProcedure(TByteIntHashMap tByteIntHashMap) {
|
|
this.a = tByteIntHashMap;
|
|
}
|
|
|
|
private static boolean a(int i, int i2) {
|
|
return i == i2;
|
|
}
|
|
|
|
@Override // gnu.trove.TByteIntProcedure
|
|
public final boolean a(byte b, int i) {
|
|
return this.a.index(b) >= 0 && a(i, this.a.get(b));
|
|
}
|
|
}
|
|
|
|
private final class HashProcedure implements TByteIntProcedure {
|
|
private int a;
|
|
|
|
HashProcedure() {
|
|
}
|
|
|
|
public int a() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // gnu.trove.TByteIntProcedure
|
|
public final boolean a(byte b, int i) {
|
|
int i2 = this.a;
|
|
int computeHashCode = TByteIntHashMap.this._hashingStrategy.computeHashCode(b);
|
|
HashFunctions.a(i);
|
|
this.a = i2 + (computeHashCode ^ i);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public TByteIntHashMap() {
|
|
}
|
|
|
|
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.readByte(), objectInputStream.readInt());
|
|
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(byte b, int i) {
|
|
int index = index(b);
|
|
if (index < 0) {
|
|
return false;
|
|
}
|
|
int[] iArr = this._values;
|
|
iArr[index] = iArr[index] + i;
|
|
return true;
|
|
}
|
|
|
|
@Override // gnu.trove.THash
|
|
public void clear() {
|
|
super.clear();
|
|
byte[] bArr = this._set;
|
|
int[] iArr = this._values;
|
|
if (iArr == null) {
|
|
return;
|
|
}
|
|
byte[] bArr2 = this._states;
|
|
int length = bArr.length;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
return;
|
|
}
|
|
bArr[i] = 0;
|
|
iArr[i] = 0;
|
|
bArr2[i] = 0;
|
|
length = i;
|
|
}
|
|
}
|
|
|
|
@Override // gnu.trove.TByteHash, gnu.trove.TPrimitiveHash, gnu.trove.THash
|
|
public Object clone() {
|
|
TByteIntHashMap tByteIntHashMap = (TByteIntHashMap) super.clone();
|
|
int[] iArr = this._values;
|
|
tByteIntHashMap._values = iArr == null ? null : (int[]) iArr.clone();
|
|
return tByteIntHashMap;
|
|
}
|
|
|
|
public boolean containsKey(byte b) {
|
|
return contains(b);
|
|
}
|
|
|
|
public boolean containsValue(int i) {
|
|
byte[] bArr = this._states;
|
|
int[] iArr = this._values;
|
|
if (bArr == null) {
|
|
return false;
|
|
}
|
|
int length = bArr.length;
|
|
while (true) {
|
|
int i2 = length - 1;
|
|
if (length <= 0) {
|
|
return false;
|
|
}
|
|
if (bArr[i2] == 1 && i == iArr[i2]) {
|
|
return true;
|
|
}
|
|
length = i2;
|
|
}
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (!(obj instanceof TByteIntHashMap)) {
|
|
return false;
|
|
}
|
|
TByteIntHashMap tByteIntHashMap = (TByteIntHashMap) obj;
|
|
if (tByteIntHashMap.size() != size()) {
|
|
return false;
|
|
}
|
|
return forEachEntry(new EqProcedure(tByteIntHashMap));
|
|
}
|
|
|
|
public boolean forEachEntry(TByteIntProcedure tByteIntProcedure) {
|
|
byte[] bArr = this._states;
|
|
byte[] bArr2 = this._set;
|
|
int[] iArr = this._values;
|
|
if (bArr != null) {
|
|
int length = bArr.length;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
break;
|
|
}
|
|
if (bArr[i] == 1 && !tByteIntProcedure.a(bArr2[i], iArr[i])) {
|
|
return false;
|
|
}
|
|
length = i;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public boolean forEachKey(TByteProcedure tByteProcedure) {
|
|
return forEach(tByteProcedure);
|
|
}
|
|
|
|
public boolean forEachValue(TIntProcedure tIntProcedure) {
|
|
byte[] bArr = this._states;
|
|
int[] iArr = this._values;
|
|
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;
|
|
}
|
|
|
|
public int get(byte b) {
|
|
int index = index(b);
|
|
if (index < 0) {
|
|
return 0;
|
|
}
|
|
return this._values[index];
|
|
}
|
|
|
|
public int[] getValues() {
|
|
int[] iArr = new int[size()];
|
|
int[] iArr2 = 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) {
|
|
iArr[i] = iArr2[i2];
|
|
i++;
|
|
}
|
|
length = i2;
|
|
}
|
|
}
|
|
return iArr;
|
|
}
|
|
|
|
public int hashCode() {
|
|
HashProcedure hashProcedure = new HashProcedure();
|
|
forEachEntry(hashProcedure);
|
|
return hashProcedure.a();
|
|
}
|
|
|
|
public boolean increment(byte b) {
|
|
return adjustValue(b, 1);
|
|
}
|
|
|
|
public TByteIntIterator iterator() {
|
|
return new TByteIntIterator(this);
|
|
}
|
|
|
|
public byte[] keys() {
|
|
byte[] bArr = new byte[size()];
|
|
byte[] bArr2 = this._set;
|
|
byte[] bArr3 = this._states;
|
|
if (bArr3 != null) {
|
|
int length = bArr3.length;
|
|
int i = 0;
|
|
while (true) {
|
|
int i2 = length - 1;
|
|
if (length <= 0) {
|
|
break;
|
|
}
|
|
if (bArr3[i2] == 1) {
|
|
bArr[i] = bArr2[i2];
|
|
i++;
|
|
}
|
|
length = i2;
|
|
}
|
|
}
|
|
return bArr;
|
|
}
|
|
|
|
public int put(byte b, int i) {
|
|
boolean z;
|
|
int i2;
|
|
int insertionIndex = insertionIndex(b);
|
|
if (insertionIndex < 0) {
|
|
insertionIndex = (-insertionIndex) - 1;
|
|
i2 = this._values[insertionIndex];
|
|
z = false;
|
|
} else {
|
|
z = true;
|
|
i2 = 0;
|
|
}
|
|
byte[] bArr = this._states;
|
|
byte b2 = bArr[insertionIndex];
|
|
this._set[insertionIndex] = b;
|
|
bArr[insertionIndex] = 1;
|
|
this._values[insertionIndex] = i;
|
|
if (z) {
|
|
postInsertHook(b2 == 0);
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
@Override // gnu.trove.THash
|
|
protected void rehash(int i) {
|
|
int capacity = capacity();
|
|
byte[] bArr = this._set;
|
|
int[] iArr = this._values;
|
|
byte[] bArr2 = this._states;
|
|
this._set = new byte[i];
|
|
this._values = new int[i];
|
|
this._states = new byte[i];
|
|
while (true) {
|
|
int i2 = capacity - 1;
|
|
if (capacity <= 0) {
|
|
return;
|
|
}
|
|
if (bArr2[i2] == 1) {
|
|
byte b = bArr[i2];
|
|
int insertionIndex = insertionIndex(b);
|
|
this._set[insertionIndex] = b;
|
|
this._values[insertionIndex] = iArr[i2];
|
|
this._states[insertionIndex] = 1;
|
|
}
|
|
capacity = i2;
|
|
}
|
|
}
|
|
|
|
public int remove(byte b) {
|
|
int index = index(b);
|
|
if (index < 0) {
|
|
return 0;
|
|
}
|
|
int i = this._values[index];
|
|
removeAt(index);
|
|
return i;
|
|
}
|
|
|
|
@Override // gnu.trove.TByteHash, gnu.trove.TPrimitiveHash, gnu.trove.THash
|
|
protected void removeAt(int i) {
|
|
this._values[i] = 0;
|
|
super.removeAt(i);
|
|
}
|
|
|
|
public boolean retainEntries(TByteIntProcedure tByteIntProcedure) {
|
|
byte[] bArr = this._states;
|
|
byte[] bArr2 = this._set;
|
|
int[] iArr = 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 || tByteIntProcedure.a(bArr2[i], iArr[i])) {
|
|
length = i;
|
|
} else {
|
|
removeAt(i);
|
|
length = i;
|
|
z = true;
|
|
}
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // gnu.trove.TByteHash, gnu.trove.TPrimitiveHash, gnu.trove.THash
|
|
protected int setUp(int i) {
|
|
int up = super.setUp(i);
|
|
this._values = i == -1 ? null : new int[up];
|
|
return up;
|
|
}
|
|
|
|
public String toString() {
|
|
final StringBuilder sb = new StringBuilder();
|
|
forEachEntry(new TByteIntProcedure(this) { // from class: gnu.trove.TByteIntHashMap.1
|
|
@Override // gnu.trove.TByteIntProcedure
|
|
public boolean a(byte b, int i) {
|
|
if (sb.length() != 0) {
|
|
StringBuilder sb2 = sb;
|
|
sb2.append(',');
|
|
sb2.append(' ');
|
|
}
|
|
sb.append((int) b);
|
|
sb.append('=');
|
|
sb.append(i);
|
|
return true;
|
|
}
|
|
});
|
|
sb.append('}');
|
|
sb.insert(0, '{');
|
|
return sb.toString();
|
|
}
|
|
|
|
public void transformValues(TIntFunction tIntFunction) {
|
|
byte[] bArr = this._states;
|
|
int[] iArr = this._values;
|
|
if (bArr == null) {
|
|
return;
|
|
}
|
|
int length = bArr.length;
|
|
while (true) {
|
|
int i = length - 1;
|
|
if (length <= 0) {
|
|
return;
|
|
}
|
|
if (bArr[i] == 1) {
|
|
iArr[i] = tIntFunction.a(iArr[i]);
|
|
}
|
|
length = i;
|
|
}
|
|
}
|
|
|
|
public TByteIntHashMap(int i) {
|
|
super(i);
|
|
}
|
|
|
|
public TByteIntHashMap(int i, float f) {
|
|
super(i, f);
|
|
}
|
|
|
|
public TByteIntHashMap(TByteHashingStrategy tByteHashingStrategy) {
|
|
super(tByteHashingStrategy);
|
|
}
|
|
|
|
public TByteIntHashMap(int i, TByteHashingStrategy tByteHashingStrategy) {
|
|
super(i, tByteHashingStrategy);
|
|
}
|
|
|
|
public TByteIntHashMap(int i, float f, TByteHashingStrategy tByteHashingStrategy) {
|
|
super(i, f, tByteHashingStrategy);
|
|
}
|
|
}
|