mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-25 00:22:50 -06:00
160 lines
6.6 KiB
Java
160 lines
6.6 KiB
Java
|
package androidx.collection;
|
||
|
|
||
|
import io.sentry.protocol.MetricSummary;
|
||
|
import kotlin.Metadata;
|
||
|
import kotlin.collections.ArraysKt;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
|
||
|
/* compiled from: CircularIntArray.kt */
|
||
|
@Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0015\n\u0002\b\b\n\u0002\u0010\u0002\n\u0002\b\u0007\n\u0002\u0010\u000b\n\u0002\b\u0007\u0018\u00002\u00020\u0001B\u0011\b\u0007\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u000e\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u0003J\u000e\u0010\u0012\u001a\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u0003J\u0006\u0010\u0013\u001a\u00020\u0010J\b\u0010\u0014\u001a\u00020\u0010H\u0002J\u0011\u0010\u0015\u001a\u00020\u00032\u0006\u0010\u0016\u001a\u00020\u0003H\u0086\u0002J\u0006\u0010\u0017\u001a\u00020\u0018J\u0006\u0010\u0019\u001a\u00020\u0003J\u0006\u0010\u001a\u001a\u00020\u0003J\u000e\u0010\u001b\u001a\u00020\u00102\u0006\u0010\u001c\u001a\u00020\u0003J\u000e\u0010\u001d\u001a\u00020\u00102\u0006\u0010\u001c\u001a\u00020\u0003J\u0006\u0010\u001e\u001a\u00020\u0003R\u000e\u0010\u0005\u001a\u00020\u0003X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0011\u0010\b\u001a\u00020\u00038F¢\u0006\u0006\u001a\u0004\b\t\u0010\nR\u000e\u0010\u000b\u001a\u00020\u0003X\u0082\u000e¢\u0006\u0002\n\u0000R\u0011\u0010\f\u001a\u00020\u00038F¢\u0006\u0006\u001a\u0004\b\r\u0010\nR\u000e\u0010\u000e\u001a\u00020\u0003X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u001f"}, d2 = {"Landroidx/collection/CircularIntArray;", "", "minCapacity", "", "(I)V", "capacityBitmask", "elements", "", "first", "getFirst", "()I", "head", "last", "getLast", "tail", "addFirst", "", "element", "addLast", "clear", "doubleCapacity", "get", "index", "isEmpty", "", "popFirst", "popLast", "removeFromEnd", MetricSummary.JsonKeys.COUNT, "removeFromStart", "size", "collection"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class CircularIntArray {
|
||
|
private int capacityBitmask;
|
||
|
private int[] elements;
|
||
|
private int head;
|
||
|
private int tail;
|
||
|
|
||
|
public CircularIntArray() {
|
||
|
this(0, 1, null);
|
||
|
}
|
||
|
|
||
|
public final void clear() {
|
||
|
this.tail = this.head;
|
||
|
}
|
||
|
|
||
|
public final boolean isEmpty() {
|
||
|
return this.head == this.tail;
|
||
|
}
|
||
|
|
||
|
public final int size() {
|
||
|
return this.capacityBitmask & (this.tail - this.head);
|
||
|
}
|
||
|
|
||
|
public CircularIntArray(int i) {
|
||
|
if (i < 1) {
|
||
|
throw new IllegalArgumentException("capacity must be >= 1".toString());
|
||
|
}
|
||
|
if (i > 1073741824) {
|
||
|
throw new IllegalArgumentException("capacity must be <= 2^30".toString());
|
||
|
}
|
||
|
i = Integer.bitCount(i) != 1 ? Integer.highestOneBit(i - 1) << 1 : i;
|
||
|
this.capacityBitmask = i - 1;
|
||
|
this.elements = new int[i];
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ CircularIntArray(int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this((i2 & 1) != 0 ? 8 : i);
|
||
|
}
|
||
|
|
||
|
private final void doubleCapacity() {
|
||
|
int[] iArr = this.elements;
|
||
|
int length = iArr.length;
|
||
|
int i = this.head;
|
||
|
int i2 = length - i;
|
||
|
int i3 = length << 1;
|
||
|
if (i3 < 0) {
|
||
|
throw new RuntimeException("Max array capacity exceeded");
|
||
|
}
|
||
|
int[] iArr2 = new int[i3];
|
||
|
ArraysKt.copyInto(iArr, iArr2, 0, i, length);
|
||
|
ArraysKt.copyInto(this.elements, iArr2, i2, 0, this.head);
|
||
|
this.elements = iArr2;
|
||
|
this.head = 0;
|
||
|
this.tail = length;
|
||
|
this.capacityBitmask = i3 - 1;
|
||
|
}
|
||
|
|
||
|
public final void addFirst(int element) {
|
||
|
int i = (this.head - 1) & this.capacityBitmask;
|
||
|
this.head = i;
|
||
|
this.elements[i] = element;
|
||
|
if (i == this.tail) {
|
||
|
doubleCapacity();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final void addLast(int element) {
|
||
|
int[] iArr = this.elements;
|
||
|
int i = this.tail;
|
||
|
iArr[i] = element;
|
||
|
int i2 = this.capacityBitmask & (i + 1);
|
||
|
this.tail = i2;
|
||
|
if (i2 == this.head) {
|
||
|
doubleCapacity();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final int popFirst() {
|
||
|
int i = this.head;
|
||
|
if (i == this.tail) {
|
||
|
CollectionPlatformUtils collectionPlatformUtils = CollectionPlatformUtils.INSTANCE;
|
||
|
throw new ArrayIndexOutOfBoundsException();
|
||
|
}
|
||
|
int i2 = this.elements[i];
|
||
|
this.head = (i + 1) & this.capacityBitmask;
|
||
|
return i2;
|
||
|
}
|
||
|
|
||
|
public final int popLast() {
|
||
|
int i = this.head;
|
||
|
int i2 = this.tail;
|
||
|
if (i == i2) {
|
||
|
CollectionPlatformUtils collectionPlatformUtils = CollectionPlatformUtils.INSTANCE;
|
||
|
throw new ArrayIndexOutOfBoundsException();
|
||
|
}
|
||
|
int i3 = this.capacityBitmask & (i2 - 1);
|
||
|
int i4 = this.elements[i3];
|
||
|
this.tail = i3;
|
||
|
return i4;
|
||
|
}
|
||
|
|
||
|
public final void removeFromStart(int count) {
|
||
|
if (count <= 0) {
|
||
|
return;
|
||
|
}
|
||
|
if (count > size()) {
|
||
|
CollectionPlatformUtils collectionPlatformUtils = CollectionPlatformUtils.INSTANCE;
|
||
|
throw new ArrayIndexOutOfBoundsException();
|
||
|
}
|
||
|
this.head = this.capacityBitmask & (this.head + count);
|
||
|
}
|
||
|
|
||
|
public final void removeFromEnd(int count) {
|
||
|
if (count <= 0) {
|
||
|
return;
|
||
|
}
|
||
|
if (count > size()) {
|
||
|
CollectionPlatformUtils collectionPlatformUtils = CollectionPlatformUtils.INSTANCE;
|
||
|
throw new ArrayIndexOutOfBoundsException();
|
||
|
}
|
||
|
this.tail = this.capacityBitmask & (this.tail - count);
|
||
|
}
|
||
|
|
||
|
public final int getFirst() {
|
||
|
int i = this.head;
|
||
|
if (i == this.tail) {
|
||
|
CollectionPlatformUtils collectionPlatformUtils = CollectionPlatformUtils.INSTANCE;
|
||
|
throw new ArrayIndexOutOfBoundsException();
|
||
|
}
|
||
|
return this.elements[i];
|
||
|
}
|
||
|
|
||
|
public final int getLast() {
|
||
|
int i = this.head;
|
||
|
int i2 = this.tail;
|
||
|
if (i == i2) {
|
||
|
CollectionPlatformUtils collectionPlatformUtils = CollectionPlatformUtils.INSTANCE;
|
||
|
throw new ArrayIndexOutOfBoundsException();
|
||
|
}
|
||
|
return this.elements[this.capacityBitmask & (i2 - 1)];
|
||
|
}
|
||
|
|
||
|
public final int get(int index) {
|
||
|
if (index < 0 || index >= size()) {
|
||
|
CollectionPlatformUtils collectionPlatformUtils = CollectionPlatformUtils.INSTANCE;
|
||
|
throw new ArrayIndexOutOfBoundsException();
|
||
|
}
|
||
|
return this.elements[this.capacityBitmask & (this.head + index)];
|
||
|
}
|
||
|
}
|