mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-16 02:47:17 +01:00
197 lines
9.1 KiB
Java
197 lines
9.1 KiB
Java
package androidx.compose.runtime.snapshots;
|
|
|
|
import androidx.compose.runtime.internal.StabilityInferred;
|
|
import com.amazon.alexa.ra.core.data.fragments.SmartFragmentContent;
|
|
import com.amazon.clouddrive.extended.model.BulkOperationType;
|
|
import defpackage.a$$ExternalSyntheticOutline0;
|
|
import kotlin.Metadata;
|
|
import kotlin.collections.ArraysKt___ArraysJvmKt;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.TestOnly;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@StabilityInferred(parameters = 0)
|
|
@Metadata(d1 = {"\u0000<\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010\u0016\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0015\n\u0002\b\u0003\n\u0002\u0010\t\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u000e\b\u0001\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u001d\u0010\u0011\u001a\u00060\u0012j\u0002`\u00132\f\b\u0002\u0010\u0014\u001a\u00060\u0012j\u0002`\u0013¢\u0006\u0002\u0010\u0015J\u0017\u0010\u0016\u001a\u00020\u00052\n\u0010\u0004\u001a\u00060\u0012j\u0002`\u0013¢\u0006\u0002\u0010\u0017J\u000e\u0010\u0018\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u0005J\b\u0010\u001b\u001a\u00020\u0019H\u0007J!\u0010\u001c\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u00052\n\u0010\u0004\u001a\u00060\u0012j\u0002`\u0013H\u0007¢\u0006\u0002\u0010\u001dJ\u0010\u0010\u001e\u001a\u00020\u00192\u0006\u0010\r\u001a\u00020\u0005H\u0002J\u0010\u0010\u001f\u001a\u00020\u00192\u0006\u0010\r\u001a\u00020\u0005H\u0002J\u0018\u0010 \u001a\u00020\u00192\u0006\u0010!\u001a\u00020\u00052\u0006\u0010\"\u001a\u00020\u0005H\u0002J\u0010\u0010#\u001a\u00020\u00192\u0006\u0010$\u001a\u00020\u0005H\u0002J\b\u0010%\u001a\u00020\u0005H\u0002J\u0010\u0010&\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u0005H\u0002R\u001e\u0010\u0006\u001a\u00020\u00052\u0006\u0010\u0004\u001a\u00020\u0005@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u0014\u0010\t\u001a\u00060\nj\u0002`\u000bX\u0082\u000e¢\u0006\u0004\n\u0002\u0010\fR\u000e\u0010\r\u001a\u00020\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006'"}, d2 = {"Landroidx/compose/runtime/snapshots/SnapshotDoubleIndexHeap;", "", "<init>", "()V", "value", "", "size", "getSize", "()I", "values", "", "Landroidx/compose/runtime/snapshots/SnapshotIdArray;", "[J", "index", "", "handles", "firstFreeHandle", "lowestOrDefault", "", "Landroidx/compose/runtime/snapshots/SnapshotId;", "default", "(J)J", BulkOperationType.add, "(J)I", BulkOperationType.remove, "", "handle", "validate", "validateHandle", "(IJ)V", "shiftUp", "shiftDown", "swap", "a", "b", "ensure", "atLeast", "allocateHandle", "freeHandle", SmartFragmentContent.RUNTIME}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
@SourceDebugExtension({"SMAP\nSnapshotDoubleIndexHeap.kt\nKotlin\n*S Kotlin\n*F\n+ 1 SnapshotDoubleIndexHeap.kt\nandroidx/compose/runtime/snapshots/SnapshotDoubleIndexHeap\n+ 2 SnapshotId.jvm.kt\nandroidx/compose/runtime/snapshots/SnapshotId_jvmKt\n*L\n1#1,201:1\n55#2:202\n58#2,2:203\n55#2:205\n31#2:206\n55#2:207\n55#2:208\n55#2:209\n55#2:210\n31#2:211\n55#2:212\n31#2:213\n55#2:214\n31#2:215\n55#2:216\n31#2:217\n55#2:218\n55#2,5:219\n58#2,2:224\n62#2:226\n65#2,2:227\n*S KotlinDebug\n*F\n+ 1 SnapshotDoubleIndexHeap.kt\nandroidx/compose/runtime/snapshots/SnapshotDoubleIndexHeap\n*L\n56#1:202\n66#1:203,2\n92#1:205\n92#1:206\n101#1:207\n102#1:208\n108#1:209\n112#1:210\n112#1:211\n132#1:212\n132#1:213\n133#1:214\n133#1:215\n137#1:216\n137#1:217\n153#1:218\n154#1:219,5\n155#1:224,2\n166#1:226\n171#1:227,2\n*E\n"})
|
|
/* loaded from: classes13.dex */
|
|
public final class SnapshotDoubleIndexHeap {
|
|
public static final int $stable = 8;
|
|
private int firstFreeHandle;
|
|
|
|
@NotNull
|
|
private int[] handles;
|
|
private int size;
|
|
|
|
@NotNull
|
|
private long[] values = SnapshotId_jvmKt.snapshotIdArrayWithCapacity(16);
|
|
|
|
@NotNull
|
|
private int[] index = new int[16];
|
|
|
|
public SnapshotDoubleIndexHeap() {
|
|
int[] iArr = new int[16];
|
|
int i = 0;
|
|
while (i < 16) {
|
|
int i2 = i + 1;
|
|
iArr[i] = i2;
|
|
i = i2;
|
|
}
|
|
this.handles = iArr;
|
|
}
|
|
|
|
private final int allocateHandle() {
|
|
int length = this.handles.length;
|
|
if (this.firstFreeHandle >= length) {
|
|
int i = length * 2;
|
|
int[] iArr = new int[i];
|
|
int i2 = 0;
|
|
while (i2 < i) {
|
|
int i3 = i2 + 1;
|
|
iArr[i2] = i3;
|
|
i2 = i3;
|
|
}
|
|
ArraysKt___ArraysJvmKt.copyInto$default(this.handles, iArr, 0, 0, 0, 14, (Object) null);
|
|
this.handles = iArr;
|
|
}
|
|
int i4 = this.firstFreeHandle;
|
|
this.firstFreeHandle = this.handles[i4];
|
|
return i4;
|
|
}
|
|
|
|
private final void ensure(int atLeast) {
|
|
int length = this.values.length;
|
|
if (atLeast <= length) {
|
|
return;
|
|
}
|
|
int i = length * 2;
|
|
long[] snapshotIdArrayWithCapacity = SnapshotId_jvmKt.snapshotIdArrayWithCapacity(i);
|
|
int[] iArr = new int[i];
|
|
ArraysKt___ArraysJvmKt.copyInto$default(this.values, snapshotIdArrayWithCapacity, 0, 0, 0, 12, (Object) null);
|
|
ArraysKt___ArraysJvmKt.copyInto$default(this.index, iArr, 0, 0, 0, 14, (Object) null);
|
|
this.values = snapshotIdArrayWithCapacity;
|
|
this.index = iArr;
|
|
}
|
|
|
|
private final void freeHandle(int handle) {
|
|
this.handles[handle] = this.firstFreeHandle;
|
|
this.firstFreeHandle = handle;
|
|
}
|
|
|
|
public static /* synthetic */ long lowestOrDefault$default(SnapshotDoubleIndexHeap snapshotDoubleIndexHeap, long j, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = 0;
|
|
}
|
|
return snapshotDoubleIndexHeap.lowestOrDefault(j);
|
|
}
|
|
|
|
private final void shiftDown(int index) {
|
|
long[] jArr = this.values;
|
|
int i = this.size >> 1;
|
|
while (index < i) {
|
|
int i2 = (index + 1) << 1;
|
|
int i3 = i2 - 1;
|
|
if (i2 >= this.size || Intrinsics.compare(jArr[i2], jArr[i3]) >= 0) {
|
|
if (Intrinsics.compare(jArr[i3], jArr[index]) >= 0) {
|
|
return;
|
|
}
|
|
swap(i3, index);
|
|
index = i3;
|
|
} else {
|
|
if (Intrinsics.compare(jArr[i2], jArr[index]) >= 0) {
|
|
return;
|
|
}
|
|
swap(i2, index);
|
|
index = i2;
|
|
}
|
|
}
|
|
}
|
|
|
|
private final void shiftUp(int index) {
|
|
long[] jArr = this.values;
|
|
long j = jArr[index];
|
|
while (index > 0) {
|
|
int i = ((index + 1) >> 1) - 1;
|
|
if (Intrinsics.compare(jArr[i], j) <= 0) {
|
|
return;
|
|
}
|
|
swap(i, index);
|
|
index = i;
|
|
}
|
|
}
|
|
|
|
private final void swap(int a2, int b) {
|
|
long[] jArr = this.values;
|
|
int[] iArr = this.index;
|
|
int[] iArr2 = this.handles;
|
|
long j = jArr[a2];
|
|
jArr[a2] = jArr[b];
|
|
jArr[b] = j;
|
|
int i = iArr[a2];
|
|
int i2 = iArr[b];
|
|
iArr[a2] = i2;
|
|
iArr[b] = i;
|
|
iArr2[i2] = a2;
|
|
iArr2[i] = b;
|
|
}
|
|
|
|
public final int add(long value) {
|
|
ensure(this.size + 1);
|
|
int i = this.size;
|
|
this.size = i + 1;
|
|
int allocateHandle = allocateHandle();
|
|
this.values[i] = value;
|
|
this.index[i] = allocateHandle;
|
|
this.handles[allocateHandle] = i;
|
|
shiftUp(i);
|
|
return allocateHandle;
|
|
}
|
|
|
|
public final int getSize() {
|
|
return this.size;
|
|
}
|
|
|
|
public final long lowestOrDefault(long r2) {
|
|
return this.size > 0 ? this.values[0] : r2;
|
|
}
|
|
|
|
public final void remove(int handle) {
|
|
int i = this.handles[handle];
|
|
swap(i, this.size - 1);
|
|
this.size--;
|
|
shiftUp(i);
|
|
shiftDown(i);
|
|
freeHandle(handle);
|
|
}
|
|
|
|
@TestOnly
|
|
public final void validate() {
|
|
int i = this.size;
|
|
int i2 = 1;
|
|
while (i2 < i) {
|
|
int i3 = i2 + 1;
|
|
long[] jArr = this.values;
|
|
if (Intrinsics.compare(jArr[(i3 >> 1) - 1], jArr[i2]) > 0) {
|
|
throw new IllegalStateException(("Index " + i2 + " is out of place").toString());
|
|
}
|
|
i2 = i3;
|
|
}
|
|
}
|
|
|
|
@TestOnly
|
|
public final void validateHandle(int handle, long value) {
|
|
int i = this.handles[handle];
|
|
if (this.index[i] != handle) {
|
|
throw new IllegalStateException(("Index for handle " + handle + " is corrupted").toString());
|
|
}
|
|
if (this.values[i] == value) {
|
|
return;
|
|
}
|
|
StringBuilder m0m = a$$ExternalSyntheticOutline0.m0m(handle, "Value for handle ", " was ");
|
|
m0m.append(this.values[i]);
|
|
m0m.append(" but was supposed to be ");
|
|
m0m.append(value);
|
|
throw new IllegalStateException(m0m.toString().toString());
|
|
}
|
|
}
|