ADD week 5
This commit is contained in:
108
02-Easy5/E5/sources/androidx/collection/ArrayMap.java
Normal file
108
02-Easy5/E5/sources/androidx/collection/ArrayMap.java
Normal file
@ -0,0 +1,108 @@
|
||||
package androidx.collection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ArrayMap<K, V> extends SimpleArrayMap<K, V> implements Map<K, V> {
|
||||
MapCollections<K, V> mCollections;
|
||||
|
||||
public ArrayMap() {
|
||||
}
|
||||
|
||||
public ArrayMap(int i) {
|
||||
super(i);
|
||||
}
|
||||
|
||||
public ArrayMap(SimpleArrayMap simpleArrayMap) {
|
||||
super(simpleArrayMap);
|
||||
}
|
||||
|
||||
private MapCollections<K, V> getCollection() {
|
||||
if (this.mCollections == null) {
|
||||
this.mCollections = new MapCollections<K, V>() { // from class: androidx.collection.ArrayMap.1
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected Map<K, V> colGetMap() {
|
||||
return ArrayMap.this;
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected int colGetSize() {
|
||||
return ArrayMap.this.mSize;
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected Object colGetEntry(int i, int i2) {
|
||||
return ArrayMap.this.mArray[(i << 1) + i2];
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected int colIndexOfKey(Object obj) {
|
||||
return ArrayMap.this.indexOfKey(obj);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected int colIndexOfValue(Object obj) {
|
||||
return ArrayMap.this.indexOfValue(obj);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected void colPut(K k, V v) {
|
||||
ArrayMap.this.put(k, v);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected V colSetValue(int i, V v) {
|
||||
return ArrayMap.this.setValueAt(i, v);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected void colRemoveAt(int i) {
|
||||
ArrayMap.this.removeAt(i);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected void colClear() {
|
||||
ArrayMap.this.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.mCollections;
|
||||
}
|
||||
|
||||
public boolean containsAll(Collection<?> collection) {
|
||||
return MapCollections.containsAllHelper(this, collection);
|
||||
}
|
||||
|
||||
@Override // java.util.Map
|
||||
public void putAll(Map<? extends K, ? extends V> map) {
|
||||
ensureCapacity(this.mSize + map.size());
|
||||
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
return MapCollections.removeAllHelper(this, collection);
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
return MapCollections.retainAllHelper(this, collection);
|
||||
}
|
||||
|
||||
@Override // java.util.Map
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
return getCollection().getEntrySet();
|
||||
}
|
||||
|
||||
@Override // java.util.Map
|
||||
public Set<K> keySet() {
|
||||
return getCollection().getKeySet();
|
||||
}
|
||||
|
||||
@Override // java.util.Map
|
||||
public Collection<V> values() {
|
||||
return getCollection().getValues();
|
||||
}
|
||||
}
|
511
02-Easy5/E5/sources/androidx/collection/ArraySet.java
Normal file
511
02-Easy5/E5/sources/androidx/collection/ArraySet.java
Normal file
@ -0,0 +1,511 @@
|
||||
package androidx.collection;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ArraySet<E> implements Collection<E>, Set<E> {
|
||||
private static final int BASE_SIZE = 4;
|
||||
private static final int CACHE_SIZE = 10;
|
||||
private static final boolean DEBUG = false;
|
||||
private static final int[] INT = new int[0];
|
||||
private static final Object[] OBJECT = new Object[0];
|
||||
private static final String TAG = "ArraySet";
|
||||
private static Object[] sBaseCache;
|
||||
private static int sBaseCacheSize;
|
||||
private static Object[] sTwiceBaseCache;
|
||||
private static int sTwiceBaseCacheSize;
|
||||
Object[] mArray;
|
||||
private MapCollections<E, E> mCollections;
|
||||
private int[] mHashes;
|
||||
int mSize;
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean isEmpty() {
|
||||
return this.mSize <= 0;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public int size() {
|
||||
return this.mSize;
|
||||
}
|
||||
|
||||
private int indexOf(Object obj, int i) {
|
||||
int i2 = this.mSize;
|
||||
if (i2 == 0) {
|
||||
return -1;
|
||||
}
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mHashes, i2, i);
|
||||
if (binarySearch < 0 || obj.equals(this.mArray[binarySearch])) {
|
||||
return binarySearch;
|
||||
}
|
||||
int i3 = binarySearch + 1;
|
||||
while (i3 < i2 && this.mHashes[i3] == i) {
|
||||
if (obj.equals(this.mArray[i3])) {
|
||||
return i3;
|
||||
}
|
||||
i3++;
|
||||
}
|
||||
for (int i4 = binarySearch - 1; i4 >= 0 && this.mHashes[i4] == i; i4--) {
|
||||
if (obj.equals(this.mArray[i4])) {
|
||||
return i4;
|
||||
}
|
||||
}
|
||||
return ~i3;
|
||||
}
|
||||
|
||||
private int indexOfNull() {
|
||||
int i = this.mSize;
|
||||
if (i == 0) {
|
||||
return -1;
|
||||
}
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mHashes, i, 0);
|
||||
if (binarySearch < 0 || this.mArray[binarySearch] == null) {
|
||||
return binarySearch;
|
||||
}
|
||||
int i2 = binarySearch + 1;
|
||||
while (i2 < i && this.mHashes[i2] == 0) {
|
||||
if (this.mArray[i2] == null) {
|
||||
return i2;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
for (int i3 = binarySearch - 1; i3 >= 0 && this.mHashes[i3] == 0; i3--) {
|
||||
if (this.mArray[i3] == null) {
|
||||
return i3;
|
||||
}
|
||||
}
|
||||
return ~i2;
|
||||
}
|
||||
|
||||
private void allocArrays(int i) {
|
||||
if (i == 8) {
|
||||
synchronized (ArraySet.class) {
|
||||
Object[] objArr = sTwiceBaseCache;
|
||||
if (objArr != null) {
|
||||
this.mArray = objArr;
|
||||
sTwiceBaseCache = (Object[]) objArr[0];
|
||||
this.mHashes = (int[]) objArr[1];
|
||||
objArr[1] = null;
|
||||
objArr[0] = null;
|
||||
sTwiceBaseCacheSize--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (i == 4) {
|
||||
synchronized (ArraySet.class) {
|
||||
Object[] objArr2 = sBaseCache;
|
||||
if (objArr2 != null) {
|
||||
this.mArray = objArr2;
|
||||
sBaseCache = (Object[]) objArr2[0];
|
||||
this.mHashes = (int[]) objArr2[1];
|
||||
objArr2[1] = null;
|
||||
objArr2[0] = null;
|
||||
sBaseCacheSize--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mHashes = new int[i];
|
||||
this.mArray = new Object[i];
|
||||
}
|
||||
|
||||
private static void freeArrays(int[] iArr, Object[] objArr, int i) {
|
||||
if (iArr.length == 8) {
|
||||
synchronized (ArraySet.class) {
|
||||
if (sTwiceBaseCacheSize < 10) {
|
||||
objArr[0] = sTwiceBaseCache;
|
||||
objArr[1] = iArr;
|
||||
for (int i2 = i - 1; i2 >= 2; i2--) {
|
||||
objArr[i2] = null;
|
||||
}
|
||||
sTwiceBaseCache = objArr;
|
||||
sTwiceBaseCacheSize++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (iArr.length == 4) {
|
||||
synchronized (ArraySet.class) {
|
||||
if (sBaseCacheSize < 10) {
|
||||
objArr[0] = sBaseCache;
|
||||
objArr[1] = iArr;
|
||||
for (int i3 = i - 1; i3 >= 2; i3--) {
|
||||
objArr[i3] = null;
|
||||
}
|
||||
sBaseCache = objArr;
|
||||
sBaseCacheSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArraySet() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public ArraySet(int i) {
|
||||
if (i == 0) {
|
||||
this.mHashes = INT;
|
||||
this.mArray = OBJECT;
|
||||
} else {
|
||||
allocArrays(i);
|
||||
}
|
||||
this.mSize = 0;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public ArraySet(ArraySet<E> arraySet) {
|
||||
this();
|
||||
if (arraySet != 0) {
|
||||
addAll((ArraySet) arraySet);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public ArraySet(Collection<E> collection) {
|
||||
this();
|
||||
if (collection != 0) {
|
||||
addAll(collection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public void clear() {
|
||||
int i = this.mSize;
|
||||
if (i != 0) {
|
||||
freeArrays(this.mHashes, this.mArray, i);
|
||||
this.mHashes = INT;
|
||||
this.mArray = OBJECT;
|
||||
this.mSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureCapacity(int i) {
|
||||
int[] iArr = this.mHashes;
|
||||
if (iArr.length < i) {
|
||||
Object[] objArr = this.mArray;
|
||||
allocArrays(i);
|
||||
int i2 = this.mSize;
|
||||
if (i2 > 0) {
|
||||
System.arraycopy(iArr, 0, this.mHashes, 0, i2);
|
||||
System.arraycopy(objArr, 0, this.mArray, 0, this.mSize);
|
||||
}
|
||||
freeArrays(iArr, objArr, this.mSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean contains(Object obj) {
|
||||
return indexOf(obj) >= 0;
|
||||
}
|
||||
|
||||
public int indexOf(Object obj) {
|
||||
return obj == null ? indexOfNull() : indexOf(obj, obj.hashCode());
|
||||
}
|
||||
|
||||
public E valueAt(int i) {
|
||||
return (E) this.mArray[i];
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean add(E e) {
|
||||
int i;
|
||||
int indexOf;
|
||||
if (e == null) {
|
||||
indexOf = indexOfNull();
|
||||
i = 0;
|
||||
} else {
|
||||
int hashCode = e.hashCode();
|
||||
i = hashCode;
|
||||
indexOf = indexOf(e, hashCode);
|
||||
}
|
||||
if (indexOf >= 0) {
|
||||
return false;
|
||||
}
|
||||
int i2 = ~indexOf;
|
||||
int i3 = this.mSize;
|
||||
int[] iArr = this.mHashes;
|
||||
if (i3 >= iArr.length) {
|
||||
int i4 = 8;
|
||||
if (i3 >= 8) {
|
||||
i4 = (i3 >> 1) + i3;
|
||||
} else if (i3 < 4) {
|
||||
i4 = 4;
|
||||
}
|
||||
Object[] objArr = this.mArray;
|
||||
allocArrays(i4);
|
||||
int[] iArr2 = this.mHashes;
|
||||
if (iArr2.length > 0) {
|
||||
System.arraycopy(iArr, 0, iArr2, 0, iArr.length);
|
||||
System.arraycopy(objArr, 0, this.mArray, 0, objArr.length);
|
||||
}
|
||||
freeArrays(iArr, objArr, this.mSize);
|
||||
}
|
||||
int i5 = this.mSize;
|
||||
if (i2 < i5) {
|
||||
int[] iArr3 = this.mHashes;
|
||||
int i6 = i2 + 1;
|
||||
System.arraycopy(iArr3, i2, iArr3, i6, i5 - i2);
|
||||
Object[] objArr2 = this.mArray;
|
||||
System.arraycopy(objArr2, i2, objArr2, i6, this.mSize - i2);
|
||||
}
|
||||
this.mHashes[i2] = i;
|
||||
this.mArray[i2] = e;
|
||||
this.mSize++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addAll(ArraySet<? extends E> arraySet) {
|
||||
int i = arraySet.mSize;
|
||||
ensureCapacity(this.mSize + i);
|
||||
if (this.mSize != 0) {
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
add(arraySet.valueAt(i2));
|
||||
}
|
||||
} else if (i > 0) {
|
||||
System.arraycopy(arraySet.mHashes, 0, this.mHashes, 0, i);
|
||||
System.arraycopy(arraySet.mArray, 0, this.mArray, 0, i);
|
||||
this.mSize = i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean remove(Object obj) {
|
||||
int indexOf = indexOf(obj);
|
||||
if (indexOf < 0) {
|
||||
return false;
|
||||
}
|
||||
removeAt(indexOf);
|
||||
return true;
|
||||
}
|
||||
|
||||
public E removeAt(int i) {
|
||||
Object[] objArr = this.mArray;
|
||||
E e = (E) objArr[i];
|
||||
int i2 = this.mSize;
|
||||
if (i2 <= 1) {
|
||||
freeArrays(this.mHashes, objArr, i2);
|
||||
this.mHashes = INT;
|
||||
this.mArray = OBJECT;
|
||||
this.mSize = 0;
|
||||
} else {
|
||||
int[] iArr = this.mHashes;
|
||||
if (iArr.length > 8 && i2 < iArr.length / 3) {
|
||||
allocArrays(i2 > 8 ? i2 + (i2 >> 1) : 8);
|
||||
this.mSize--;
|
||||
if (i > 0) {
|
||||
System.arraycopy(iArr, 0, this.mHashes, 0, i);
|
||||
System.arraycopy(objArr, 0, this.mArray, 0, i);
|
||||
}
|
||||
int i3 = this.mSize;
|
||||
if (i < i3) {
|
||||
int i4 = i + 1;
|
||||
System.arraycopy(iArr, i4, this.mHashes, i, i3 - i);
|
||||
System.arraycopy(objArr, i4, this.mArray, i, this.mSize - i);
|
||||
}
|
||||
} else {
|
||||
int i5 = i2 - 1;
|
||||
this.mSize = i5;
|
||||
if (i < i5) {
|
||||
int i6 = i + 1;
|
||||
System.arraycopy(iArr, i6, iArr, i, i5 - i);
|
||||
Object[] objArr2 = this.mArray;
|
||||
System.arraycopy(objArr2, i6, objArr2, i, this.mSize - i);
|
||||
}
|
||||
this.mArray[this.mSize] = null;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
public boolean removeAll(ArraySet<? extends E> arraySet) {
|
||||
int i = arraySet.mSize;
|
||||
int i2 = this.mSize;
|
||||
for (int i3 = 0; i3 < i; i3++) {
|
||||
remove(arraySet.valueAt(i3));
|
||||
}
|
||||
return i2 != this.mSize;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public Object[] toArray() {
|
||||
int i = this.mSize;
|
||||
Object[] objArr = new Object[i];
|
||||
System.arraycopy(this.mArray, 0, objArr, 0, i);
|
||||
return objArr;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public <T> T[] toArray(T[] tArr) {
|
||||
if (tArr.length < this.mSize) {
|
||||
tArr = (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), this.mSize));
|
||||
}
|
||||
System.arraycopy(this.mArray, 0, tArr, 0, this.mSize);
|
||||
int length = tArr.length;
|
||||
int i = this.mSize;
|
||||
if (length > i) {
|
||||
tArr[i] = null;
|
||||
}
|
||||
return tArr;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Set) {
|
||||
Set set = (Set) obj;
|
||||
if (size() != set.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
try {
|
||||
if (!set.contains(valueAt(i))) {
|
||||
return false;
|
||||
}
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public int hashCode() {
|
||||
int[] iArr = this.mHashes;
|
||||
int i = this.mSize;
|
||||
int i2 = 0;
|
||||
for (int i3 = 0; i3 < i; i3++) {
|
||||
i2 += iArr[i3];
|
||||
}
|
||||
return i2;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (isEmpty()) {
|
||||
return "{}";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(this.mSize * 14);
|
||||
sb.append('{');
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
E valueAt = valueAt(i);
|
||||
if (valueAt != this) {
|
||||
sb.append(valueAt);
|
||||
} else {
|
||||
sb.append("(this Set)");
|
||||
}
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private MapCollections<E, E> getCollection() {
|
||||
if (this.mCollections == null) {
|
||||
this.mCollections = new MapCollections<E, E>() { // from class: androidx.collection.ArraySet.1
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected int colGetSize() {
|
||||
return ArraySet.this.mSize;
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected Object colGetEntry(int i, int i2) {
|
||||
return ArraySet.this.mArray[i];
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected int colIndexOfKey(Object obj) {
|
||||
return ArraySet.this.indexOf(obj);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected int colIndexOfValue(Object obj) {
|
||||
return ArraySet.this.indexOf(obj);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected Map<E, E> colGetMap() {
|
||||
throw new UnsupportedOperationException("not a map");
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected void colPut(E e, E e2) {
|
||||
ArraySet.this.add(e);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected E colSetValue(int i, E e) {
|
||||
throw new UnsupportedOperationException("not a map");
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected void colRemoveAt(int i) {
|
||||
ArraySet.this.removeAt(i);
|
||||
}
|
||||
|
||||
@Override // androidx.collection.MapCollections
|
||||
protected void colClear() {
|
||||
ArraySet.this.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
return this.mCollections;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.lang.Iterable, java.util.Set
|
||||
public Iterator<E> iterator() {
|
||||
return getCollection().getKeySet().iterator();
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean containsAll(Collection<?> collection) {
|
||||
Iterator<?> it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!contains(it.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean addAll(Collection<? extends E> collection) {
|
||||
ensureCapacity(this.mSize + collection.size());
|
||||
Iterator<? extends E> it = collection.iterator();
|
||||
boolean z = false;
|
||||
while (it.hasNext()) {
|
||||
z |= add(it.next());
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
Iterator<?> it = collection.iterator();
|
||||
boolean z = false;
|
||||
while (it.hasNext()) {
|
||||
z |= remove(it.next());
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.util.Set
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
boolean z = false;
|
||||
for (int i = this.mSize - 1; i >= 0; i--) {
|
||||
if (!collection.contains(this.mArray[i])) {
|
||||
removeAt(i);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
}
|
186
02-Easy5/E5/sources/androidx/collection/CircularArray.java
Normal file
186
02-Easy5/E5/sources/androidx/collection/CircularArray.java
Normal file
@ -0,0 +1,186 @@
|
||||
package androidx.collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class CircularArray<E> {
|
||||
private int mCapacityBitmask;
|
||||
private E[] mElements;
|
||||
private int mHead;
|
||||
private int mTail;
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.mHead == this.mTail;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return (this.mTail - this.mHead) & this.mCapacityBitmask;
|
||||
}
|
||||
|
||||
private void doubleCapacity() {
|
||||
E[] eArr = this.mElements;
|
||||
int length = eArr.length;
|
||||
int i = this.mHead;
|
||||
int i2 = length - i;
|
||||
int i3 = length << 1;
|
||||
if (i3 < 0) {
|
||||
throw new RuntimeException("Max array capacity exceeded");
|
||||
}
|
||||
Object[] objArr = new Object[i3];
|
||||
System.arraycopy(eArr, i, objArr, 0, i2);
|
||||
System.arraycopy(this.mElements, 0, objArr, i2, this.mHead);
|
||||
this.mElements = (E[]) objArr;
|
||||
this.mHead = 0;
|
||||
this.mTail = length;
|
||||
this.mCapacityBitmask = i3 - 1;
|
||||
}
|
||||
|
||||
public CircularArray() {
|
||||
this(8);
|
||||
}
|
||||
|
||||
public CircularArray(int i) {
|
||||
if (i < 1) {
|
||||
throw new IllegalArgumentException("capacity must be >= 1");
|
||||
}
|
||||
if (i > 1073741824) {
|
||||
throw new IllegalArgumentException("capacity must be <= 2^30");
|
||||
}
|
||||
i = Integer.bitCount(i) != 1 ? Integer.highestOneBit(i - 1) << 1 : i;
|
||||
this.mCapacityBitmask = i - 1;
|
||||
this.mElements = (E[]) new Object[i];
|
||||
}
|
||||
|
||||
public void addFirst(E e) {
|
||||
int i = (this.mHead - 1) & this.mCapacityBitmask;
|
||||
this.mHead = i;
|
||||
this.mElements[i] = e;
|
||||
if (i == this.mTail) {
|
||||
doubleCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
public void addLast(E e) {
|
||||
E[] eArr = this.mElements;
|
||||
int i = this.mTail;
|
||||
eArr[i] = e;
|
||||
int i2 = this.mCapacityBitmask & (i + 1);
|
||||
this.mTail = i2;
|
||||
if (i2 == this.mHead) {
|
||||
doubleCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
public E popFirst() {
|
||||
int i = this.mHead;
|
||||
if (i == this.mTail) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
E[] eArr = this.mElements;
|
||||
E e = eArr[i];
|
||||
eArr[i] = null;
|
||||
this.mHead = (i + 1) & this.mCapacityBitmask;
|
||||
return e;
|
||||
}
|
||||
|
||||
public E popLast() {
|
||||
int i = this.mHead;
|
||||
int i2 = this.mTail;
|
||||
if (i == i2) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
int i3 = this.mCapacityBitmask & (i2 - 1);
|
||||
E[] eArr = this.mElements;
|
||||
E e = eArr[i3];
|
||||
eArr[i3] = null;
|
||||
this.mTail = i3;
|
||||
return e;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
removeFromStart(size());
|
||||
}
|
||||
|
||||
public void removeFromStart(int i) {
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
if (i > size()) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
int length = this.mElements.length;
|
||||
int i2 = this.mHead;
|
||||
if (i < length - i2) {
|
||||
length = i2 + i;
|
||||
}
|
||||
while (i2 < length) {
|
||||
this.mElements[i2] = null;
|
||||
i2++;
|
||||
}
|
||||
int i3 = this.mHead;
|
||||
int i4 = length - i3;
|
||||
int i5 = i - i4;
|
||||
this.mHead = this.mCapacityBitmask & (i3 + i4);
|
||||
if (i5 > 0) {
|
||||
for (int i6 = 0; i6 < i5; i6++) {
|
||||
this.mElements[i6] = null;
|
||||
}
|
||||
this.mHead = i5;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromEnd(int i) {
|
||||
int i2;
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
if (i > size()) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
int i3 = this.mTail;
|
||||
int i4 = i < i3 ? i3 - i : 0;
|
||||
int i5 = i4;
|
||||
while (true) {
|
||||
i2 = this.mTail;
|
||||
if (i5 >= i2) {
|
||||
break;
|
||||
}
|
||||
this.mElements[i5] = null;
|
||||
i5++;
|
||||
}
|
||||
int i6 = i2 - i4;
|
||||
int i7 = i - i6;
|
||||
this.mTail = i2 - i6;
|
||||
if (i7 > 0) {
|
||||
int length = this.mElements.length;
|
||||
this.mTail = length;
|
||||
int i8 = length - i7;
|
||||
for (int i9 = i8; i9 < this.mTail; i9++) {
|
||||
this.mElements[i9] = null;
|
||||
}
|
||||
this.mTail = i8;
|
||||
}
|
||||
}
|
||||
|
||||
public E getFirst() {
|
||||
int i = this.mHead;
|
||||
if (i == this.mTail) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return this.mElements[i];
|
||||
}
|
||||
|
||||
public E getLast() {
|
||||
int i = this.mHead;
|
||||
int i2 = this.mTail;
|
||||
if (i == i2) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return this.mElements[(i2 - 1) & this.mCapacityBitmask];
|
||||
}
|
||||
|
||||
public E get(int i) {
|
||||
if (i < 0 || i >= size()) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return this.mElements[this.mCapacityBitmask & (this.mHead + i)];
|
||||
}
|
||||
}
|
141
02-Easy5/E5/sources/androidx/collection/CircularIntArray.java
Normal file
141
02-Easy5/E5/sources/androidx/collection/CircularIntArray.java
Normal file
@ -0,0 +1,141 @@
|
||||
package androidx.collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class CircularIntArray {
|
||||
private int mCapacityBitmask;
|
||||
private int[] mElements;
|
||||
private int mHead;
|
||||
private int mTail;
|
||||
|
||||
public void clear() {
|
||||
this.mTail = this.mHead;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.mHead == this.mTail;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return (this.mTail - this.mHead) & this.mCapacityBitmask;
|
||||
}
|
||||
|
||||
private void doubleCapacity() {
|
||||
int[] iArr = this.mElements;
|
||||
int length = iArr.length;
|
||||
int i = this.mHead;
|
||||
int i2 = length - i;
|
||||
int i3 = length << 1;
|
||||
if (i3 < 0) {
|
||||
throw new RuntimeException("Max array capacity exceeded");
|
||||
}
|
||||
int[] iArr2 = new int[i3];
|
||||
System.arraycopy(iArr, i, iArr2, 0, i2);
|
||||
System.arraycopy(this.mElements, 0, iArr2, i2, this.mHead);
|
||||
this.mElements = iArr2;
|
||||
this.mHead = 0;
|
||||
this.mTail = length;
|
||||
this.mCapacityBitmask = i3 - 1;
|
||||
}
|
||||
|
||||
public CircularIntArray() {
|
||||
this(8);
|
||||
}
|
||||
|
||||
public CircularIntArray(int i) {
|
||||
if (i < 1) {
|
||||
throw new IllegalArgumentException("capacity must be >= 1");
|
||||
}
|
||||
if (i > 1073741824) {
|
||||
throw new IllegalArgumentException("capacity must be <= 2^30");
|
||||
}
|
||||
i = Integer.bitCount(i) != 1 ? Integer.highestOneBit(i - 1) << 1 : i;
|
||||
this.mCapacityBitmask = i - 1;
|
||||
this.mElements = new int[i];
|
||||
}
|
||||
|
||||
public void addFirst(int i) {
|
||||
int i2 = (this.mHead - 1) & this.mCapacityBitmask;
|
||||
this.mHead = i2;
|
||||
this.mElements[i2] = i;
|
||||
if (i2 == this.mTail) {
|
||||
doubleCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
public void addLast(int i) {
|
||||
int[] iArr = this.mElements;
|
||||
int i2 = this.mTail;
|
||||
iArr[i2] = i;
|
||||
int i3 = this.mCapacityBitmask & (i2 + 1);
|
||||
this.mTail = i3;
|
||||
if (i3 == this.mHead) {
|
||||
doubleCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
public int popFirst() {
|
||||
int i = this.mHead;
|
||||
if (i == this.mTail) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
int i2 = this.mElements[i];
|
||||
this.mHead = (i + 1) & this.mCapacityBitmask;
|
||||
return i2;
|
||||
}
|
||||
|
||||
public int popLast() {
|
||||
int i = this.mHead;
|
||||
int i2 = this.mTail;
|
||||
if (i == i2) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
int i3 = this.mCapacityBitmask & (i2 - 1);
|
||||
int i4 = this.mElements[i3];
|
||||
this.mTail = i3;
|
||||
return i4;
|
||||
}
|
||||
|
||||
public void removeFromStart(int i) {
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
if (i > size()) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
this.mHead = this.mCapacityBitmask & (this.mHead + i);
|
||||
}
|
||||
|
||||
public void removeFromEnd(int i) {
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
if (i > size()) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
this.mTail = this.mCapacityBitmask & (this.mTail - i);
|
||||
}
|
||||
|
||||
public int getFirst() {
|
||||
int i = this.mHead;
|
||||
if (i == this.mTail) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return this.mElements[i];
|
||||
}
|
||||
|
||||
public int getLast() {
|
||||
int i = this.mHead;
|
||||
int i2 = this.mTail;
|
||||
if (i == i2) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return this.mElements[(i2 - 1) & this.mCapacityBitmask];
|
||||
}
|
||||
|
||||
public int get(int i) {
|
||||
if (i < 0 || i >= size()) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
return this.mElements[this.mCapacityBitmask & (this.mHead + i)];
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package androidx.collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ContainerHelpers {
|
||||
static final int[] EMPTY_INTS = new int[0];
|
||||
static final long[] EMPTY_LONGS = new long[0];
|
||||
static final Object[] EMPTY_OBJECTS = new Object[0];
|
||||
|
||||
public static int idealByteArraySize(int i) {
|
||||
for (int i2 = 4; i2 < 32; i2++) {
|
||||
int i3 = (1 << i2) - 12;
|
||||
if (i <= i3) {
|
||||
return i3;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int idealIntArraySize(int i) {
|
||||
return idealByteArraySize(i * 4) / 4;
|
||||
}
|
||||
|
||||
public static int idealLongArraySize(int i) {
|
||||
return idealByteArraySize(i * 8) / 8;
|
||||
}
|
||||
|
||||
public static boolean equal(Object obj, Object obj2) {
|
||||
return obj == obj2 || (obj != null && obj.equals(obj2));
|
||||
}
|
||||
|
||||
static int binarySearch(int[] iArr, int i, int i2) {
|
||||
int i3 = i - 1;
|
||||
int i4 = 0;
|
||||
while (i4 <= i3) {
|
||||
int i5 = (i4 + i3) >>> 1;
|
||||
int i6 = iArr[i5];
|
||||
if (i6 < i2) {
|
||||
i4 = i5 + 1;
|
||||
} else {
|
||||
if (i6 <= i2) {
|
||||
return i5;
|
||||
}
|
||||
i3 = i5 - 1;
|
||||
}
|
||||
}
|
||||
return ~i4;
|
||||
}
|
||||
|
||||
static int binarySearch(long[] jArr, int i, long j) {
|
||||
int i2 = i - 1;
|
||||
int i3 = 0;
|
||||
while (i3 <= i2) {
|
||||
int i4 = (i3 + i2) >>> 1;
|
||||
long j2 = jArr[i4];
|
||||
if (j2 < j) {
|
||||
i3 = i4 + 1;
|
||||
} else {
|
||||
if (j2 <= j) {
|
||||
return i4;
|
||||
}
|
||||
i2 = i4 - 1;
|
||||
}
|
||||
}
|
||||
return ~i3;
|
||||
}
|
||||
|
||||
private ContainerHelpers() {
|
||||
}
|
||||
}
|
311
02-Easy5/E5/sources/androidx/collection/LongSparseArray.java
Normal file
311
02-Easy5/E5/sources/androidx/collection/LongSparseArray.java
Normal file
@ -0,0 +1,311 @@
|
||||
package androidx.collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LongSparseArray<E> implements Cloneable {
|
||||
private static final Object DELETED = new Object();
|
||||
private boolean mGarbage;
|
||||
private long[] mKeys;
|
||||
private int mSize;
|
||||
private Object[] mValues;
|
||||
|
||||
public LongSparseArray() {
|
||||
this(10);
|
||||
}
|
||||
|
||||
public LongSparseArray(int i) {
|
||||
this.mGarbage = false;
|
||||
if (i == 0) {
|
||||
this.mKeys = ContainerHelpers.EMPTY_LONGS;
|
||||
this.mValues = ContainerHelpers.EMPTY_OBJECTS;
|
||||
} else {
|
||||
int idealLongArraySize = ContainerHelpers.idealLongArraySize(i);
|
||||
this.mKeys = new long[idealLongArraySize];
|
||||
this.mValues = new Object[idealLongArraySize];
|
||||
}
|
||||
}
|
||||
|
||||
/* renamed from: clone, reason: merged with bridge method [inline-methods] */
|
||||
public LongSparseArray<E> m45clone() {
|
||||
try {
|
||||
LongSparseArray<E> longSparseArray = (LongSparseArray) super.clone();
|
||||
longSparseArray.mKeys = (long[]) this.mKeys.clone();
|
||||
longSparseArray.mValues = (Object[]) this.mValues.clone();
|
||||
return longSparseArray;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public E get(long j) {
|
||||
return get(j, null);
|
||||
}
|
||||
|
||||
public E get(long j, E e) {
|
||||
E e2;
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mKeys, this.mSize, j);
|
||||
return (binarySearch < 0 || (e2 = (E) this.mValues[binarySearch]) == DELETED) ? e : e2;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void delete(long j) {
|
||||
remove(j);
|
||||
}
|
||||
|
||||
public void remove(long j) {
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mKeys, this.mSize, j);
|
||||
if (binarySearch >= 0) {
|
||||
Object[] objArr = this.mValues;
|
||||
Object obj = objArr[binarySearch];
|
||||
Object obj2 = DELETED;
|
||||
if (obj != obj2) {
|
||||
objArr[binarySearch] = obj2;
|
||||
this.mGarbage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(long j, Object obj) {
|
||||
int indexOfKey = indexOfKey(j);
|
||||
if (indexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
E valueAt = valueAt(indexOfKey);
|
||||
if (obj != valueAt && (obj == null || !obj.equals(valueAt))) {
|
||||
return false;
|
||||
}
|
||||
removeAt(indexOfKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeAt(int i) {
|
||||
Object[] objArr = this.mValues;
|
||||
Object obj = objArr[i];
|
||||
Object obj2 = DELETED;
|
||||
if (obj != obj2) {
|
||||
objArr[i] = obj2;
|
||||
this.mGarbage = true;
|
||||
}
|
||||
}
|
||||
|
||||
public E replace(long j, E e) {
|
||||
int indexOfKey = indexOfKey(j);
|
||||
if (indexOfKey < 0) {
|
||||
return null;
|
||||
}
|
||||
Object[] objArr = this.mValues;
|
||||
E e2 = (E) objArr[indexOfKey];
|
||||
objArr[indexOfKey] = e;
|
||||
return e2;
|
||||
}
|
||||
|
||||
public boolean replace(long j, E e, E e2) {
|
||||
int indexOfKey = indexOfKey(j);
|
||||
if (indexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
Object obj = this.mValues[indexOfKey];
|
||||
if (obj != e && (e == null || !e.equals(obj))) {
|
||||
return false;
|
||||
}
|
||||
this.mValues[indexOfKey] = e2;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void gc() {
|
||||
int i = this.mSize;
|
||||
long[] jArr = this.mKeys;
|
||||
Object[] objArr = this.mValues;
|
||||
int i2 = 0;
|
||||
for (int i3 = 0; i3 < i; i3++) {
|
||||
Object obj = objArr[i3];
|
||||
if (obj != DELETED) {
|
||||
if (i3 != i2) {
|
||||
jArr[i2] = jArr[i3];
|
||||
objArr[i2] = obj;
|
||||
objArr[i3] = null;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
this.mGarbage = false;
|
||||
this.mSize = i2;
|
||||
}
|
||||
|
||||
public void put(long j, E e) {
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mKeys, this.mSize, j);
|
||||
if (binarySearch >= 0) {
|
||||
this.mValues[binarySearch] = e;
|
||||
return;
|
||||
}
|
||||
int i = ~binarySearch;
|
||||
int i2 = this.mSize;
|
||||
if (i < i2) {
|
||||
Object[] objArr = this.mValues;
|
||||
if (objArr[i] == DELETED) {
|
||||
this.mKeys[i] = j;
|
||||
objArr[i] = e;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.mGarbage && i2 >= this.mKeys.length) {
|
||||
gc();
|
||||
i = ~ContainerHelpers.binarySearch(this.mKeys, this.mSize, j);
|
||||
}
|
||||
int i3 = this.mSize;
|
||||
if (i3 >= this.mKeys.length) {
|
||||
int idealLongArraySize = ContainerHelpers.idealLongArraySize(i3 + 1);
|
||||
long[] jArr = new long[idealLongArraySize];
|
||||
Object[] objArr2 = new Object[idealLongArraySize];
|
||||
long[] jArr2 = this.mKeys;
|
||||
System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
|
||||
Object[] objArr3 = this.mValues;
|
||||
System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
|
||||
this.mKeys = jArr;
|
||||
this.mValues = objArr2;
|
||||
}
|
||||
int i4 = this.mSize;
|
||||
if (i4 - i != 0) {
|
||||
long[] jArr3 = this.mKeys;
|
||||
int i5 = i + 1;
|
||||
System.arraycopy(jArr3, i, jArr3, i5, i4 - i);
|
||||
Object[] objArr4 = this.mValues;
|
||||
System.arraycopy(objArr4, i, objArr4, i5, this.mSize - i);
|
||||
}
|
||||
this.mKeys[i] = j;
|
||||
this.mValues[i] = e;
|
||||
this.mSize++;
|
||||
}
|
||||
|
||||
public void putAll(LongSparseArray<? extends E> longSparseArray) {
|
||||
int size = longSparseArray.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
put(longSparseArray.keyAt(i), longSparseArray.valueAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
public E putIfAbsent(long j, E e) {
|
||||
E e2 = get(j);
|
||||
if (e2 == null) {
|
||||
put(j, e);
|
||||
}
|
||||
return e2;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return this.mSize;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
public long keyAt(int i) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return this.mKeys[i];
|
||||
}
|
||||
|
||||
public E valueAt(int i) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return (E) this.mValues[i];
|
||||
}
|
||||
|
||||
public void setValueAt(int i, E e) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
this.mValues[i] = e;
|
||||
}
|
||||
|
||||
public int indexOfKey(long j) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return ContainerHelpers.binarySearch(this.mKeys, this.mSize, j);
|
||||
}
|
||||
|
||||
public int indexOfValue(E e) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
if (this.mValues[i] == e) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean containsKey(long j) {
|
||||
return indexOfKey(j) >= 0;
|
||||
}
|
||||
|
||||
public boolean containsValue(E e) {
|
||||
return indexOfValue(e) >= 0;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
int i = this.mSize;
|
||||
Object[] objArr = this.mValues;
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
objArr[i2] = null;
|
||||
}
|
||||
this.mSize = 0;
|
||||
this.mGarbage = false;
|
||||
}
|
||||
|
||||
public void append(long j, E e) {
|
||||
int i = this.mSize;
|
||||
if (i != 0 && j <= this.mKeys[i - 1]) {
|
||||
put(j, e);
|
||||
return;
|
||||
}
|
||||
if (this.mGarbage && i >= this.mKeys.length) {
|
||||
gc();
|
||||
}
|
||||
int i2 = this.mSize;
|
||||
if (i2 >= this.mKeys.length) {
|
||||
int idealLongArraySize = ContainerHelpers.idealLongArraySize(i2 + 1);
|
||||
long[] jArr = new long[idealLongArraySize];
|
||||
Object[] objArr = new Object[idealLongArraySize];
|
||||
long[] jArr2 = this.mKeys;
|
||||
System.arraycopy(jArr2, 0, jArr, 0, jArr2.length);
|
||||
Object[] objArr2 = this.mValues;
|
||||
System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
|
||||
this.mKeys = jArr;
|
||||
this.mValues = objArr;
|
||||
}
|
||||
this.mKeys[i2] = j;
|
||||
this.mValues[i2] = e;
|
||||
this.mSize = i2 + 1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (size() <= 0) {
|
||||
return "{}";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(this.mSize * 28);
|
||||
sb.append('{');
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(keyAt(i));
|
||||
sb.append('=');
|
||||
E valueAt = valueAt(i);
|
||||
if (valueAt != this) {
|
||||
sb.append(valueAt);
|
||||
} else {
|
||||
sb.append("(this Map)");
|
||||
}
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
241
02-Easy5/E5/sources/androidx/collection/LruCache.java
Normal file
241
02-Easy5/E5/sources/androidx/collection/LruCache.java
Normal file
@ -0,0 +1,241 @@
|
||||
package androidx.collection;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LruCache<K, V> {
|
||||
private int createCount;
|
||||
private int evictionCount;
|
||||
private int hitCount;
|
||||
private final LinkedHashMap<K, V> map;
|
||||
private int maxSize;
|
||||
private int missCount;
|
||||
private int putCount;
|
||||
private int size;
|
||||
|
||||
protected V create(K k) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void entryRemoved(boolean z, K k, V v, V v2) {
|
||||
}
|
||||
|
||||
protected int sizeOf(K k, V v) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public LruCache(int i) {
|
||||
if (i <= 0) {
|
||||
throw new IllegalArgumentException("maxSize <= 0");
|
||||
}
|
||||
this.maxSize = i;
|
||||
this.map = new LinkedHashMap<>(0, 0.75f, true);
|
||||
}
|
||||
|
||||
public void resize(int i) {
|
||||
if (i <= 0) {
|
||||
throw new IllegalArgumentException("maxSize <= 0");
|
||||
}
|
||||
synchronized (this) {
|
||||
this.maxSize = i;
|
||||
}
|
||||
trimToSize(i);
|
||||
}
|
||||
|
||||
public final V get(K k) {
|
||||
V v;
|
||||
if (k == null) {
|
||||
throw new NullPointerException("key == null");
|
||||
}
|
||||
synchronized (this) {
|
||||
V v2 = this.map.get(k);
|
||||
if (v2 != null) {
|
||||
this.hitCount++;
|
||||
return v2;
|
||||
}
|
||||
this.missCount++;
|
||||
V create = create(k);
|
||||
if (create == null) {
|
||||
return null;
|
||||
}
|
||||
synchronized (this) {
|
||||
this.createCount++;
|
||||
v = (V) this.map.put(k, create);
|
||||
if (v != null) {
|
||||
this.map.put(k, v);
|
||||
} else {
|
||||
this.size += safeSizeOf(k, create);
|
||||
}
|
||||
}
|
||||
if (v != null) {
|
||||
entryRemoved(false, k, create, v);
|
||||
return v;
|
||||
}
|
||||
trimToSize(this.maxSize);
|
||||
return create;
|
||||
}
|
||||
}
|
||||
|
||||
public final V put(K k, V v) {
|
||||
V put;
|
||||
if (k == null || v == null) {
|
||||
throw new NullPointerException("key == null || value == null");
|
||||
}
|
||||
synchronized (this) {
|
||||
this.putCount++;
|
||||
this.size += safeSizeOf(k, v);
|
||||
put = this.map.put(k, v);
|
||||
if (put != null) {
|
||||
this.size -= safeSizeOf(k, put);
|
||||
}
|
||||
}
|
||||
if (put != null) {
|
||||
entryRemoved(false, k, put, v);
|
||||
}
|
||||
trimToSize(this.maxSize);
|
||||
return put;
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:11:0x0070, code lost:
|
||||
|
||||
throw new java.lang.IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
public void trimToSize(int r5) {
|
||||
/*
|
||||
r4 = this;
|
||||
L0:
|
||||
monitor-enter(r4)
|
||||
int r0 = r4.size // Catch: java.lang.Throwable -> L71
|
||||
if (r0 < 0) goto L52
|
||||
java.util.LinkedHashMap<K, V> r0 = r4.map // Catch: java.lang.Throwable -> L71
|
||||
boolean r0 = r0.isEmpty() // Catch: java.lang.Throwable -> L71
|
||||
if (r0 == 0) goto L11
|
||||
int r0 = r4.size // Catch: java.lang.Throwable -> L71
|
||||
if (r0 != 0) goto L52
|
||||
L11:
|
||||
int r0 = r4.size // Catch: java.lang.Throwable -> L71
|
||||
if (r0 <= r5) goto L50
|
||||
java.util.LinkedHashMap<K, V> r0 = r4.map // Catch: java.lang.Throwable -> L71
|
||||
boolean r0 = r0.isEmpty() // Catch: java.lang.Throwable -> L71
|
||||
if (r0 == 0) goto L1e
|
||||
goto L50
|
||||
L1e:
|
||||
java.util.LinkedHashMap<K, V> r0 = r4.map // Catch: java.lang.Throwable -> L71
|
||||
java.util.Set r0 = r0.entrySet() // Catch: java.lang.Throwable -> L71
|
||||
java.util.Iterator r0 = r0.iterator() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Object r0 = r0.next() // Catch: java.lang.Throwable -> L71
|
||||
java.util.Map$Entry r0 = (java.util.Map.Entry) r0 // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Object r1 = r0.getKey() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Object r0 = r0.getValue() // Catch: java.lang.Throwable -> L71
|
||||
java.util.LinkedHashMap<K, V> r2 = r4.map // Catch: java.lang.Throwable -> L71
|
||||
r2.remove(r1) // Catch: java.lang.Throwable -> L71
|
||||
int r2 = r4.size // Catch: java.lang.Throwable -> L71
|
||||
int r3 = r4.safeSizeOf(r1, r0) // Catch: java.lang.Throwable -> L71
|
||||
int r2 = r2 - r3
|
||||
r4.size = r2 // Catch: java.lang.Throwable -> L71
|
||||
int r2 = r4.evictionCount // Catch: java.lang.Throwable -> L71
|
||||
r3 = 1
|
||||
int r2 = r2 + r3
|
||||
r4.evictionCount = r2 // Catch: java.lang.Throwable -> L71
|
||||
monitor-exit(r4) // Catch: java.lang.Throwable -> L71
|
||||
r2 = 0
|
||||
r4.entryRemoved(r3, r1, r0, r2)
|
||||
goto L0
|
||||
L50:
|
||||
monitor-exit(r4) // Catch: java.lang.Throwable -> L71
|
||||
return
|
||||
L52:
|
||||
java.lang.IllegalStateException r5 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L71
|
||||
java.lang.StringBuilder r0 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L71
|
||||
r0.<init>() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Class r1 = r4.getClass() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.String r1 = r1.getName() // Catch: java.lang.Throwable -> L71
|
||||
r0.append(r1) // Catch: java.lang.Throwable -> L71
|
||||
java.lang.String r1 = ".sizeOf() is reporting inconsistent results!"
|
||||
r0.append(r1) // Catch: java.lang.Throwable -> L71
|
||||
java.lang.String r0 = r0.toString() // Catch: java.lang.Throwable -> L71
|
||||
r5.<init>(r0) // Catch: java.lang.Throwable -> L71
|
||||
throw r5 // Catch: java.lang.Throwable -> L71
|
||||
L71:
|
||||
r5 = move-exception
|
||||
monitor-exit(r4) // Catch: java.lang.Throwable -> L71
|
||||
throw r5
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: androidx.collection.LruCache.trimToSize(int):void");
|
||||
}
|
||||
|
||||
public final V remove(K k) {
|
||||
V remove;
|
||||
if (k == null) {
|
||||
throw new NullPointerException("key == null");
|
||||
}
|
||||
synchronized (this) {
|
||||
remove = this.map.remove(k);
|
||||
if (remove != null) {
|
||||
this.size -= safeSizeOf(k, remove);
|
||||
}
|
||||
}
|
||||
if (remove != null) {
|
||||
entryRemoved(false, k, remove, null);
|
||||
}
|
||||
return remove;
|
||||
}
|
||||
|
||||
private int safeSizeOf(K k, V v) {
|
||||
int sizeOf = sizeOf(k, v);
|
||||
if (sizeOf >= 0) {
|
||||
return sizeOf;
|
||||
}
|
||||
throw new IllegalStateException("Negative size: " + k + "=" + v);
|
||||
}
|
||||
|
||||
public final void evictAll() {
|
||||
trimToSize(-1);
|
||||
}
|
||||
|
||||
public final synchronized int size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public final synchronized int maxSize() {
|
||||
return this.maxSize;
|
||||
}
|
||||
|
||||
public final synchronized int hitCount() {
|
||||
return this.hitCount;
|
||||
}
|
||||
|
||||
public final synchronized int missCount() {
|
||||
return this.missCount;
|
||||
}
|
||||
|
||||
public final synchronized int createCount() {
|
||||
return this.createCount;
|
||||
}
|
||||
|
||||
public final synchronized int putCount() {
|
||||
return this.putCount;
|
||||
}
|
||||
|
||||
public final synchronized int evictionCount() {
|
||||
return this.evictionCount;
|
||||
}
|
||||
|
||||
public final synchronized Map<K, V> snapshot() {
|
||||
return new LinkedHashMap(this.map);
|
||||
}
|
||||
|
||||
public final synchronized String toString() {
|
||||
int i;
|
||||
int i2;
|
||||
i = this.hitCount;
|
||||
i2 = this.missCount + i;
|
||||
return String.format(Locale.US, "LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]", Integer.valueOf(this.maxSize), Integer.valueOf(this.hitCount), Integer.valueOf(this.missCount), Integer.valueOf(i2 != 0 ? (i * 100) / i2 : 0));
|
||||
}
|
||||
}
|
554
02-Easy5/E5/sources/androidx/collection/MapCollections.java
Normal file
554
02-Easy5/E5/sources/androidx/collection/MapCollections.java
Normal file
@ -0,0 +1,554 @@
|
||||
package androidx.collection;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class MapCollections<K, V> {
|
||||
MapCollections<K, V>.EntrySet mEntrySet;
|
||||
MapCollections<K, V>.KeySet mKeySet;
|
||||
MapCollections<K, V>.ValuesCollection mValues;
|
||||
|
||||
protected abstract void colClear();
|
||||
|
||||
protected abstract Object colGetEntry(int i, int i2);
|
||||
|
||||
protected abstract Map<K, V> colGetMap();
|
||||
|
||||
protected abstract int colGetSize();
|
||||
|
||||
protected abstract int colIndexOfKey(Object obj);
|
||||
|
||||
protected abstract int colIndexOfValue(Object obj);
|
||||
|
||||
protected abstract void colPut(K k, V v);
|
||||
|
||||
protected abstract void colRemoveAt(int i);
|
||||
|
||||
protected abstract V colSetValue(int i, V v);
|
||||
|
||||
MapCollections() {
|
||||
}
|
||||
|
||||
final class ArrayIterator<T> implements Iterator<T> {
|
||||
boolean mCanRemove = false;
|
||||
int mIndex;
|
||||
final int mOffset;
|
||||
int mSize;
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public boolean hasNext() {
|
||||
return this.mIndex < this.mSize;
|
||||
}
|
||||
|
||||
ArrayIterator(int i) {
|
||||
this.mOffset = i;
|
||||
this.mSize = MapCollections.this.colGetSize();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public T next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
T t = (T) MapCollections.this.colGetEntry(this.mIndex, this.mOffset);
|
||||
this.mIndex++;
|
||||
this.mCanRemove = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public void remove() {
|
||||
if (!this.mCanRemove) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
int i = this.mIndex - 1;
|
||||
this.mIndex = i;
|
||||
this.mSize--;
|
||||
this.mCanRemove = false;
|
||||
MapCollections.this.colRemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
final class MapIterator implements Iterator<Map.Entry<K, V>>, Map.Entry<K, V> {
|
||||
int mEnd;
|
||||
boolean mEntryValid = false;
|
||||
int mIndex = -1;
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public boolean hasNext() {
|
||||
return this.mIndex < this.mEnd;
|
||||
}
|
||||
|
||||
MapIterator() {
|
||||
this.mEnd = MapCollections.this.colGetSize() - 1;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public Map.Entry<K, V> next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
this.mIndex++;
|
||||
this.mEntryValid = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public void remove() {
|
||||
if (!this.mEntryValid) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
MapCollections.this.colRemoveAt(this.mIndex);
|
||||
this.mIndex--;
|
||||
this.mEnd--;
|
||||
this.mEntryValid = false;
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public K getKey() {
|
||||
if (!this.mEntryValid) {
|
||||
throw new IllegalStateException("This container does not support retaining Map.Entry objects");
|
||||
}
|
||||
return (K) MapCollections.this.colGetEntry(this.mIndex, 0);
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public V getValue() {
|
||||
if (!this.mEntryValid) {
|
||||
throw new IllegalStateException("This container does not support retaining Map.Entry objects");
|
||||
}
|
||||
return (V) MapCollections.this.colGetEntry(this.mIndex, 1);
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public V setValue(V v) {
|
||||
if (!this.mEntryValid) {
|
||||
throw new IllegalStateException("This container does not support retaining Map.Entry objects");
|
||||
}
|
||||
return (V) MapCollections.this.colSetValue(this.mIndex, v);
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public boolean equals(Object obj) {
|
||||
if (!this.mEntryValid) {
|
||||
throw new IllegalStateException("This container does not support retaining Map.Entry objects");
|
||||
}
|
||||
if (!(obj instanceof Map.Entry)) {
|
||||
return false;
|
||||
}
|
||||
Map.Entry entry = (Map.Entry) obj;
|
||||
return ContainerHelpers.equal(entry.getKey(), MapCollections.this.colGetEntry(this.mIndex, 0)) && ContainerHelpers.equal(entry.getValue(), MapCollections.this.colGetEntry(this.mIndex, 1));
|
||||
}
|
||||
|
||||
@Override // java.util.Map.Entry
|
||||
public int hashCode() {
|
||||
if (!this.mEntryValid) {
|
||||
throw new IllegalStateException("This container does not support retaining Map.Entry objects");
|
||||
}
|
||||
Object colGetEntry = MapCollections.this.colGetEntry(this.mIndex, 0);
|
||||
Object colGetEntry2 = MapCollections.this.colGetEntry(this.mIndex, 1);
|
||||
return (colGetEntry == null ? 0 : colGetEntry.hashCode()) ^ (colGetEntry2 != null ? colGetEntry2.hashCode() : 0);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getKey() + "=" + getValue();
|
||||
}
|
||||
}
|
||||
|
||||
final class EntrySet implements Set<Map.Entry<K, V>> {
|
||||
EntrySet() {
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean add(Map.Entry<K, V> entry) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean addAll(Collection<? extends Map.Entry<K, V>> collection) {
|
||||
int colGetSize = MapCollections.this.colGetSize();
|
||||
for (Map.Entry<K, V> entry : collection) {
|
||||
MapCollections.this.colPut(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return colGetSize != MapCollections.this.colGetSize();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public void clear() {
|
||||
MapCollections.this.colClear();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean contains(Object obj) {
|
||||
if (!(obj instanceof Map.Entry)) {
|
||||
return false;
|
||||
}
|
||||
Map.Entry entry = (Map.Entry) obj;
|
||||
int colIndexOfKey = MapCollections.this.colIndexOfKey(entry.getKey());
|
||||
if (colIndexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
return ContainerHelpers.equal(MapCollections.this.colGetEntry(colIndexOfKey, 1), entry.getValue());
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean containsAll(Collection<?> collection) {
|
||||
Iterator<?> it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!contains(it.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean isEmpty() {
|
||||
return MapCollections.this.colGetSize() == 0;
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection, java.lang.Iterable
|
||||
public Iterator<Map.Entry<K, V>> iterator() {
|
||||
return new MapIterator();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean remove(Object obj) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public int size() {
|
||||
return MapCollections.this.colGetSize();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public Object[] toArray() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public <T> T[] toArray(T[] tArr) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean equals(Object obj) {
|
||||
return MapCollections.equalsSetHelper(this, obj);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public int hashCode() {
|
||||
int i = 0;
|
||||
for (int colGetSize = MapCollections.this.colGetSize() - 1; colGetSize >= 0; colGetSize--) {
|
||||
Object colGetEntry = MapCollections.this.colGetEntry(colGetSize, 0);
|
||||
Object colGetEntry2 = MapCollections.this.colGetEntry(colGetSize, 1);
|
||||
i += (colGetEntry == null ? 0 : colGetEntry.hashCode()) ^ (colGetEntry2 == null ? 0 : colGetEntry2.hashCode());
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
final class KeySet implements Set<K> {
|
||||
KeySet() {
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean add(K k) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean addAll(Collection<? extends K> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public void clear() {
|
||||
MapCollections.this.colClear();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean contains(Object obj) {
|
||||
return MapCollections.this.colIndexOfKey(obj) >= 0;
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean containsAll(Collection<?> collection) {
|
||||
return MapCollections.containsAllHelper(MapCollections.this.colGetMap(), collection);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean isEmpty() {
|
||||
return MapCollections.this.colGetSize() == 0;
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection, java.lang.Iterable
|
||||
public Iterator<K> iterator() {
|
||||
return new ArrayIterator(0);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean remove(Object obj) {
|
||||
int colIndexOfKey = MapCollections.this.colIndexOfKey(obj);
|
||||
if (colIndexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
MapCollections.this.colRemoveAt(colIndexOfKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
return MapCollections.removeAllHelper(MapCollections.this.colGetMap(), collection);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
return MapCollections.retainAllHelper(MapCollections.this.colGetMap(), collection);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public int size() {
|
||||
return MapCollections.this.colGetSize();
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public Object[] toArray() {
|
||||
return MapCollections.this.toArrayHelper(0);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public <T> T[] toArray(T[] tArr) {
|
||||
return (T[]) MapCollections.this.toArrayHelper(tArr, 0);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public boolean equals(Object obj) {
|
||||
return MapCollections.equalsSetHelper(this, obj);
|
||||
}
|
||||
|
||||
@Override // java.util.Set, java.util.Collection
|
||||
public int hashCode() {
|
||||
int i = 0;
|
||||
for (int colGetSize = MapCollections.this.colGetSize() - 1; colGetSize >= 0; colGetSize--) {
|
||||
Object colGetEntry = MapCollections.this.colGetEntry(colGetSize, 0);
|
||||
i += colGetEntry == null ? 0 : colGetEntry.hashCode();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
final class ValuesCollection implements Collection<V> {
|
||||
ValuesCollection() {
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean add(V v) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean addAll(Collection<? extends V> collection) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public void clear() {
|
||||
MapCollections.this.colClear();
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean contains(Object obj) {
|
||||
return MapCollections.this.colIndexOfValue(obj) >= 0;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean containsAll(Collection<?> collection) {
|
||||
Iterator<?> it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!contains(it.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean isEmpty() {
|
||||
return MapCollections.this.colGetSize() == 0;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection, java.lang.Iterable
|
||||
public Iterator<V> iterator() {
|
||||
return new ArrayIterator(1);
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean remove(Object obj) {
|
||||
int colIndexOfValue = MapCollections.this.colIndexOfValue(obj);
|
||||
if (colIndexOfValue < 0) {
|
||||
return false;
|
||||
}
|
||||
MapCollections.this.colRemoveAt(colIndexOfValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
int colGetSize = MapCollections.this.colGetSize();
|
||||
int i = 0;
|
||||
boolean z = false;
|
||||
while (i < colGetSize) {
|
||||
if (collection.contains(MapCollections.this.colGetEntry(i, 1))) {
|
||||
MapCollections.this.colRemoveAt(i);
|
||||
i--;
|
||||
colGetSize--;
|
||||
z = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public boolean retainAll(Collection<?> collection) {
|
||||
int colGetSize = MapCollections.this.colGetSize();
|
||||
int i = 0;
|
||||
boolean z = false;
|
||||
while (i < colGetSize) {
|
||||
if (!collection.contains(MapCollections.this.colGetEntry(i, 1))) {
|
||||
MapCollections.this.colRemoveAt(i);
|
||||
i--;
|
||||
colGetSize--;
|
||||
z = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public int size() {
|
||||
return MapCollections.this.colGetSize();
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public Object[] toArray() {
|
||||
return MapCollections.this.toArrayHelper(1);
|
||||
}
|
||||
|
||||
@Override // java.util.Collection
|
||||
public <T> T[] toArray(T[] tArr) {
|
||||
return (T[]) MapCollections.this.toArrayHelper(tArr, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static <K, V> boolean containsAllHelper(Map<K, V> map, Collection<?> collection) {
|
||||
Iterator<?> it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!map.containsKey(it.next())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static <K, V> boolean removeAllHelper(Map<K, V> map, Collection<?> collection) {
|
||||
int size = map.size();
|
||||
Iterator<?> it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
map.remove(it.next());
|
||||
}
|
||||
return size != map.size();
|
||||
}
|
||||
|
||||
public static <K, V> boolean retainAllHelper(Map<K, V> map, Collection<?> collection) {
|
||||
int size = map.size();
|
||||
Iterator<K> it = map.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!collection.contains(it.next())) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return size != map.size();
|
||||
}
|
||||
|
||||
public Object[] toArrayHelper(int i) {
|
||||
int colGetSize = colGetSize();
|
||||
Object[] objArr = new Object[colGetSize];
|
||||
for (int i2 = 0; i2 < colGetSize; i2++) {
|
||||
objArr[i2] = colGetEntry(i2, i);
|
||||
}
|
||||
return objArr;
|
||||
}
|
||||
|
||||
public <T> T[] toArrayHelper(T[] tArr, int i) {
|
||||
int colGetSize = colGetSize();
|
||||
if (tArr.length < colGetSize) {
|
||||
tArr = (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), colGetSize));
|
||||
}
|
||||
for (int i2 = 0; i2 < colGetSize; i2++) {
|
||||
tArr[i2] = colGetEntry(i2, i);
|
||||
}
|
||||
if (tArr.length > colGetSize) {
|
||||
tArr[colGetSize] = null;
|
||||
}
|
||||
return tArr;
|
||||
}
|
||||
|
||||
public static <T> boolean equalsSetHelper(Set<T> set, Object obj) {
|
||||
if (set == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Set) {
|
||||
Set set2 = (Set) obj;
|
||||
try {
|
||||
if (set.size() == set2.size()) {
|
||||
if (set.containsAll(set2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<Map.Entry<K, V>> getEntrySet() {
|
||||
if (this.mEntrySet == null) {
|
||||
this.mEntrySet = new EntrySet();
|
||||
}
|
||||
return this.mEntrySet;
|
||||
}
|
||||
|
||||
public Set<K> getKeySet() {
|
||||
if (this.mKeySet == null) {
|
||||
this.mKeySet = new KeySet();
|
||||
}
|
||||
return this.mKeySet;
|
||||
}
|
||||
|
||||
public Collection<V> getValues() {
|
||||
if (this.mValues == null) {
|
||||
this.mValues = new ValuesCollection();
|
||||
}
|
||||
return this.mValues;
|
||||
}
|
||||
}
|
537
02-Easy5/E5/sources/androidx/collection/SimpleArrayMap.java
Normal file
537
02-Easy5/E5/sources/androidx/collection/SimpleArrayMap.java
Normal file
@ -0,0 +1,537 @@
|
||||
package androidx.collection;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SimpleArrayMap<K, V> {
|
||||
private static final int BASE_SIZE = 4;
|
||||
private static final int CACHE_SIZE = 10;
|
||||
private static final boolean CONCURRENT_MODIFICATION_EXCEPTIONS = true;
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String TAG = "ArrayMap";
|
||||
static Object[] mBaseCache;
|
||||
static int mBaseCacheSize;
|
||||
static Object[] mTwiceBaseCache;
|
||||
static int mTwiceBaseCacheSize;
|
||||
Object[] mArray;
|
||||
int[] mHashes;
|
||||
int mSize;
|
||||
|
||||
public boolean isEmpty() {
|
||||
if (this.mSize <= 0) {
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.mSize;
|
||||
}
|
||||
|
||||
private static int binarySearchHashes(int[] iArr, int i, int i2) {
|
||||
try {
|
||||
return ContainerHelpers.binarySearch(iArr, i, i2);
|
||||
} catch (ArrayIndexOutOfBoundsException unused) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
}
|
||||
|
||||
int indexOf(Object obj, int i) {
|
||||
int i2 = this.mSize;
|
||||
if (i2 == 0) {
|
||||
return -1;
|
||||
}
|
||||
int binarySearchHashes = binarySearchHashes(this.mHashes, i2, i);
|
||||
if (binarySearchHashes < 0 || obj.equals(this.mArray[binarySearchHashes << 1])) {
|
||||
return binarySearchHashes;
|
||||
}
|
||||
int i3 = binarySearchHashes + 1;
|
||||
while (i3 < i2 && this.mHashes[i3] == i) {
|
||||
if (obj.equals(this.mArray[i3 << 1])) {
|
||||
return i3;
|
||||
}
|
||||
i3++;
|
||||
}
|
||||
for (int i4 = binarySearchHashes - 1; i4 >= 0 && this.mHashes[i4] == i; i4--) {
|
||||
if (obj.equals(this.mArray[i4 << 1])) {
|
||||
return i4;
|
||||
}
|
||||
}
|
||||
return ~i3;
|
||||
}
|
||||
|
||||
int indexOfNull() {
|
||||
int i = this.mSize;
|
||||
if (i == 0) {
|
||||
return -1;
|
||||
}
|
||||
int binarySearchHashes = binarySearchHashes(this.mHashes, i, 0);
|
||||
if (binarySearchHashes < 0 || this.mArray[binarySearchHashes << 1] == null) {
|
||||
return binarySearchHashes;
|
||||
}
|
||||
int i2 = binarySearchHashes + 1;
|
||||
while (i2 < i && this.mHashes[i2] == 0) {
|
||||
if (this.mArray[i2 << 1] == null) {
|
||||
return i2;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
for (int i3 = binarySearchHashes - 1; i3 >= 0 && this.mHashes[i3] == 0; i3--) {
|
||||
if (this.mArray[i3 << 1] == null) {
|
||||
return i3;
|
||||
}
|
||||
}
|
||||
return ~i2;
|
||||
}
|
||||
|
||||
private void allocArrays(int i) {
|
||||
if (i == 8) {
|
||||
synchronized (SimpleArrayMap.class) {
|
||||
Object[] objArr = mTwiceBaseCache;
|
||||
if (objArr != null) {
|
||||
this.mArray = objArr;
|
||||
mTwiceBaseCache = (Object[]) objArr[0];
|
||||
this.mHashes = (int[]) objArr[1];
|
||||
objArr[1] = null;
|
||||
objArr[0] = null;
|
||||
mTwiceBaseCacheSize--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (i == 4) {
|
||||
synchronized (SimpleArrayMap.class) {
|
||||
Object[] objArr2 = mBaseCache;
|
||||
if (objArr2 != null) {
|
||||
this.mArray = objArr2;
|
||||
mBaseCache = (Object[]) objArr2[0];
|
||||
this.mHashes = (int[]) objArr2[1];
|
||||
objArr2[1] = null;
|
||||
objArr2[0] = null;
|
||||
mBaseCacheSize--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mHashes = new int[i];
|
||||
this.mArray = new Object[i << 1];
|
||||
}
|
||||
|
||||
private static void freeArrays(int[] iArr, Object[] objArr, int i) {
|
||||
if (iArr.length == 8) {
|
||||
synchronized (SimpleArrayMap.class) {
|
||||
if (mTwiceBaseCacheSize < 10) {
|
||||
objArr[0] = mTwiceBaseCache;
|
||||
objArr[1] = iArr;
|
||||
for (int i2 = (i << 1) - 1; i2 >= 2; i2--) {
|
||||
objArr[i2] = null;
|
||||
}
|
||||
mTwiceBaseCache = objArr;
|
||||
mTwiceBaseCacheSize++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (iArr.length == 4) {
|
||||
synchronized (SimpleArrayMap.class) {
|
||||
if (mBaseCacheSize < 10) {
|
||||
objArr[0] = mBaseCache;
|
||||
objArr[1] = iArr;
|
||||
for (int i3 = (i << 1) - 1; i3 >= 2; i3--) {
|
||||
objArr[i3] = null;
|
||||
}
|
||||
mBaseCache = objArr;
|
||||
mBaseCacheSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleArrayMap() {
|
||||
this.mHashes = ContainerHelpers.EMPTY_INTS;
|
||||
this.mArray = ContainerHelpers.EMPTY_OBJECTS;
|
||||
this.mSize = 0;
|
||||
}
|
||||
|
||||
public SimpleArrayMap(int i) {
|
||||
if (i == 0) {
|
||||
this.mHashes = ContainerHelpers.EMPTY_INTS;
|
||||
this.mArray = ContainerHelpers.EMPTY_OBJECTS;
|
||||
} else {
|
||||
allocArrays(i);
|
||||
}
|
||||
this.mSize = 0;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public SimpleArrayMap(SimpleArrayMap<K, V> simpleArrayMap) {
|
||||
this();
|
||||
if (simpleArrayMap != 0) {
|
||||
putAll(simpleArrayMap);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
int i = this.mSize;
|
||||
if (i > 0) {
|
||||
int[] iArr = this.mHashes;
|
||||
Object[] objArr = this.mArray;
|
||||
this.mHashes = ContainerHelpers.EMPTY_INTS;
|
||||
this.mArray = ContainerHelpers.EMPTY_OBJECTS;
|
||||
this.mSize = 0;
|
||||
freeArrays(iArr, objArr, i);
|
||||
}
|
||||
if (this.mSize > 0) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureCapacity(int i) {
|
||||
int i2 = this.mSize;
|
||||
int[] iArr = this.mHashes;
|
||||
if (iArr.length < i) {
|
||||
Object[] objArr = this.mArray;
|
||||
allocArrays(i);
|
||||
if (this.mSize > 0) {
|
||||
System.arraycopy(iArr, 0, this.mHashes, 0, i2);
|
||||
System.arraycopy(objArr, 0, this.mArray, 0, i2 << 1);
|
||||
}
|
||||
freeArrays(iArr, objArr, i2);
|
||||
}
|
||||
if (this.mSize != i2) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsKey(Object obj) {
|
||||
if (indexOfKey(obj) >= 0) {
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int indexOfKey(Object obj) {
|
||||
return obj == null ? indexOfNull() : indexOf(obj, obj.hashCode());
|
||||
}
|
||||
|
||||
int indexOfValue(Object obj) {
|
||||
int i = this.mSize * 2;
|
||||
Object[] objArr = this.mArray;
|
||||
if (obj == null) {
|
||||
for (int i2 = 1; i2 < i; i2 += 2) {
|
||||
if (objArr[i2] == null) {
|
||||
return i2 >> 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
for (int i3 = 1; i3 < i; i3 += 2) {
|
||||
if (obj.equals(objArr[i3])) {
|
||||
return i3 >> 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean containsValue(Object obj) {
|
||||
if (indexOfValue(obj) >= 0) {
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public V get(Object obj) {
|
||||
return getOrDefault(obj, null);
|
||||
}
|
||||
|
||||
public V getOrDefault(Object obj, V v) {
|
||||
int indexOfKey = indexOfKey(obj);
|
||||
return indexOfKey >= 0 ? (V) this.mArray[(indexOfKey << 1) + 1] : v;
|
||||
}
|
||||
|
||||
public K keyAt(int i) {
|
||||
return (K) this.mArray[i << 1];
|
||||
}
|
||||
|
||||
public V valueAt(int i) {
|
||||
return (V) this.mArray[(i << 1) + 1];
|
||||
}
|
||||
|
||||
public V setValueAt(int i, V v) {
|
||||
int i2 = (i << 1) + 1;
|
||||
Object[] objArr = this.mArray;
|
||||
V v2 = (V) objArr[i2];
|
||||
objArr[i2] = v;
|
||||
return v2;
|
||||
}
|
||||
|
||||
public V put(K k, V v) {
|
||||
int i;
|
||||
int indexOf;
|
||||
int i2 = this.mSize;
|
||||
if (k == null) {
|
||||
indexOf = indexOfNull();
|
||||
i = 0;
|
||||
} else {
|
||||
int hashCode = k.hashCode();
|
||||
i = hashCode;
|
||||
indexOf = indexOf(k, hashCode);
|
||||
}
|
||||
if (indexOf >= 0) {
|
||||
int i3 = (indexOf << 1) + 1;
|
||||
Object[] objArr = this.mArray;
|
||||
V v2 = (V) objArr[i3];
|
||||
objArr[i3] = v;
|
||||
return v2;
|
||||
}
|
||||
int i4 = ~indexOf;
|
||||
int[] iArr = this.mHashes;
|
||||
if (i2 >= iArr.length) {
|
||||
int i5 = 8;
|
||||
if (i2 >= 8) {
|
||||
i5 = (i2 >> 1) + i2;
|
||||
} else if (i2 < 4) {
|
||||
i5 = 4;
|
||||
}
|
||||
Object[] objArr2 = this.mArray;
|
||||
allocArrays(i5);
|
||||
if (i2 != this.mSize) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
int[] iArr2 = this.mHashes;
|
||||
if (iArr2.length > 0) {
|
||||
System.arraycopy(iArr, 0, iArr2, 0, iArr.length);
|
||||
System.arraycopy(objArr2, 0, this.mArray, 0, objArr2.length);
|
||||
}
|
||||
freeArrays(iArr, objArr2, i2);
|
||||
}
|
||||
if (i4 < i2) {
|
||||
int[] iArr3 = this.mHashes;
|
||||
int i6 = i4 + 1;
|
||||
System.arraycopy(iArr3, i4, iArr3, i6, i2 - i4);
|
||||
Object[] objArr3 = this.mArray;
|
||||
System.arraycopy(objArr3, i4 << 1, objArr3, i6 << 1, (this.mSize - i4) << 1);
|
||||
}
|
||||
int i7 = this.mSize;
|
||||
if (i2 == i7) {
|
||||
int[] iArr4 = this.mHashes;
|
||||
if (i4 < iArr4.length) {
|
||||
iArr4[i4] = i;
|
||||
Object[] objArr4 = this.mArray;
|
||||
int i8 = i4 << 1;
|
||||
objArr4[i8] = k;
|
||||
objArr4[i8 + 1] = v;
|
||||
this.mSize = i7 + 1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
|
||||
public void putAll(SimpleArrayMap<? extends K, ? extends V> simpleArrayMap) {
|
||||
int i = simpleArrayMap.mSize;
|
||||
ensureCapacity(this.mSize + i);
|
||||
if (this.mSize != 0) {
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
put(simpleArrayMap.keyAt(i2), simpleArrayMap.valueAt(i2));
|
||||
}
|
||||
} else if (i > 0) {
|
||||
System.arraycopy(simpleArrayMap.mHashes, 0, this.mHashes, 0, i);
|
||||
System.arraycopy(simpleArrayMap.mArray, 0, this.mArray, 0, i << 1);
|
||||
this.mSize = i;
|
||||
}
|
||||
}
|
||||
|
||||
public V putIfAbsent(K k, V v) {
|
||||
V v2 = get(k);
|
||||
return v2 == null ? put(k, v) : v2;
|
||||
}
|
||||
|
||||
public V remove(Object obj) {
|
||||
int indexOfKey = indexOfKey(obj);
|
||||
if (indexOfKey >= 0) {
|
||||
return removeAt(indexOfKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean remove(Object obj, Object obj2) {
|
||||
int indexOfKey = indexOfKey(obj);
|
||||
if (indexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
V valueAt = valueAt(indexOfKey);
|
||||
if (obj2 != valueAt && (obj2 == null || !obj2.equals(valueAt))) {
|
||||
return false;
|
||||
}
|
||||
removeAt(indexOfKey);
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
|
||||
public V removeAt(int i) {
|
||||
Object[] objArr = this.mArray;
|
||||
int i2 = i << 1;
|
||||
V v = (V) objArr[i2 + 1];
|
||||
int i3 = this.mSize;
|
||||
int i4 = 0;
|
||||
if (i3 <= 1) {
|
||||
freeArrays(this.mHashes, objArr, i3);
|
||||
this.mHashes = ContainerHelpers.EMPTY_INTS;
|
||||
this.mArray = ContainerHelpers.EMPTY_OBJECTS;
|
||||
} else {
|
||||
int i5 = i3 - 1;
|
||||
int[] iArr = this.mHashes;
|
||||
if (iArr.length > 8 && i3 < iArr.length / 3) {
|
||||
allocArrays(i3 > 8 ? i3 + (i3 >> 1) : 8);
|
||||
if (i3 != this.mSize) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
if (i > 0) {
|
||||
System.arraycopy(iArr, 0, this.mHashes, 0, i);
|
||||
System.arraycopy(objArr, 0, this.mArray, 0, i2);
|
||||
}
|
||||
if (i < i5) {
|
||||
int i6 = i + 1;
|
||||
int i7 = i5 - i;
|
||||
System.arraycopy(iArr, i6, this.mHashes, i, i7);
|
||||
System.arraycopy(objArr, i6 << 1, this.mArray, i2, i7 << 1);
|
||||
}
|
||||
} else {
|
||||
if (i < i5) {
|
||||
int i8 = i + 1;
|
||||
int i9 = i5 - i;
|
||||
System.arraycopy(iArr, i8, iArr, i, i9);
|
||||
Object[] objArr2 = this.mArray;
|
||||
System.arraycopy(objArr2, i8 << 1, objArr2, i2, i9 << 1);
|
||||
}
|
||||
Object[] objArr3 = this.mArray;
|
||||
int i10 = i5 << 1;
|
||||
objArr3[i10] = null;
|
||||
objArr3[i10 + 1] = null;
|
||||
}
|
||||
i4 = i5;
|
||||
}
|
||||
if (i3 != this.mSize) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
this.mSize = i4;
|
||||
return v;
|
||||
}
|
||||
|
||||
public V replace(K k, V v) {
|
||||
int indexOfKey = indexOfKey(k);
|
||||
if (indexOfKey >= 0) {
|
||||
return setValueAt(indexOfKey, v);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean replace(K k, V v, V v2) {
|
||||
int indexOfKey = indexOfKey(k);
|
||||
if (indexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
V valueAt = valueAt(indexOfKey);
|
||||
if (valueAt != v && (v == null || !v.equals(valueAt))) {
|
||||
return false;
|
||||
}
|
||||
setValueAt(indexOfKey, v2);
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
if (obj instanceof SimpleArrayMap) {
|
||||
SimpleArrayMap simpleArrayMap = (SimpleArrayMap) obj;
|
||||
if (size() != simpleArrayMap.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
try {
|
||||
K keyAt = keyAt(i);
|
||||
V valueAt = valueAt(i);
|
||||
Object obj2 = simpleArrayMap.get(keyAt);
|
||||
if (valueAt == null) {
|
||||
if (obj2 != null || !simpleArrayMap.containsKey(keyAt)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!valueAt.equals(obj2)) {
|
||||
return false;
|
||||
}
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
if (obj instanceof Map) {
|
||||
Map map = (Map) obj;
|
||||
if (size() != map.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i2 = 0; i2 < this.mSize; i2++) {
|
||||
try {
|
||||
K keyAt2 = keyAt(i2);
|
||||
V valueAt2 = valueAt(i2);
|
||||
Object obj3 = map.get(keyAt2);
|
||||
if (valueAt2 == null) {
|
||||
if (obj3 != null || !map.containsKey(keyAt2)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!valueAt2.equals(obj3)) {
|
||||
return false;
|
||||
}
|
||||
} catch (ClassCastException | NullPointerException unused2) {
|
||||
}
|
||||
}
|
||||
return CONCURRENT_MODIFICATION_EXCEPTIONS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int[] iArr = this.mHashes;
|
||||
Object[] objArr = this.mArray;
|
||||
int i = this.mSize;
|
||||
int i2 = 1;
|
||||
int i3 = 0;
|
||||
int i4 = 0;
|
||||
while (i3 < i) {
|
||||
Object obj = objArr[i2];
|
||||
i4 += (obj == null ? 0 : obj.hashCode()) ^ iArr[i3];
|
||||
i3++;
|
||||
i2 += 2;
|
||||
}
|
||||
return i4;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (isEmpty()) {
|
||||
return "{}";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(this.mSize * 28);
|
||||
sb.append('{');
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
K keyAt = keyAt(i);
|
||||
if (keyAt != this) {
|
||||
sb.append(keyAt);
|
||||
} else {
|
||||
sb.append("(this Map)");
|
||||
}
|
||||
sb.append('=');
|
||||
V valueAt = valueAt(i);
|
||||
if (valueAt != this) {
|
||||
sb.append(valueAt);
|
||||
} else {
|
||||
sb.append("(this Map)");
|
||||
}
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
319
02-Easy5/E5/sources/androidx/collection/SparseArrayCompat.java
Normal file
319
02-Easy5/E5/sources/androidx/collection/SparseArrayCompat.java
Normal file
@ -0,0 +1,319 @@
|
||||
package androidx.collection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SparseArrayCompat<E> implements Cloneable {
|
||||
private static final Object DELETED = new Object();
|
||||
private boolean mGarbage;
|
||||
private int[] mKeys;
|
||||
private int mSize;
|
||||
private Object[] mValues;
|
||||
|
||||
public SparseArrayCompat() {
|
||||
this(10);
|
||||
}
|
||||
|
||||
public SparseArrayCompat(int i) {
|
||||
this.mGarbage = false;
|
||||
if (i == 0) {
|
||||
this.mKeys = ContainerHelpers.EMPTY_INTS;
|
||||
this.mValues = ContainerHelpers.EMPTY_OBJECTS;
|
||||
} else {
|
||||
int idealIntArraySize = ContainerHelpers.idealIntArraySize(i);
|
||||
this.mKeys = new int[idealIntArraySize];
|
||||
this.mValues = new Object[idealIntArraySize];
|
||||
}
|
||||
}
|
||||
|
||||
/* renamed from: clone, reason: merged with bridge method [inline-methods] */
|
||||
public SparseArrayCompat<E> m46clone() {
|
||||
try {
|
||||
SparseArrayCompat<E> sparseArrayCompat = (SparseArrayCompat) super.clone();
|
||||
sparseArrayCompat.mKeys = (int[]) this.mKeys.clone();
|
||||
sparseArrayCompat.mValues = (Object[]) this.mValues.clone();
|
||||
return sparseArrayCompat;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public E get(int i) {
|
||||
return get(i, null);
|
||||
}
|
||||
|
||||
public E get(int i, E e) {
|
||||
E e2;
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mKeys, this.mSize, i);
|
||||
return (binarySearch < 0 || (e2 = (E) this.mValues[binarySearch]) == DELETED) ? e : e2;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void delete(int i) {
|
||||
remove(i);
|
||||
}
|
||||
|
||||
public void remove(int i) {
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mKeys, this.mSize, i);
|
||||
if (binarySearch >= 0) {
|
||||
Object[] objArr = this.mValues;
|
||||
Object obj = objArr[binarySearch];
|
||||
Object obj2 = DELETED;
|
||||
if (obj != obj2) {
|
||||
objArr[binarySearch] = obj2;
|
||||
this.mGarbage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(int i, Object obj) {
|
||||
int indexOfKey = indexOfKey(i);
|
||||
if (indexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
E valueAt = valueAt(indexOfKey);
|
||||
if (obj != valueAt && (obj == null || !obj.equals(valueAt))) {
|
||||
return false;
|
||||
}
|
||||
removeAt(indexOfKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeAt(int i) {
|
||||
Object[] objArr = this.mValues;
|
||||
Object obj = objArr[i];
|
||||
Object obj2 = DELETED;
|
||||
if (obj != obj2) {
|
||||
objArr[i] = obj2;
|
||||
this.mGarbage = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAtRange(int i, int i2) {
|
||||
int min = Math.min(this.mSize, i2 + i);
|
||||
while (i < min) {
|
||||
removeAt(i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public E replace(int i, E e) {
|
||||
int indexOfKey = indexOfKey(i);
|
||||
if (indexOfKey < 0) {
|
||||
return null;
|
||||
}
|
||||
Object[] objArr = this.mValues;
|
||||
E e2 = (E) objArr[indexOfKey];
|
||||
objArr[indexOfKey] = e;
|
||||
return e2;
|
||||
}
|
||||
|
||||
public boolean replace(int i, E e, E e2) {
|
||||
int indexOfKey = indexOfKey(i);
|
||||
if (indexOfKey < 0) {
|
||||
return false;
|
||||
}
|
||||
Object obj = this.mValues[indexOfKey];
|
||||
if (obj != e && (e == null || !e.equals(obj))) {
|
||||
return false;
|
||||
}
|
||||
this.mValues[indexOfKey] = e2;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void gc() {
|
||||
int i = this.mSize;
|
||||
int[] iArr = this.mKeys;
|
||||
Object[] objArr = this.mValues;
|
||||
int i2 = 0;
|
||||
for (int i3 = 0; i3 < i; i3++) {
|
||||
Object obj = objArr[i3];
|
||||
if (obj != DELETED) {
|
||||
if (i3 != i2) {
|
||||
iArr[i2] = iArr[i3];
|
||||
objArr[i2] = obj;
|
||||
objArr[i3] = null;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
this.mGarbage = false;
|
||||
this.mSize = i2;
|
||||
}
|
||||
|
||||
public void put(int i, E e) {
|
||||
int binarySearch = ContainerHelpers.binarySearch(this.mKeys, this.mSize, i);
|
||||
if (binarySearch >= 0) {
|
||||
this.mValues[binarySearch] = e;
|
||||
return;
|
||||
}
|
||||
int i2 = ~binarySearch;
|
||||
int i3 = this.mSize;
|
||||
if (i2 < i3) {
|
||||
Object[] objArr = this.mValues;
|
||||
if (objArr[i2] == DELETED) {
|
||||
this.mKeys[i2] = i;
|
||||
objArr[i2] = e;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.mGarbage && i3 >= this.mKeys.length) {
|
||||
gc();
|
||||
i2 = ~ContainerHelpers.binarySearch(this.mKeys, this.mSize, i);
|
||||
}
|
||||
int i4 = this.mSize;
|
||||
if (i4 >= this.mKeys.length) {
|
||||
int idealIntArraySize = ContainerHelpers.idealIntArraySize(i4 + 1);
|
||||
int[] iArr = new int[idealIntArraySize];
|
||||
Object[] objArr2 = new Object[idealIntArraySize];
|
||||
int[] iArr2 = this.mKeys;
|
||||
System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
|
||||
Object[] objArr3 = this.mValues;
|
||||
System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
|
||||
this.mKeys = iArr;
|
||||
this.mValues = objArr2;
|
||||
}
|
||||
int i5 = this.mSize;
|
||||
if (i5 - i2 != 0) {
|
||||
int[] iArr3 = this.mKeys;
|
||||
int i6 = i2 + 1;
|
||||
System.arraycopy(iArr3, i2, iArr3, i6, i5 - i2);
|
||||
Object[] objArr4 = this.mValues;
|
||||
System.arraycopy(objArr4, i2, objArr4, i6, this.mSize - i2);
|
||||
}
|
||||
this.mKeys[i2] = i;
|
||||
this.mValues[i2] = e;
|
||||
this.mSize++;
|
||||
}
|
||||
|
||||
public void putAll(SparseArrayCompat<? extends E> sparseArrayCompat) {
|
||||
int size = sparseArrayCompat.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
put(sparseArrayCompat.keyAt(i), sparseArrayCompat.valueAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
public E putIfAbsent(int i, E e) {
|
||||
E e2 = get(i);
|
||||
if (e2 == null) {
|
||||
put(i, e);
|
||||
}
|
||||
return e2;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return this.mSize;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
public int keyAt(int i) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return this.mKeys[i];
|
||||
}
|
||||
|
||||
public E valueAt(int i) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return (E) this.mValues[i];
|
||||
}
|
||||
|
||||
public void setValueAt(int i, E e) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
this.mValues[i] = e;
|
||||
}
|
||||
|
||||
public int indexOfKey(int i) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
return ContainerHelpers.binarySearch(this.mKeys, this.mSize, i);
|
||||
}
|
||||
|
||||
public int indexOfValue(E e) {
|
||||
if (this.mGarbage) {
|
||||
gc();
|
||||
}
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
if (this.mValues[i] == e) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean containsKey(int i) {
|
||||
return indexOfKey(i) >= 0;
|
||||
}
|
||||
|
||||
public boolean containsValue(E e) {
|
||||
return indexOfValue(e) >= 0;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
int i = this.mSize;
|
||||
Object[] objArr = this.mValues;
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
objArr[i2] = null;
|
||||
}
|
||||
this.mSize = 0;
|
||||
this.mGarbage = false;
|
||||
}
|
||||
|
||||
public void append(int i, E e) {
|
||||
int i2 = this.mSize;
|
||||
if (i2 != 0 && i <= this.mKeys[i2 - 1]) {
|
||||
put(i, e);
|
||||
return;
|
||||
}
|
||||
if (this.mGarbage && i2 >= this.mKeys.length) {
|
||||
gc();
|
||||
}
|
||||
int i3 = this.mSize;
|
||||
if (i3 >= this.mKeys.length) {
|
||||
int idealIntArraySize = ContainerHelpers.idealIntArraySize(i3 + 1);
|
||||
int[] iArr = new int[idealIntArraySize];
|
||||
Object[] objArr = new Object[idealIntArraySize];
|
||||
int[] iArr2 = this.mKeys;
|
||||
System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
|
||||
Object[] objArr2 = this.mValues;
|
||||
System.arraycopy(objArr2, 0, objArr, 0, objArr2.length);
|
||||
this.mKeys = iArr;
|
||||
this.mValues = objArr;
|
||||
}
|
||||
this.mKeys[i3] = i;
|
||||
this.mValues[i3] = e;
|
||||
this.mSize = i3 + 1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (size() <= 0) {
|
||||
return "{}";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(this.mSize * 28);
|
||||
sb.append('{');
|
||||
for (int i = 0; i < this.mSize; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(keyAt(i));
|
||||
sb.append('=');
|
||||
E valueAt = valueAt(i);
|
||||
if (valueAt != this) {
|
||||
sb.append(valueAt);
|
||||
} else {
|
||||
sb.append("(this Map)");
|
||||
}
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user