mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
746 lines
34 KiB
Java
746 lines
34 KiB
Java
package kotlin.collections;
|
|
|
|
import androidx.exifinterface.media.ExifInterface;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.NoSuchElementException;
|
|
import kotlin.Metadata;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function2;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.ranges.RangesKt;
|
|
|
|
/* compiled from: ArrayDeque.kt */
|
|
@Metadata(d1 = {"\u0000L\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u001e\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u0000\n\u0002\b\u0007\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0011\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u001b\b\u0007\u0018\u0000 P*\u0004\b\u0000\u0010\u00012\b\u0012\u0004\u0012\u0002H\u00010\u0002:\u0001PB\u000f\b\u0016\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005B\u0007\b\u0016¢\u0006\u0002\u0010\u0006B\u0015\b\u0016\u0012\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u00028\u00000\b¢\u0006\u0002\u0010\tJ\u0015\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00028\u0000H\u0016¢\u0006\u0002\u0010\u0016J\u001d\u0010\u0013\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00028\u0000H\u0016¢\u0006\u0002\u0010\u0019J\u001e\u0010\u001a\u001a\u00020\u00142\u0006\u0010\u0018\u001a\u00020\u00042\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u00028\u00000\bH\u0016J\u0016\u0010\u001a\u001a\u00020\u00142\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u00028\u00000\bH\u0016J\u0013\u0010\u001b\u001a\u00020\u00172\u0006\u0010\u0015\u001a\u00028\u0000¢\u0006\u0002\u0010\u001cJ\u0013\u0010\u001d\u001a\u00020\u00172\u0006\u0010\u0015\u001a\u00028\u0000¢\u0006\u0002\u0010\u001cJ\b\u0010\u001e\u001a\u00020\u0017H\u0016J\u0016\u0010\u001f\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00028\u0000H\u0096\u0002¢\u0006\u0002\u0010\u0016J\u001e\u0010 \u001a\u00020\u00172\u0006\u0010!\u001a\u00020\u00042\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u00028\u00000\bH\u0002J\u0010\u0010\"\u001a\u00020\u00172\u0006\u0010#\u001a\u00020\u0004H\u0002J\u0010\u0010$\u001a\u00020\u00042\u0006\u0010\u0018\u001a\u00020\u0004H\u0002J\u0010\u0010%\u001a\u00020\u00172\u0006\u0010&\u001a\u00020\u0004H\u0002J\u001d\u0010'\u001a\u00020\u00142\u0012\u0010(\u001a\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00020\u00140)H\u0082\bJ\u000b\u0010*\u001a\u00028\u0000¢\u0006\u0002\u0010+J\r\u0010,\u001a\u0004\u0018\u00018\u0000¢\u0006\u0002\u0010+J\u0016\u0010-\u001a\u00028\u00002\u0006\u0010\u0018\u001a\u00020\u0004H\u0096\u0002¢\u0006\u0002\u0010.J\u0010\u0010/\u001a\u00020\u00042\u0006\u0010\u0018\u001a\u00020\u0004H\u0002J\u0015\u00100\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00028\u0000H\u0016¢\u0006\u0002\u00101J\u0016\u00102\u001a\u00028\u00002\u0006\u0010!\u001a\u00020\u0004H\u0083\b¢\u0006\u0002\u0010.J\u0011\u0010!\u001a\u00020\u00042\u0006\u0010\u0018\u001a\u00020\u0004H\u0083\bJM\u00103\u001a\u00020\u00172>\u00104\u001a:\u0012\u0013\u0012\u00110\u0004¢\u0006\f\b6\u0012\b\b7\u0012\u0004\b\b(\u000e\u0012\u001b\u0012\u0019\u0012\u0006\u0012\u0004\u0018\u00010\f0\u000b¢\u0006\f\b6\u0012\b\b7\u0012\u0004\b\b(\u0007\u0012\u0004\u0012\u00020\u001705H\u0000¢\u0006\u0002\b8J\b\u00109\u001a\u00020\u0014H\u0016J\u000b\u0010:\u001a\u00028\u0000¢\u0006\u0002\u0010+J\u0015\u0010;\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00028\u0000H\u0016¢\u0006\u0002\u00101J\r\u0010<\u001a\u0004\u0018\u00018\u0000¢\u0006\u0002\u0010+J\u0010\u0010=\u001a\u00020\u00042\u0006\u0010\u0018\u001a\u00020\u0004H\u0002J\u0010\u0010>\u001a\u00020\u00042\u0006\u0010\u0018\u001a\u00020\u0004H\u0002J\u0015\u0010?\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00028\u0000H\u0016¢\u0006\u0002\u0010\u0016J\u0016\u0010@\u001a\u00020\u00142\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u00028\u00000\bH\u0016J\u0015\u0010A\u001a\u00028\u00002\u0006\u0010\u0018\u001a\u00020\u0004H\u0016¢\u0006\u0002\u0010.J\u000b\u0010B\u001a\u00028\u0000¢\u0006\u0002\u0010+J\r\u0010C\u001a\u0004\u0018\u00018\u0000¢\u0006\u0002\u0010+J\u000b\u0010D\u001a\u00028\u0000¢\u0006\u0002\u0010+J\r\u0010E\u001a\u0004\u0018\u00018\u0000¢\u0006\u0002\u0010+J\u0016\u0010F\u001a\u00020\u00142\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u00028\u00000\bH\u0016J\u001e\u0010G\u001a\u00028\u00002\u0006\u0010\u0018\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00028\u0000H\u0096\u0002¢\u0006\u0002\u0010HJ\u0017\u0010I\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\f0\u000bH\u0000¢\u0006\u0004\bJ\u0010KJ)\u0010I\u001a\b\u0012\u0004\u0012\u0002HL0\u000b\"\u0004\b\u0001\u0010L2\f\u0010M\u001a\b\u0012\u0004\u0012\u0002HL0\u000bH\u0000¢\u0006\u0004\bJ\u0010NJ\u0015\u0010O\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\f0\u000bH\u0016¢\u0006\u0002\u0010KJ'\u0010O\u001a\b\u0012\u0004\u0012\u0002HL0\u000b\"\u0004\b\u0001\u0010L2\f\u0010M\u001a\b\u0012\u0004\u0012\u0002HL0\u000bH\u0016¢\u0006\u0002\u0010NR\u0018\u0010\n\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\f0\u000bX\u0082\u000e¢\u0006\u0004\n\u0002\u0010\rR\u000e\u0010\u000e\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\u0010\u001a\u00020\u00042\u0006\u0010\u000f\u001a\u00020\u0004@RX\u0096\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u0011\u0010\u0012¨\u0006Q"}, d2 = {"Lkotlin/collections/ArrayDeque;", ExifInterface.LONGITUDE_EAST, "Lkotlin/collections/AbstractMutableList;", "initialCapacity", "", "(I)V", "()V", "elements", "", "(Ljava/util/Collection;)V", "elementData", "", "", "[Ljava/lang/Object;", "head", "<set-?>", "size", "getSize", "()I", "add", "", "element", "(Ljava/lang/Object;)Z", "", "index", "(ILjava/lang/Object;)V", "addAll", "addFirst", "(Ljava/lang/Object;)V", "addLast", "clear", "contains", "copyCollectionElements", "internalIndex", "copyElements", "newCapacity", "decremented", "ensureCapacity", "minCapacity", "filterInPlace", "predicate", "Lkotlin/Function1;", "first", "()Ljava/lang/Object;", "firstOrNull", "get", "(I)Ljava/lang/Object;", "incremented", "indexOf", "(Ljava/lang/Object;)I", "internalGet", "internalStructure", "structure", "Lkotlin/Function2;", "Lkotlin/ParameterName;", "name", "internalStructure$kotlin_stdlib", "isEmpty", "last", "lastIndexOf", "lastOrNull", "negativeMod", "positiveMod", "remove", "removeAll", "removeAt", "removeFirst", "removeFirstOrNull", "removeLast", "removeLastOrNull", "retainAll", "set", "(ILjava/lang/Object;)Ljava/lang/Object;", "testToArray", "testToArray$kotlin_stdlib", "()[Ljava/lang/Object;", ExifInterface.GPS_DIRECTION_TRUE, "array", "([Ljava/lang/Object;)[Ljava/lang/Object;", "toArray", "Companion", "kotlin-stdlib"}, k = 1, mv = {1, 9, 0}, xi = 48)
|
|
/* loaded from: classes3.dex */
|
|
public final class ArrayDeque<E> extends AbstractMutableList<E> {
|
|
private static final int defaultMinCapacity = 10;
|
|
private Object[] elementData;
|
|
private int head;
|
|
private int size;
|
|
private static final Object[] emptyElementData = new Object[0];
|
|
|
|
@Override // kotlin.collections.AbstractMutableList
|
|
public int getSize() {
|
|
return this.size;
|
|
}
|
|
|
|
public ArrayDeque(int i) {
|
|
Object[] objArr;
|
|
if (i == 0) {
|
|
objArr = emptyElementData;
|
|
} else if (i > 0) {
|
|
objArr = new Object[i];
|
|
} else {
|
|
throw new IllegalArgumentException("Illegal Capacity: " + i);
|
|
}
|
|
this.elementData = objArr;
|
|
}
|
|
|
|
public ArrayDeque() {
|
|
this.elementData = emptyElementData;
|
|
}
|
|
|
|
public ArrayDeque(Collection<? extends E> elements) {
|
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
|
Object[] array = elements.toArray(new Object[0]);
|
|
this.elementData = array;
|
|
this.size = array.length;
|
|
if (array.length == 0) {
|
|
this.elementData = emptyElementData;
|
|
}
|
|
}
|
|
|
|
private final void ensureCapacity(int minCapacity) {
|
|
if (minCapacity < 0) {
|
|
throw new IllegalStateException("Deque is too big.");
|
|
}
|
|
Object[] objArr = this.elementData;
|
|
if (minCapacity <= objArr.length) {
|
|
return;
|
|
}
|
|
if (objArr == emptyElementData) {
|
|
this.elementData = new Object[RangesKt.coerceAtLeast(minCapacity, 10)];
|
|
} else {
|
|
copyElements(AbstractList.INSTANCE.newCapacity$kotlin_stdlib(this.elementData.length, minCapacity));
|
|
}
|
|
}
|
|
|
|
private final void copyElements(int newCapacity) {
|
|
Object[] objArr = new Object[newCapacity];
|
|
Object[] objArr2 = this.elementData;
|
|
ArraysKt.copyInto(objArr2, objArr, 0, this.head, objArr2.length);
|
|
Object[] objArr3 = this.elementData;
|
|
int length = objArr3.length;
|
|
int i = this.head;
|
|
ArraysKt.copyInto(objArr3, objArr, length - i, 0, i);
|
|
this.head = 0;
|
|
this.elementData = objArr;
|
|
}
|
|
|
|
private final E internalGet(int internalIndex) {
|
|
return (E) this.elementData[internalIndex];
|
|
}
|
|
|
|
private final int positiveMod(int index) {
|
|
Object[] objArr = this.elementData;
|
|
return index >= objArr.length ? index - objArr.length : index;
|
|
}
|
|
|
|
private final int negativeMod(int index) {
|
|
return index < 0 ? index + this.elementData.length : index;
|
|
}
|
|
|
|
private final int internalIndex(int index) {
|
|
return positiveMod(this.head + index);
|
|
}
|
|
|
|
private final int incremented(int index) {
|
|
if (index == ArraysKt.getLastIndex(this.elementData)) {
|
|
return 0;
|
|
}
|
|
return index + 1;
|
|
}
|
|
|
|
private final int decremented(int index) {
|
|
return index == 0 ? ArraysKt.getLastIndex(this.elementData) : index - 1;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean isEmpty() {
|
|
return size() == 0;
|
|
}
|
|
|
|
public final E first() {
|
|
if (isEmpty()) {
|
|
throw new NoSuchElementException("ArrayDeque is empty.");
|
|
}
|
|
return (E) this.elementData[this.head];
|
|
}
|
|
|
|
public final E firstOrNull() {
|
|
if (isEmpty()) {
|
|
return null;
|
|
}
|
|
return (E) this.elementData[this.head];
|
|
}
|
|
|
|
public final E last() {
|
|
if (isEmpty()) {
|
|
throw new NoSuchElementException("ArrayDeque is empty.");
|
|
}
|
|
return (E) this.elementData[positiveMod(this.head + CollectionsKt.getLastIndex(this))];
|
|
}
|
|
|
|
public final E lastOrNull() {
|
|
if (isEmpty()) {
|
|
return null;
|
|
}
|
|
return (E) this.elementData[positiveMod(this.head + CollectionsKt.getLastIndex(this))];
|
|
}
|
|
|
|
public final void addFirst(E element) {
|
|
ensureCapacity(size() + 1);
|
|
int decremented = decremented(this.head);
|
|
this.head = decremented;
|
|
this.elementData[decremented] = element;
|
|
this.size = size() + 1;
|
|
}
|
|
|
|
public final void addLast(E element) {
|
|
ensureCapacity(size() + 1);
|
|
this.elementData[positiveMod(this.head + size())] = element;
|
|
this.size = size() + 1;
|
|
}
|
|
|
|
public final E removeFirst() {
|
|
if (isEmpty()) {
|
|
throw new NoSuchElementException("ArrayDeque is empty.");
|
|
}
|
|
Object[] objArr = this.elementData;
|
|
int i = this.head;
|
|
E e = (E) objArr[i];
|
|
objArr[i] = null;
|
|
this.head = incremented(i);
|
|
this.size = size() - 1;
|
|
return e;
|
|
}
|
|
|
|
public final E removeFirstOrNull() {
|
|
if (isEmpty()) {
|
|
return null;
|
|
}
|
|
return removeFirst();
|
|
}
|
|
|
|
public final E removeLast() {
|
|
if (isEmpty()) {
|
|
throw new NoSuchElementException("ArrayDeque is empty.");
|
|
}
|
|
int positiveMod = positiveMod(this.head + CollectionsKt.getLastIndex(this));
|
|
Object[] objArr = this.elementData;
|
|
E e = (E) objArr[positiveMod];
|
|
objArr[positiveMod] = null;
|
|
this.size = size() - 1;
|
|
return e;
|
|
}
|
|
|
|
public final E removeLastOrNull() {
|
|
if (isEmpty()) {
|
|
return null;
|
|
}
|
|
return removeLast();
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean add(E element) {
|
|
addLast(element);
|
|
return true;
|
|
}
|
|
|
|
@Override // kotlin.collections.AbstractMutableList, java.util.AbstractList, java.util.List
|
|
public void add(int index, E element) {
|
|
AbstractList.INSTANCE.checkPositionIndex$kotlin_stdlib(index, size());
|
|
if (index == size()) {
|
|
addLast(element);
|
|
return;
|
|
}
|
|
if (index == 0) {
|
|
addFirst(element);
|
|
return;
|
|
}
|
|
ensureCapacity(size() + 1);
|
|
int positiveMod = positiveMod(this.head + index);
|
|
if (index < ((size() + 1) >> 1)) {
|
|
int decremented = decremented(positiveMod);
|
|
int decremented2 = decremented(this.head);
|
|
int i = this.head;
|
|
if (decremented >= i) {
|
|
Object[] objArr = this.elementData;
|
|
objArr[decremented2] = objArr[i];
|
|
ArraysKt.copyInto(objArr, objArr, i, i + 1, decremented + 1);
|
|
} else {
|
|
Object[] objArr2 = this.elementData;
|
|
ArraysKt.copyInto(objArr2, objArr2, i - 1, i, objArr2.length);
|
|
Object[] objArr3 = this.elementData;
|
|
objArr3[objArr3.length - 1] = objArr3[0];
|
|
ArraysKt.copyInto(objArr3, objArr3, 0, 1, decremented + 1);
|
|
}
|
|
this.elementData[decremented] = element;
|
|
this.head = decremented2;
|
|
} else {
|
|
int positiveMod2 = positiveMod(this.head + size());
|
|
if (positiveMod < positiveMod2) {
|
|
Object[] objArr4 = this.elementData;
|
|
ArraysKt.copyInto(objArr4, objArr4, positiveMod + 1, positiveMod, positiveMod2);
|
|
} else {
|
|
Object[] objArr5 = this.elementData;
|
|
ArraysKt.copyInto(objArr5, objArr5, 1, 0, positiveMod2);
|
|
Object[] objArr6 = this.elementData;
|
|
objArr6[0] = objArr6[objArr6.length - 1];
|
|
ArraysKt.copyInto(objArr6, objArr6, positiveMod + 1, positiveMod, objArr6.length - 1);
|
|
}
|
|
this.elementData[positiveMod] = element;
|
|
}
|
|
this.size = size() + 1;
|
|
}
|
|
|
|
private final void copyCollectionElements(int internalIndex, Collection<? extends E> elements) {
|
|
Iterator<? extends E> it = elements.iterator();
|
|
int length = this.elementData.length;
|
|
while (internalIndex < length && it.hasNext()) {
|
|
this.elementData[internalIndex] = it.next();
|
|
internalIndex++;
|
|
}
|
|
int i = this.head;
|
|
for (int i2 = 0; i2 < i && it.hasNext(); i2++) {
|
|
this.elementData[i2] = it.next();
|
|
}
|
|
this.size = size() + elements.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean addAll(Collection<? extends E> elements) {
|
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
|
if (elements.isEmpty()) {
|
|
return false;
|
|
}
|
|
ensureCapacity(size() + elements.size());
|
|
copyCollectionElements(positiveMod(this.head + size()), elements);
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public boolean addAll(int index, Collection<? extends E> elements) {
|
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
|
AbstractList.INSTANCE.checkPositionIndex$kotlin_stdlib(index, size());
|
|
if (elements.isEmpty()) {
|
|
return false;
|
|
}
|
|
if (index == size()) {
|
|
return addAll(elements);
|
|
}
|
|
ensureCapacity(size() + elements.size());
|
|
int positiveMod = positiveMod(this.head + size());
|
|
int positiveMod2 = positiveMod(this.head + index);
|
|
int size = elements.size();
|
|
if (index < ((size() + 1) >> 1)) {
|
|
int i = this.head;
|
|
int i2 = i - size;
|
|
if (positiveMod2 < i) {
|
|
Object[] objArr = this.elementData;
|
|
ArraysKt.copyInto(objArr, objArr, i2, i, objArr.length);
|
|
if (size >= positiveMod2) {
|
|
Object[] objArr2 = this.elementData;
|
|
ArraysKt.copyInto(objArr2, objArr2, objArr2.length - size, 0, positiveMod2);
|
|
} else {
|
|
Object[] objArr3 = this.elementData;
|
|
ArraysKt.copyInto(objArr3, objArr3, objArr3.length - size, 0, size);
|
|
Object[] objArr4 = this.elementData;
|
|
ArraysKt.copyInto(objArr4, objArr4, 0, size, positiveMod2);
|
|
}
|
|
} else if (i2 >= 0) {
|
|
Object[] objArr5 = this.elementData;
|
|
ArraysKt.copyInto(objArr5, objArr5, i2, i, positiveMod2);
|
|
} else {
|
|
Object[] objArr6 = this.elementData;
|
|
i2 += objArr6.length;
|
|
int i3 = positiveMod2 - i;
|
|
int length = objArr6.length - i2;
|
|
if (length >= i3) {
|
|
ArraysKt.copyInto(objArr6, objArr6, i2, i, positiveMod2);
|
|
} else {
|
|
ArraysKt.copyInto(objArr6, objArr6, i2, i, i + length);
|
|
Object[] objArr7 = this.elementData;
|
|
ArraysKt.copyInto(objArr7, objArr7, 0, this.head + length, positiveMod2);
|
|
}
|
|
}
|
|
this.head = i2;
|
|
copyCollectionElements(negativeMod(positiveMod2 - size), elements);
|
|
} else {
|
|
int i4 = positiveMod2 + size;
|
|
if (positiveMod2 < positiveMod) {
|
|
int i5 = size + positiveMod;
|
|
Object[] objArr8 = this.elementData;
|
|
if (i5 <= objArr8.length) {
|
|
ArraysKt.copyInto(objArr8, objArr8, i4, positiveMod2, positiveMod);
|
|
} else if (i4 >= objArr8.length) {
|
|
ArraysKt.copyInto(objArr8, objArr8, i4 - objArr8.length, positiveMod2, positiveMod);
|
|
} else {
|
|
int length2 = positiveMod - (i5 - objArr8.length);
|
|
ArraysKt.copyInto(objArr8, objArr8, 0, length2, positiveMod);
|
|
Object[] objArr9 = this.elementData;
|
|
ArraysKt.copyInto(objArr9, objArr9, i4, positiveMod2, length2);
|
|
}
|
|
} else {
|
|
Object[] objArr10 = this.elementData;
|
|
ArraysKt.copyInto(objArr10, objArr10, size, 0, positiveMod);
|
|
Object[] objArr11 = this.elementData;
|
|
if (i4 >= objArr11.length) {
|
|
ArraysKt.copyInto(objArr11, objArr11, i4 - objArr11.length, positiveMod2, objArr11.length);
|
|
} else {
|
|
ArraysKt.copyInto(objArr11, objArr11, 0, objArr11.length - size, objArr11.length);
|
|
Object[] objArr12 = this.elementData;
|
|
ArraysKt.copyInto(objArr12, objArr12, i4, positiveMod2, objArr12.length - size);
|
|
}
|
|
}
|
|
copyCollectionElements(positiveMod2, elements);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public E get(int index) {
|
|
AbstractList.INSTANCE.checkElementIndex$kotlin_stdlib(index, size());
|
|
return (E) this.elementData[positiveMod(this.head + index)];
|
|
}
|
|
|
|
@Override // kotlin.collections.AbstractMutableList, java.util.AbstractList, java.util.List
|
|
public E set(int index, E element) {
|
|
AbstractList.INSTANCE.checkElementIndex$kotlin_stdlib(index, size());
|
|
int positiveMod = positiveMod(this.head + index);
|
|
Object[] objArr = this.elementData;
|
|
E e = (E) objArr[positiveMod];
|
|
objArr[positiveMod] = element;
|
|
return e;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean contains(Object element) {
|
|
return indexOf(element) != -1;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public int indexOf(Object element) {
|
|
int i;
|
|
int positiveMod = positiveMod(this.head + size());
|
|
int i2 = this.head;
|
|
if (i2 < positiveMod) {
|
|
while (i2 < positiveMod) {
|
|
if (Intrinsics.areEqual(element, this.elementData[i2])) {
|
|
i = this.head;
|
|
} else {
|
|
i2++;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
if (i2 < positiveMod) {
|
|
return -1;
|
|
}
|
|
int length = this.elementData.length;
|
|
while (true) {
|
|
if (i2 >= length) {
|
|
for (int i3 = 0; i3 < positiveMod; i3++) {
|
|
if (Intrinsics.areEqual(element, this.elementData[i3])) {
|
|
i2 = i3 + this.elementData.length;
|
|
i = this.head;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
if (Intrinsics.areEqual(element, this.elementData[i2])) {
|
|
i = this.head;
|
|
break;
|
|
}
|
|
i2++;
|
|
}
|
|
return i2 - i;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public int lastIndexOf(Object element) {
|
|
int lastIndex;
|
|
int i;
|
|
int positiveMod = positiveMod(this.head + size());
|
|
int i2 = this.head;
|
|
if (i2 < positiveMod) {
|
|
lastIndex = positiveMod - 1;
|
|
if (i2 <= lastIndex) {
|
|
while (!Intrinsics.areEqual(element, this.elementData[lastIndex])) {
|
|
if (lastIndex != i2) {
|
|
lastIndex--;
|
|
}
|
|
}
|
|
i = this.head;
|
|
return lastIndex - i;
|
|
}
|
|
return -1;
|
|
}
|
|
if (i2 > positiveMod) {
|
|
int i3 = positiveMod - 1;
|
|
while (true) {
|
|
if (-1 < i3) {
|
|
if (Intrinsics.areEqual(element, this.elementData[i3])) {
|
|
lastIndex = i3 + this.elementData.length;
|
|
i = this.head;
|
|
break;
|
|
}
|
|
i3--;
|
|
} else {
|
|
lastIndex = ArraysKt.getLastIndex(this.elementData);
|
|
int i4 = this.head;
|
|
if (i4 <= lastIndex) {
|
|
while (!Intrinsics.areEqual(element, this.elementData[lastIndex])) {
|
|
if (lastIndex != i4) {
|
|
lastIndex--;
|
|
}
|
|
}
|
|
i = this.head;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean remove(Object element) {
|
|
int indexOf = indexOf(element);
|
|
if (indexOf == -1) {
|
|
return false;
|
|
}
|
|
remove(indexOf);
|
|
return true;
|
|
}
|
|
|
|
@Override // kotlin.collections.AbstractMutableList
|
|
public E removeAt(int index) {
|
|
AbstractList.INSTANCE.checkElementIndex$kotlin_stdlib(index, size());
|
|
ArrayDeque<E> arrayDeque = this;
|
|
if (index == CollectionsKt.getLastIndex(arrayDeque)) {
|
|
return removeLast();
|
|
}
|
|
if (index == 0) {
|
|
return removeFirst();
|
|
}
|
|
int positiveMod = positiveMod(this.head + index);
|
|
E e = (E) this.elementData[positiveMod];
|
|
if (index < (size() >> 1)) {
|
|
int i = this.head;
|
|
if (positiveMod >= i) {
|
|
Object[] objArr = this.elementData;
|
|
ArraysKt.copyInto(objArr, objArr, i + 1, i, positiveMod);
|
|
} else {
|
|
Object[] objArr2 = this.elementData;
|
|
ArraysKt.copyInto(objArr2, objArr2, 1, 0, positiveMod);
|
|
Object[] objArr3 = this.elementData;
|
|
objArr3[0] = objArr3[objArr3.length - 1];
|
|
int i2 = this.head;
|
|
ArraysKt.copyInto(objArr3, objArr3, i2 + 1, i2, objArr3.length - 1);
|
|
}
|
|
Object[] objArr4 = this.elementData;
|
|
int i3 = this.head;
|
|
objArr4[i3] = null;
|
|
this.head = incremented(i3);
|
|
} else {
|
|
int positiveMod2 = positiveMod(this.head + CollectionsKt.getLastIndex(arrayDeque));
|
|
if (positiveMod <= positiveMod2) {
|
|
Object[] objArr5 = this.elementData;
|
|
ArraysKt.copyInto(objArr5, objArr5, positiveMod, positiveMod + 1, positiveMod2 + 1);
|
|
} else {
|
|
Object[] objArr6 = this.elementData;
|
|
ArraysKt.copyInto(objArr6, objArr6, positiveMod, positiveMod + 1, objArr6.length);
|
|
Object[] objArr7 = this.elementData;
|
|
objArr7[objArr7.length - 1] = objArr7[0];
|
|
ArraysKt.copyInto(objArr7, objArr7, 0, 1, positiveMod2 + 1);
|
|
}
|
|
this.elementData[positiveMod2] = null;
|
|
}
|
|
this.size = size() - 1;
|
|
return e;
|
|
}
|
|
|
|
private final boolean filterInPlace(Function1<? super E, Boolean> predicate) {
|
|
int positiveMod;
|
|
boolean z = false;
|
|
z = false;
|
|
z = false;
|
|
if (!isEmpty() && this.elementData.length != 0) {
|
|
int positiveMod2 = positiveMod(this.head + size());
|
|
int i = this.head;
|
|
if (i < positiveMod2) {
|
|
positiveMod = i;
|
|
while (i < positiveMod2) {
|
|
Object obj = this.elementData[i];
|
|
if (predicate.invoke(obj).booleanValue()) {
|
|
this.elementData[positiveMod] = obj;
|
|
positiveMod++;
|
|
} else {
|
|
z = true;
|
|
}
|
|
i++;
|
|
}
|
|
ArraysKt.fill(this.elementData, (Object) null, positiveMod, positiveMod2);
|
|
} else {
|
|
int length = this.elementData.length;
|
|
boolean z2 = false;
|
|
int i2 = i;
|
|
while (i < length) {
|
|
Object[] objArr = this.elementData;
|
|
Object obj2 = objArr[i];
|
|
objArr[i] = null;
|
|
if (predicate.invoke(obj2).booleanValue()) {
|
|
this.elementData[i2] = obj2;
|
|
i2++;
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
i++;
|
|
}
|
|
positiveMod = positiveMod(i2);
|
|
for (int i3 = 0; i3 < positiveMod2; i3++) {
|
|
Object[] objArr2 = this.elementData;
|
|
Object obj3 = objArr2[i3];
|
|
objArr2[i3] = null;
|
|
if (predicate.invoke(obj3).booleanValue()) {
|
|
this.elementData[positiveMod] = obj3;
|
|
positiveMod = incremented(positiveMod);
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
}
|
|
z = z2;
|
|
}
|
|
if (z) {
|
|
this.size = negativeMod(positiveMod - this.head);
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public void clear() {
|
|
int positiveMod = positiveMod(this.head + size());
|
|
int i = this.head;
|
|
if (i < positiveMod) {
|
|
ArraysKt.fill(this.elementData, (Object) null, i, positiveMod);
|
|
} else if (!isEmpty()) {
|
|
Object[] objArr = this.elementData;
|
|
ArraysKt.fill(objArr, (Object) null, this.head, objArr.length);
|
|
ArraysKt.fill(this.elementData, (Object) null, 0, positiveMod);
|
|
}
|
|
this.head = 0;
|
|
this.size = 0;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public <T> T[] toArray(T[] array) {
|
|
Intrinsics.checkNotNullParameter(array, "array");
|
|
if (array.length < size()) {
|
|
array = (T[]) ArraysKt.arrayOfNulls(array, size());
|
|
}
|
|
int positiveMod = positiveMod(this.head + size());
|
|
int i = this.head;
|
|
if (i < positiveMod) {
|
|
ArraysKt.copyInto$default(this.elementData, array, 0, i, positiveMod, 2, (Object) null);
|
|
} else if (!isEmpty()) {
|
|
Object[] objArr = this.elementData;
|
|
ArraysKt.copyInto(objArr, array, 0, this.head, objArr.length);
|
|
Object[] objArr2 = this.elementData;
|
|
ArraysKt.copyInto(objArr2, array, objArr2.length - this.head, 0, positiveMod);
|
|
}
|
|
return (T[]) CollectionsKt.terminateCollectionToArray(size(), array);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public Object[] toArray() {
|
|
return toArray(new Object[size()]);
|
|
}
|
|
|
|
public final <T> T[] testToArray$kotlin_stdlib(T[] array) {
|
|
Intrinsics.checkNotNullParameter(array, "array");
|
|
return (T[]) toArray(array);
|
|
}
|
|
|
|
public final Object[] testToArray$kotlin_stdlib() {
|
|
return toArray();
|
|
}
|
|
|
|
public final void internalStructure$kotlin_stdlib(Function2<? super Integer, ? super Object[], Unit> structure) {
|
|
int i;
|
|
Intrinsics.checkNotNullParameter(structure, "structure");
|
|
structure.invoke(Integer.valueOf((isEmpty() || (i = this.head) < positiveMod(this.head + size())) ? this.head : i - this.elementData.length), toArray());
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean removeAll(Collection<? extends Object> elements) {
|
|
int positiveMod;
|
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
|
boolean z = false;
|
|
z = false;
|
|
z = false;
|
|
if (!isEmpty() && this.elementData.length != 0) {
|
|
int positiveMod2 = positiveMod(this.head + size());
|
|
int i = this.head;
|
|
if (i < positiveMod2) {
|
|
positiveMod = i;
|
|
while (i < positiveMod2) {
|
|
Object obj = this.elementData[i];
|
|
if (!elements.contains(obj)) {
|
|
this.elementData[positiveMod] = obj;
|
|
positiveMod++;
|
|
} else {
|
|
z = true;
|
|
}
|
|
i++;
|
|
}
|
|
ArraysKt.fill(this.elementData, (Object) null, positiveMod, positiveMod2);
|
|
} else {
|
|
int length = this.elementData.length;
|
|
boolean z2 = false;
|
|
int i2 = i;
|
|
while (i < length) {
|
|
Object[] objArr = this.elementData;
|
|
Object obj2 = objArr[i];
|
|
objArr[i] = null;
|
|
if (!elements.contains(obj2)) {
|
|
this.elementData[i2] = obj2;
|
|
i2++;
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
i++;
|
|
}
|
|
positiveMod = positiveMod(i2);
|
|
for (int i3 = 0; i3 < positiveMod2; i3++) {
|
|
Object[] objArr2 = this.elementData;
|
|
Object obj3 = objArr2[i3];
|
|
objArr2[i3] = null;
|
|
if (!elements.contains(obj3)) {
|
|
this.elementData[positiveMod] = obj3;
|
|
positiveMod = incremented(positiveMod);
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
}
|
|
z = z2;
|
|
}
|
|
if (z) {
|
|
this.size = negativeMod(positiveMod - this.head);
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean retainAll(Collection<? extends Object> elements) {
|
|
int positiveMod;
|
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
|
boolean z = false;
|
|
z = false;
|
|
z = false;
|
|
if (!isEmpty() && this.elementData.length != 0) {
|
|
int positiveMod2 = positiveMod(this.head + size());
|
|
int i = this.head;
|
|
if (i < positiveMod2) {
|
|
positiveMod = i;
|
|
while (i < positiveMod2) {
|
|
Object obj = this.elementData[i];
|
|
if (elements.contains(obj)) {
|
|
this.elementData[positiveMod] = obj;
|
|
positiveMod++;
|
|
} else {
|
|
z = true;
|
|
}
|
|
i++;
|
|
}
|
|
ArraysKt.fill(this.elementData, (Object) null, positiveMod, positiveMod2);
|
|
} else {
|
|
int length = this.elementData.length;
|
|
boolean z2 = false;
|
|
int i2 = i;
|
|
while (i < length) {
|
|
Object[] objArr = this.elementData;
|
|
Object obj2 = objArr[i];
|
|
objArr[i] = null;
|
|
if (elements.contains(obj2)) {
|
|
this.elementData[i2] = obj2;
|
|
i2++;
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
i++;
|
|
}
|
|
positiveMod = positiveMod(i2);
|
|
for (int i3 = 0; i3 < positiveMod2; i3++) {
|
|
Object[] objArr2 = this.elementData;
|
|
Object obj3 = objArr2[i3];
|
|
objArr2[i3] = null;
|
|
if (elements.contains(obj3)) {
|
|
this.elementData[positiveMod] = obj3;
|
|
positiveMod = incremented(positiveMod);
|
|
} else {
|
|
z2 = true;
|
|
}
|
|
}
|
|
z = z2;
|
|
}
|
|
if (z) {
|
|
this.size = negativeMod(positiveMod - this.head);
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
}
|