mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-24 16:12:29 -06:00
505 lines
16 KiB
Java
505 lines
16 KiB
Java
package androidx.collection;
|
|
|
|
import androidx.collection.internal.ContainerHelpersKt;
|
|
import java.lang.reflect.Array;
|
|
import java.util.AbstractSet;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.NoSuchElementException;
|
|
import java.util.Set;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ArrayMap<K, V> extends SimpleArrayMap<K, V> implements Map<K, V> {
|
|
ArrayMap<K, V>.EntrySet mEntrySet;
|
|
ArrayMap<K, V>.KeySet mKeySet;
|
|
ArrayMap<K, V>.ValueCollection mValues;
|
|
|
|
public ArrayMap() {
|
|
}
|
|
|
|
public ArrayMap(int i) {
|
|
super(i);
|
|
}
|
|
|
|
public ArrayMap(SimpleArrayMap simpleArrayMap) {
|
|
super(simpleArrayMap);
|
|
}
|
|
|
|
public boolean containsAll(Collection<?> collection) {
|
|
Iterator<?> it = collection.iterator();
|
|
while (it.hasNext()) {
|
|
if (!containsKey(it.next())) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // androidx.collection.SimpleArrayMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
return super.containsKey(obj);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // androidx.collection.SimpleArrayMap, java.util.Map
|
|
public boolean containsValue(Object obj) {
|
|
return super.containsValue(obj);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // androidx.collection.SimpleArrayMap, java.util.Map
|
|
public V get(Object obj) {
|
|
return (V) super.get(obj);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // androidx.collection.SimpleArrayMap, java.util.Map
|
|
public V remove(Object obj) {
|
|
return (V) super.remove(obj);
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public void putAll(Map<? extends K, ? extends V> map) {
|
|
ensureCapacity(getSize() + map.size());
|
|
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
|
put(entry.getKey(), entry.getValue());
|
|
}
|
|
}
|
|
|
|
public boolean removeAll(Collection<?> collection) {
|
|
int size = getSize();
|
|
Iterator<?> it = collection.iterator();
|
|
while (it.hasNext()) {
|
|
remove(it.next());
|
|
}
|
|
return size != getSize();
|
|
}
|
|
|
|
public boolean retainAll(Collection<?> collection) {
|
|
int size = getSize();
|
|
for (int size2 = getSize() - 1; size2 >= 0; size2--) {
|
|
if (!collection.contains(keyAt(size2))) {
|
|
removeAt(size2);
|
|
}
|
|
}
|
|
return size != getSize();
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public Set<Map.Entry<K, V>> entrySet() {
|
|
ArrayMap<K, V>.EntrySet entrySet = this.mEntrySet;
|
|
if (entrySet != null) {
|
|
return entrySet;
|
|
}
|
|
ArrayMap<K, V>.EntrySet entrySet2 = new EntrySet();
|
|
this.mEntrySet = entrySet2;
|
|
return entrySet2;
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public Set<K> keySet() {
|
|
ArrayMap<K, V>.KeySet keySet = this.mKeySet;
|
|
if (keySet != null) {
|
|
return keySet;
|
|
}
|
|
ArrayMap<K, V>.KeySet keySet2 = new KeySet();
|
|
this.mKeySet = keySet2;
|
|
return keySet2;
|
|
}
|
|
|
|
@Override // java.util.Map
|
|
public Collection<V> values() {
|
|
ArrayMap<K, V>.ValueCollection valueCollection = this.mValues;
|
|
if (valueCollection != null) {
|
|
return valueCollection;
|
|
}
|
|
ArrayMap<K, V>.ValueCollection valueCollection2 = new ValueCollection();
|
|
this.mValues = valueCollection2;
|
|
return valueCollection2;
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
final class EntrySet extends AbstractSet<Map.Entry<K, V>> {
|
|
EntrySet() {
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<Map.Entry<K, V>> iterator() {
|
|
return new MapIterator();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public int size() {
|
|
return ArrayMap.this.getSize();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
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() {
|
|
ArrayMap.this.clear();
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public boolean contains(Object obj) {
|
|
return ArrayMap.this.containsKey(obj);
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public boolean containsAll(Collection<?> collection) {
|
|
return ArrayMap.this.containsAll(collection);
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public boolean isEmpty() {
|
|
return ArrayMap.this.isEmpty();
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection, java.lang.Iterable
|
|
public Iterator<K> iterator() {
|
|
return new KeyIterator();
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public boolean remove(Object obj) {
|
|
int indexOfKey = ArrayMap.this.indexOfKey(obj);
|
|
if (indexOfKey < 0) {
|
|
return false;
|
|
}
|
|
ArrayMap.this.removeAt(indexOfKey);
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public boolean removeAll(Collection<?> collection) {
|
|
return ArrayMap.this.removeAll(collection);
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public boolean retainAll(Collection<?> collection) {
|
|
return ArrayMap.this.retainAll(collection);
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public int size() {
|
|
return ArrayMap.this.getSize();
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public Object[] toArray() {
|
|
int size = ArrayMap.this.getSize();
|
|
Object[] objArr = new Object[size];
|
|
for (int i = 0; i < size; i++) {
|
|
objArr[i] = ArrayMap.this.keyAt(i);
|
|
}
|
|
return objArr;
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public <T> T[] toArray(T[] tArr) {
|
|
int size = size();
|
|
if (tArr.length < size) {
|
|
tArr = (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), size));
|
|
}
|
|
for (int i = 0; i < size; i++) {
|
|
tArr[i] = ArrayMap.this.keyAt(i);
|
|
}
|
|
if (tArr.length > size) {
|
|
tArr[size] = null;
|
|
}
|
|
return tArr;
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public boolean equals(Object obj) {
|
|
return ArrayMap.equalsSetHelper(this, obj);
|
|
}
|
|
|
|
@Override // java.util.Set, java.util.Collection
|
|
public int hashCode() {
|
|
int i = 0;
|
|
for (int size = ArrayMap.this.getSize() - 1; size >= 0; size--) {
|
|
K keyAt = ArrayMap.this.keyAt(size);
|
|
i += keyAt == null ? 0 : keyAt.hashCode();
|
|
}
|
|
return i;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
final class ValueCollection implements Collection<V> {
|
|
ValueCollection() {
|
|
}
|
|
|
|
@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() {
|
|
ArrayMap.this.clear();
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public boolean contains(Object obj) {
|
|
return ArrayMap.this.__restricted$indexOfValue(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 ArrayMap.this.isEmpty();
|
|
}
|
|
|
|
@Override // java.util.Collection, java.lang.Iterable
|
|
public Iterator<V> iterator() {
|
|
return new ValueIterator();
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public boolean remove(Object obj) {
|
|
int __restricted$indexOfValue = ArrayMap.this.__restricted$indexOfValue(obj);
|
|
if (__restricted$indexOfValue < 0) {
|
|
return false;
|
|
}
|
|
ArrayMap.this.removeAt(__restricted$indexOfValue);
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public boolean removeAll(Collection<?> collection) {
|
|
int size = ArrayMap.this.getSize();
|
|
int i = 0;
|
|
boolean z = false;
|
|
while (i < size) {
|
|
if (collection.contains(ArrayMap.this.valueAt(i))) {
|
|
ArrayMap.this.removeAt(i);
|
|
i--;
|
|
size--;
|
|
z = true;
|
|
}
|
|
i++;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public boolean retainAll(Collection<?> collection) {
|
|
int size = ArrayMap.this.getSize();
|
|
int i = 0;
|
|
boolean z = false;
|
|
while (i < size) {
|
|
if (!collection.contains(ArrayMap.this.valueAt(i))) {
|
|
ArrayMap.this.removeAt(i);
|
|
i--;
|
|
size--;
|
|
z = true;
|
|
}
|
|
i++;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public int size() {
|
|
return ArrayMap.this.getSize();
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public Object[] toArray() {
|
|
int size = ArrayMap.this.getSize();
|
|
Object[] objArr = new Object[size];
|
|
for (int i = 0; i < size; i++) {
|
|
objArr[i] = ArrayMap.this.valueAt(i);
|
|
}
|
|
return objArr;
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public <T> T[] toArray(T[] tArr) {
|
|
int size = size();
|
|
if (tArr.length < size) {
|
|
tArr = (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), size));
|
|
}
|
|
for (int i = 0; i < size; i++) {
|
|
tArr[i] = ArrayMap.this.valueAt(i);
|
|
}
|
|
if (tArr.length > size) {
|
|
tArr[size] = null;
|
|
}
|
|
return tArr;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
final class KeyIterator extends IndexBasedArrayIterator<K> {
|
|
KeyIterator() {
|
|
super(ArrayMap.this.getSize());
|
|
}
|
|
|
|
@Override // androidx.collection.IndexBasedArrayIterator
|
|
protected K elementAt(int i) {
|
|
return ArrayMap.this.keyAt(i);
|
|
}
|
|
|
|
@Override // androidx.collection.IndexBasedArrayIterator
|
|
protected void removeAt(int i) {
|
|
ArrayMap.this.removeAt(i);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
final class ValueIterator extends IndexBasedArrayIterator<V> {
|
|
ValueIterator() {
|
|
super(ArrayMap.this.getSize());
|
|
}
|
|
|
|
@Override // androidx.collection.IndexBasedArrayIterator
|
|
protected V elementAt(int i) {
|
|
return ArrayMap.this.valueAt(i);
|
|
}
|
|
|
|
@Override // androidx.collection.IndexBasedArrayIterator
|
|
protected void removeAt(int i) {
|
|
ArrayMap.this.removeAt(i);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
final class MapIterator implements Iterator<Map.Entry<K, V>>, Map.Entry<K, V> {
|
|
int mEnd;
|
|
boolean mEntryValid;
|
|
int mIndex = -1;
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.mIndex < this.mEnd;
|
|
}
|
|
|
|
MapIterator() {
|
|
this.mEnd = ArrayMap.this.getSize() - 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();
|
|
}
|
|
ArrayMap.this.removeAt(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 ArrayMap.this.keyAt(this.mIndex);
|
|
}
|
|
|
|
@Override // java.util.Map.Entry
|
|
public V getValue() {
|
|
if (!this.mEntryValid) {
|
|
throw new IllegalStateException("This container does not support retaining Map.Entry objects");
|
|
}
|
|
return ArrayMap.this.valueAt(this.mIndex);
|
|
}
|
|
|
|
@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 ArrayMap.this.setValueAt(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 ContainerHelpersKt.equal(entry.getKey(), ArrayMap.this.keyAt(this.mIndex)) && ContainerHelpersKt.equal(entry.getValue(), ArrayMap.this.valueAt(this.mIndex));
|
|
}
|
|
|
|
@Override // java.util.Map.Entry
|
|
public int hashCode() {
|
|
if (!this.mEntryValid) {
|
|
throw new IllegalStateException("This container does not support retaining Map.Entry objects");
|
|
}
|
|
K keyAt = ArrayMap.this.keyAt(this.mIndex);
|
|
V valueAt = ArrayMap.this.valueAt(this.mIndex);
|
|
return (keyAt == null ? 0 : keyAt.hashCode()) ^ (valueAt != null ? valueAt.hashCode() : 0);
|
|
}
|
|
|
|
public String toString() {
|
|
return getKey() + "=" + getValue();
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|