Rabbit-R1/android (non root)/java/sources/androidx/collection/ArraySet.java

417 lines
18 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.collection;
import androidx.collection.internal.ContainerHelpersKt;
import androidx.exifinterface.media.ExifInterface;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Set;
import kotlin.Metadata;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.ArrayIteratorKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.markers.KMutableCollection;
import kotlin.jvm.internal.markers.KMutableSet;
/* compiled from: ArraySet.jvm.kt */
@Metadata(d1 = {"\u0000Z\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u001f\n\u0002\u0010#\n\u0002\b\u0002\n\u0002\u0010\u001e\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010\u0000\n\u0002\b\u0005\n\u0002\u0010\u0015\n\u0002\b\u0007\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\r\n\u0002\u0010)\n\u0002\b\n\n\u0002\u0010\u000e\n\u0002\b\u0003\u0018\u0000*\u0004\b\u0000\u0010\u00012\b\u0012\u0004\u0012\u0002H\u00010\u00022\b\u0012\u0004\u0012\u0002H\u00010\u0003:\u0001?B\u0019\b\u0016\u0012\u0010\u0010\u0004\u001a\f\u0012\u0006\b\u0001\u0012\u00028\u0000\u0018\u00010\u0000¢\u0006\u0002\u0010\u0005B\u0017\b\u0016\u0012\u000e\u0010\u0004\u001a\n\u0012\u0004\u0012\u00028\u0000\u0018\u00010\u0006¢\u0006\u0002\u0010\u0007B\u0019\b\u0016\u0012\u0010\u0010\b\u001a\f\u0012\u0006\b\u0001\u0012\u00028\u0000\u0018\u00010\\u0006\u0002\u0010\nB\u0011\b\u0007\u0012\b\b\u0002\u0010\u000b\u001a\u00020\\u0006\u0002\u0010\rJ\u0015\u0010\u001f\u001a\u00020 2\u0006\u0010!\u001a\u00028\u0000H\u0016¢\u0006\u0002\u0010\"J\u0016\u0010#\u001a\u00020$2\u000e\u0010\b\u001a\n\u0012\u0006\b\u0001\u0012\u00028\u00000\u0000J\u0016\u0010#\u001a\u00020 2\f\u0010%\u001a\b\u0012\u0004\u0012\u00028\u00000\u0006H\u0016J\b\u0010&\u001a\u00020$H\u0016J\u0016\u0010'\u001a\u00020 2\u0006\u0010!\u001a\u00028\u0000H\u0096\u0002¢\u0006\u0002\u0010\"J\u0016\u0010(\u001a\u00020 2\f\u0010%\u001a\b\u0012\u0004\u0012\u00028\u00000\u0006H\u0016J\u000e\u0010)\u001a\u00020$2\u0006\u0010*\u001a\u00020\fJ\u0013\u0010+\u001a\u00020 2\b\u0010,\u001a\u0004\u0018\u00010\u0012H\u0096\u0002J\b\u0010-\u001a\u00020\fH\u0016J\u0010\u0010.\u001a\u00020\f2\b\u0010/\u001a\u0004\u0018\u00010\u0012J\b\u00100\u001a\u00020 H\u0016J\u000f\u00101\u001a\b\u0012\u0004\u0012\u00028\u000002H\u0096\u0002J\u0015\u00103\u001a\u00020 2\u0006\u0010!\u001a\u00028\u0000H\u0016¢\u0006\u0002\u0010\"J\u0016\u00104\u001a\u00020 2\u000e\u0010\b\u001a\n\u0012\u0006\b\u0001\u0012\u00028\u00000\u0000J\u0016\u00104\u001a\u00020 2\f\u0010%\u001a\b\u0012\u0004\u0012\u00028\u00000\u0006H\u0016J\u0013\u00105\u001a\u00028\u00002\u0006\u00106\u001a\u00020\\u0006\u0002\u00107J\u0016\u00108\u001a\u00020 2\f\u0010%\u001a\b\u0012\u0004\u0012\u00028\u00000\u0006H\u0016J\u0013\u00109\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00120\\u0006\u0002\u0010\u0014J%\u00109\u001a\b\u0012\u0004\u0012\u0002H:0\t\"\u0004\b\u0001\u0010:2\f\u0010\b\u001a\b\u0012\u0004\u0012\u0002H:0\\u0006\u0002\u0010;J\b\u0010<\u001a\u00020=H\u0016J\u0013\u0010>\u001a\u00028\u00002\u0006\u00106\u001a\u00020\\u0006\u0002\u00107R\u001a\u0010\u000e\u001a\u00020\fX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\u0010\"\u0004\b\u0011\u0010\rR$\u0010\b\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00120\tX\u0080\u000e¢\u0006\u0010\n\u0002\u0010\u0016\u001a\u0004\b\u0013\u0010\u0014\"\u0004\b\u0015\u0010\nR\u001a\u0010\u0017\u001a\u00020\u0018X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0019\u0010\u001a\"\u0004\b\u001b\u0010\u001cR\u0014\u0010\u001d\u001a\u00020\f8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u001e\u0010\u0010¨\u0006@"}, d2 = {"Landroidx/collection/ArraySet;", ExifInterface.LONGITUDE_EAST, "", "", "set", "(Landroidx/collection/ArraySet;)V", "", "(Ljava/util/Collection;)V", "array", "", "([Ljava/lang/Object;)V", "capacity", "", "(I)V", "_size", "get_size$collection", "()I", "set_size$collection", "", "getArray$collection", "()[Ljava/lang/Object;", "setArray$collection", "[Ljava/lang/Object;", "hashes", "", "getHashes$collection", "()[I", "setHashes$collection", "([I)V", "size", "getSize", "add", "", "element", "(Ljava/lang/Object;)Z", "addAll", "", "elements", "clear", "contains", "containsAll", "ensureCapacity", "minimumCapacity", "equals", "other", "hashCode", "indexOf", "key", "isEmpty", "iterator", "", "remove", "removeAll", "removeAt", "index", "(I)Ljava/lang/Object;", "retainAll", "toArray", ExifInterface.GPS_DIRECTION_TRUE, "([Ljava/lang/Object;)[Ljava/lang/Object;", "toString", "", "valueAt", "ElementIterator", "collection"}, k
/* loaded from: classes.dex */
public final class ArraySet<E> implements Collection<E>, Set<E>, KMutableCollection, KMutableSet {
private int _size;
private Object[] array;
private int[] hashes;
public ArraySet() {
this(0, 1, null);
}
/* renamed from: getArray$collection, reason: from getter */
public final Object[] getArray() {
return this.array;
}
/* renamed from: getHashes$collection, reason: from getter */
public final int[] getHashes() {
return this.hashes;
}
/* renamed from: getSize, reason: from getter */
public int get_size() {
return this._size;
}
public final int get_size$collection() {
return this._size;
}
public final void setArray$collection(Object[] objArr) {
Intrinsics.checkNotNullParameter(objArr, "<set-?>");
this.array = objArr;
}
public final void setHashes$collection(int[] iArr) {
Intrinsics.checkNotNullParameter(iArr, "<set-?>");
this.hashes = iArr;
}
public final void set_size$collection(int i) {
this._size = i;
}
public ArraySet(int i) {
this.hashes = ContainerHelpersKt.EMPTY_INTS;
this.array = ContainerHelpersKt.EMPTY_OBJECTS;
if (i > 0) {
ArraySetKt.allocArrays(this, i);
}
}
@Override // java.util.Collection, java.util.Set
public final /* bridge */ int size() {
return get_size();
}
public /* synthetic */ ArraySet(int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this((i2 & 1) != 0 ? 0 : i);
}
public ArraySet(ArraySet<? extends E> arraySet) {
this(0);
if (arraySet != null) {
addAll((ArraySet) arraySet);
}
}
public ArraySet(Collection<? extends E> collection) {
this(0);
if (collection != null) {
addAll(collection);
}
}
/* JADX WARN: Multi-variable type inference failed */
public ArraySet(E[] eArr) {
this(0);
if (eArr != null) {
Iterator it = ArrayIteratorKt.iterator(eArr);
while (it.hasNext()) {
add(it.next());
}
}
}
@Override // java.util.Collection, java.util.Set
public final Object[] toArray() {
return ArraysKt.copyOfRange(this.array, 0, this._size);
}
@Override // java.util.Collection, java.util.Set
public final <T> T[] toArray(T[] array) {
Intrinsics.checkNotNullParameter(array, "array");
T[] result = (T[]) ArraySetJvmUtil.resizeForToArray(array, this._size);
ArraysKt.copyInto(this.array, result, 0, 0, this._size);
Intrinsics.checkNotNullExpressionValue(result, "result");
return result;
}
@Override // java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<E> iterator() {
return new ElementIterator();
}
/* compiled from: ArraySet.jvm.kt */
@Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\b\u0082\u0004\u0018\u00002\b\u0012\u0004\u0012\u00028\u00000\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0015\u0010\u0003\u001a\u00028\u00002\u0006\u0010\u0004\u001a\u00020\u0005H\u0014¢\u0006\u0002\u0010\u0006J\u0010\u0010\u0007\u001a\u00020\b2\u0006\u0010\u0004\u001a\u00020\u0005H\u0014¨\u0006\t"}, d2 = {"Landroidx/collection/ArraySet$ElementIterator;", "Landroidx/collection/IndexBasedArrayIterator;", "(Landroidx/collection/ArraySet;)V", "elementAt", "index", "", "(I)Ljava/lang/Object;", "removeAt", "", "collection"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
private final class ElementIterator extends IndexBasedArrayIterator<E> {
public ElementIterator() {
super(ArraySet.this.get_size$collection());
}
@Override // androidx.collection.IndexBasedArrayIterator
protected E elementAt(int index) {
return ArraySet.this.valueAt(index);
}
@Override // androidx.collection.IndexBasedArrayIterator
protected void removeAt(int index) {
ArraySet.this.removeAt(index);
}
}
@Override // java.util.Collection, java.util.Set
public void clear() {
if (get_size$collection() != 0) {
setHashes$collection(ContainerHelpersKt.EMPTY_INTS);
setArray$collection(ContainerHelpersKt.EMPTY_OBJECTS);
set_size$collection(0);
}
if (get_size$collection() != 0) {
throw new ConcurrentModificationException();
}
}
public final void ensureCapacity(int minimumCapacity) {
int i = get_size$collection();
if (getHashes().length < minimumCapacity) {
int[] hashes = getHashes();
Object[] array = getArray();
ArraySetKt.allocArrays(this, minimumCapacity);
if (get_size$collection() > 0) {
ArraysKt.copyInto$default(hashes, getHashes(), 0, 0, get_size$collection(), 6, (Object) null);
ArraysKt.copyInto$default(array, getArray(), 0, 0, get_size$collection(), 6, (Object) null);
}
}
if (get_size$collection() != i) {
throw new ConcurrentModificationException();
}
}
@Override // java.util.Collection, java.util.Set
public boolean contains(Object element) {
return indexOf(element) >= 0;
}
public final int indexOf(Object key) {
return key == null ? ArraySetKt.indexOfNull(this) : ArraySetKt.indexOf(this, key, key.hashCode());
}
public final E valueAt(int index) {
return (E) getArray()[index];
}
@Override // java.util.Collection, java.util.Set
public boolean isEmpty() {
return get_size$collection() <= 0;
}
@Override // java.util.Collection, java.util.Set
public boolean add(E element) {
int i;
int indexOf;
int i2 = get_size$collection();
if (element == null) {
indexOf = ArraySetKt.indexOfNull(this);
i = 0;
} else {
int hashCode = element.hashCode();
i = hashCode;
indexOf = ArraySetKt.indexOf(this, element, hashCode);
}
if (indexOf >= 0) {
return false;
}
int i3 = ~indexOf;
if (i2 >= getHashes().length) {
int i4 = 8;
if (i2 >= 8) {
i4 = (i2 >> 1) + i2;
} else if (i2 < 4) {
i4 = 4;
}
int[] hashes = getHashes();
Object[] array = getArray();
ArraySetKt.allocArrays(this, i4);
if (i2 != get_size$collection()) {
throw new ConcurrentModificationException();
}
if (!(getHashes().length == 0)) {
ArraysKt.copyInto$default(hashes, getHashes(), 0, 0, hashes.length, 6, (Object) null);
ArraysKt.copyInto$default(array, getArray(), 0, 0, array.length, 6, (Object) null);
}
}
if (i3 < i2) {
int i5 = i3 + 1;
ArraysKt.copyInto(getHashes(), getHashes(), i5, i3, i2);
ArraysKt.copyInto(getArray(), getArray(), i5, i3, i2);
}
if (i2 != get_size$collection() || i3 >= getHashes().length) {
throw new ConcurrentModificationException();
}
getHashes()[i3] = i;
getArray()[i3] = element;
set_size$collection(get_size$collection() + 1);
return true;
}
public final void addAll(ArraySet<? extends E> array) {
Intrinsics.checkNotNullParameter(array, "array");
int i = array.get_size$collection();
ensureCapacity(get_size$collection() + i);
if (get_size$collection() != 0) {
for (int i2 = 0; i2 < i; i2++) {
add(array.valueAt(i2));
}
return;
}
if (i > 0) {
ArraysKt.copyInto$default(array.getHashes(), getHashes(), 0, 0, i, 6, (Object) null);
ArraysKt.copyInto$default(array.getArray(), getArray(), 0, 0, i, 6, (Object) null);
if (get_size$collection() != 0) {
throw new ConcurrentModificationException();
}
set_size$collection(i);
}
}
@Override // java.util.Collection, java.util.Set
public boolean remove(Object element) {
int indexOf = indexOf(element);
if (indexOf < 0) {
return false;
}
removeAt(indexOf);
return true;
}
public final E removeAt(int index) {
int i = get_size$collection();
E e = (E) getArray()[index];
if (i <= 1) {
clear();
} else {
int i2 = i - 1;
if (getHashes().length > 8 && get_size$collection() < getHashes().length / 3) {
int i3 = get_size$collection() > 8 ? get_size$collection() + (get_size$collection() >> 1) : 8;
int[] hashes = getHashes();
Object[] array = getArray();
ArraySetKt.allocArrays(this, i3);
if (index > 0) {
ArraysKt.copyInto$default(hashes, getHashes(), 0, 0, index, 6, (Object) null);
ArraysKt.copyInto$default(array, getArray(), 0, 0, index, 6, (Object) null);
}
if (index < i2) {
int i4 = index + 1;
ArraysKt.copyInto(hashes, getHashes(), index, i4, i);
ArraysKt.copyInto(array, getArray(), index, i4, i);
}
} else {
if (index < i2) {
int i5 = index + 1;
ArraysKt.copyInto(getHashes(), getHashes(), index, i5, i);
ArraysKt.copyInto(getArray(), getArray(), index, i5, i);
}
getArray()[i2] = null;
}
if (i != get_size$collection()) {
throw new ConcurrentModificationException();
}
set_size$collection(i2);
}
return e;
}
public final boolean removeAll(ArraySet<? extends E> array) {
Intrinsics.checkNotNullParameter(array, "array");
int i = array.get_size$collection();
int i2 = get_size$collection();
for (int i3 = 0; i3 < i; i3++) {
remove(array.valueAt(i3));
}
return i2 != get_size$collection();
}
@Override // java.util.Collection, java.util.Set
public boolean equals(Object other) {
if (this == other) {
return true;
}
if ((other instanceof Set) && size() == ((Set) other).size()) {
try {
int i = get_size$collection();
for (int i2 = 0; i2 < i; i2++) {
if (((Set) other).contains(valueAt(i2))) {
}
}
return true;
} catch (ClassCastException | NullPointerException unused) {
}
}
return false;
}
@Override // java.util.Collection, java.util.Set
public int hashCode() {
int[] hashes = getHashes();
int i = get_size$collection();
int i2 = 0;
for (int i3 = 0; i3 < i; i3++) {
i2 += hashes[i3];
}
return i2;
}
public String toString() {
if (isEmpty()) {
return "{}";
}
StringBuilder sb = new StringBuilder(get_size$collection() * 14);
sb.append('{');
int i = get_size$collection();
for (int i2 = 0; i2 < i; i2++) {
if (i2 > 0) {
sb.append(", ");
}
E valueAt = valueAt(i2);
if (valueAt != this) {
sb.append(valueAt);
} else {
sb.append("(this Set)");
}
}
sb.append('}');
String sb2 = sb.toString();
Intrinsics.checkNotNullExpressionValue(sb2, "StringBuilder(capacity).…builderAction).toString()");
return sb2;
}
@Override // java.util.Collection, java.util.Set
public boolean containsAll(Collection<? extends Object> elements) {
Intrinsics.checkNotNullParameter(elements, "elements");
Iterator<? extends Object> it = elements.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> elements) {
Intrinsics.checkNotNullParameter(elements, "elements");
ensureCapacity(get_size$collection() + elements.size());
Iterator<? extends E> it = elements.iterator();
boolean z = false;
while (it.hasNext()) {
z |= add(it.next());
}
return z;
}
@Override // java.util.Collection, java.util.Set
public boolean removeAll(Collection<? extends Object> elements) {
Intrinsics.checkNotNullParameter(elements, "elements");
Iterator<? extends Object> it = elements.iterator();
boolean z = false;
while (it.hasNext()) {
z |= remove(it.next());
}
return z;
}
@Override // java.util.Collection, java.util.Set
public boolean retainAll(Collection<? extends Object> elements) {
Intrinsics.checkNotNullParameter(elements, "elements");
boolean z = false;
for (int i = get_size$collection() - 1; -1 < i; i--) {
if (!CollectionsKt.contains(elements, getArray()[i])) {
removeAt(i);
z = true;
}
}
return z;
}
}