discord-jadx/app/src/main/java/androidx/constraintlayout/solver/ArrayLinkedVariables.java

521 lines
17 KiB
Java
Raw Normal View History

2021-06-27 20:44:35 +00:00
package androidx.constraintlayout.solver;
import androidx.constraintlayout.solver.ArrayRow;
import c.d.b.a.a;
import java.io.PrintStream;
import java.util.Arrays;
public class ArrayLinkedVariables implements ArrayRow.ArrayRowVariables {
private static final boolean DEBUG = false;
private static final boolean FULL_NEW_CHECK = false;
public static final int NONE = -1;
private static float epsilon = 0.001f;
private int ROW_SIZE = 8;
private SolverVariable candidate = null;
public int currentSize = 0;
private int[] mArrayIndices = new int[8];
private int[] mArrayNextIndices = new int[8];
private float[] mArrayValues = new float[8];
public final Cache mCache;
private boolean mDidFillOnce = false;
private int mHead = -1;
private int mLast = -1;
private final ArrayRow mRow;
public ArrayLinkedVariables(ArrayRow arrayRow, Cache cache) {
this.mRow = arrayRow;
this.mCache = cache;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public void add(SolverVariable solverVariable, float f, boolean z2) {
float f2 = epsilon;
if (f <= (-f2) || f >= f2) {
int i = this.mHead;
if (i == -1) {
this.mHead = 0;
this.mArrayValues[0] = f;
this.mArrayIndices[0] = solverVariable.f20id;
this.mArrayNextIndices[0] = -1;
solverVariable.usageInRowCount++;
solverVariable.addToRow(this.mRow);
this.currentSize++;
if (!this.mDidFillOnce) {
int i2 = this.mLast + 1;
this.mLast = i2;
int[] iArr = this.mArrayIndices;
if (i2 >= iArr.length) {
this.mDidFillOnce = true;
this.mLast = iArr.length - 1;
return;
}
return;
}
return;
}
int i3 = 0;
int i4 = -1;
while (i != -1 && i3 < this.currentSize) {
int[] iArr2 = this.mArrayIndices;
int i5 = iArr2[i];
int i6 = solverVariable.f20id;
if (i5 == i6) {
float[] fArr = this.mArrayValues;
float f3 = fArr[i] + f;
float f4 = epsilon;
if (f3 > (-f4) && f3 < f4) {
f3 = 0.0f;
}
fArr[i] = f3;
if (f3 == 0.0f) {
if (i == this.mHead) {
this.mHead = this.mArrayNextIndices[i];
} else {
int[] iArr3 = this.mArrayNextIndices;
iArr3[i4] = iArr3[i];
}
if (z2) {
solverVariable.removeFromRow(this.mRow);
}
if (this.mDidFillOnce) {
this.mLast = i;
}
solverVariable.usageInRowCount--;
this.currentSize--;
return;
}
return;
}
if (iArr2[i] < i6) {
i4 = i;
}
i = this.mArrayNextIndices[i];
i3++;
}
int i7 = this.mLast;
int i8 = i7 + 1;
if (this.mDidFillOnce) {
int[] iArr4 = this.mArrayIndices;
if (iArr4[i7] != -1) {
i7 = iArr4.length;
}
} else {
i7 = i8;
}
int[] iArr5 = this.mArrayIndices;
if (i7 >= iArr5.length && this.currentSize < iArr5.length) {
int i9 = 0;
while (true) {
int[] iArr6 = this.mArrayIndices;
if (i9 >= iArr6.length) {
break;
} else if (iArr6[i9] == -1) {
i7 = i9;
break;
} else {
i9++;
}
}
}
int[] iArr7 = this.mArrayIndices;
if (i7 >= iArr7.length) {
i7 = iArr7.length;
int i10 = this.ROW_SIZE * 2;
this.ROW_SIZE = i10;
this.mDidFillOnce = false;
this.mLast = i7 - 1;
this.mArrayValues = Arrays.copyOf(this.mArrayValues, i10);
this.mArrayIndices = Arrays.copyOf(this.mArrayIndices, this.ROW_SIZE);
this.mArrayNextIndices = Arrays.copyOf(this.mArrayNextIndices, this.ROW_SIZE);
}
this.mArrayIndices[i7] = solverVariable.f20id;
this.mArrayValues[i7] = f;
if (i4 != -1) {
int[] iArr8 = this.mArrayNextIndices;
iArr8[i7] = iArr8[i4];
iArr8[i4] = i7;
} else {
this.mArrayNextIndices[i7] = this.mHead;
this.mHead = i7;
}
solverVariable.usageInRowCount++;
solverVariable.addToRow(this.mRow);
this.currentSize++;
if (!this.mDidFillOnce) {
this.mLast++;
}
int i11 = this.mLast;
int[] iArr9 = this.mArrayIndices;
if (i11 >= iArr9.length) {
this.mDidFillOnce = true;
this.mLast = iArr9.length - 1;
}
}
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public final void clear() {
int i = this.mHead;
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
SolverVariable solverVariable = this.mCache.mIndexedVariables[this.mArrayIndices[i]];
if (solverVariable != null) {
solverVariable.removeFromRow(this.mRow);
}
i = this.mArrayNextIndices[i];
i2++;
}
this.mHead = -1;
this.mLast = -1;
this.mDidFillOnce = false;
this.currentSize = 0;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public boolean contains(SolverVariable solverVariable) {
int i = this.mHead;
if (i == -1) {
return false;
}
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
if (this.mArrayIndices[i] == solverVariable.f20id) {
return true;
}
i = this.mArrayNextIndices[i];
i2++;
}
return false;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public void display() {
int i = this.currentSize;
System.out.print("{ ");
for (int i2 = 0; i2 < i; i2++) {
SolverVariable variable = getVariable(i2);
if (variable != null) {
PrintStream printStream = System.out;
printStream.print(variable + " = " + getVariableValue(i2) + " ");
}
}
System.out.println(" }");
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public void divideByAmount(float f) {
int i = this.mHead;
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
float[] fArr = this.mArrayValues;
fArr[i] = fArr[i] / f;
i = this.mArrayNextIndices[i];
i2++;
}
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public final float get(SolverVariable solverVariable) {
int i = this.mHead;
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
if (this.mArrayIndices[i] == solverVariable.f20id) {
return this.mArrayValues[i];
}
i = this.mArrayNextIndices[i];
i2++;
}
return 0.0f;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public int getCurrentSize() {
return this.currentSize;
}
public int getHead() {
return this.mHead;
}
public final int getId(int i) {
return this.mArrayIndices[i];
}
public final int getNextIndice(int i) {
return this.mArrayNextIndices[i];
}
public SolverVariable getPivotCandidate() {
SolverVariable solverVariable = this.candidate;
if (solverVariable != null) {
return solverVariable;
}
int i = this.mHead;
int i2 = 0;
SolverVariable solverVariable2 = null;
while (i != -1 && i2 < this.currentSize) {
if (this.mArrayValues[i] < 0.0f) {
SolverVariable solverVariable3 = this.mCache.mIndexedVariables[this.mArrayIndices[i]];
if (solverVariable2 == null || solverVariable2.strength < solverVariable3.strength) {
solverVariable2 = solverVariable3;
}
}
i = this.mArrayNextIndices[i];
i2++;
}
return solverVariable2;
}
public final float getValue(int i) {
return this.mArrayValues[i];
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public SolverVariable getVariable(int i) {
int i2 = this.mHead;
int i3 = 0;
while (i2 != -1 && i3 < this.currentSize) {
if (i3 == i) {
return this.mCache.mIndexedVariables[this.mArrayIndices[i2]];
}
i2 = this.mArrayNextIndices[i2];
i3++;
}
return null;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public float getVariableValue(int i) {
int i2 = this.mHead;
int i3 = 0;
while (i2 != -1 && i3 < this.currentSize) {
if (i3 == i) {
return this.mArrayValues[i2];
}
i2 = this.mArrayNextIndices[i2];
i3++;
}
return 0.0f;
}
public boolean hasAtLeastOnePositiveVariable() {
int i = this.mHead;
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
if (this.mArrayValues[i] > 0.0f) {
return true;
}
i = this.mArrayNextIndices[i];
i2++;
}
return false;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public int indexOf(SolverVariable solverVariable) {
int i = this.mHead;
if (i == -1) {
return -1;
}
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
if (this.mArrayIndices[i] == solverVariable.f20id) {
return i;
}
i = this.mArrayNextIndices[i];
i2++;
}
return -1;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public void invert() {
int i = this.mHead;
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
float[] fArr = this.mArrayValues;
fArr[i] = fArr[i] * -1.0f;
i = this.mArrayNextIndices[i];
i2++;
}
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public final void put(SolverVariable solverVariable, float f) {
if (f == 0.0f) {
remove(solverVariable, true);
return;
}
int i = this.mHead;
if (i == -1) {
this.mHead = 0;
this.mArrayValues[0] = f;
this.mArrayIndices[0] = solverVariable.f20id;
this.mArrayNextIndices[0] = -1;
solverVariable.usageInRowCount++;
solverVariable.addToRow(this.mRow);
this.currentSize++;
if (!this.mDidFillOnce) {
int i2 = this.mLast + 1;
this.mLast = i2;
int[] iArr = this.mArrayIndices;
if (i2 >= iArr.length) {
this.mDidFillOnce = true;
this.mLast = iArr.length - 1;
return;
}
return;
}
return;
}
int i3 = 0;
int i4 = -1;
while (i != -1 && i3 < this.currentSize) {
int[] iArr2 = this.mArrayIndices;
int i5 = iArr2[i];
int i6 = solverVariable.f20id;
if (i5 == i6) {
this.mArrayValues[i] = f;
return;
}
if (iArr2[i] < i6) {
i4 = i;
}
i = this.mArrayNextIndices[i];
i3++;
}
int i7 = this.mLast;
int i8 = i7 + 1;
if (this.mDidFillOnce) {
int[] iArr3 = this.mArrayIndices;
if (iArr3[i7] != -1) {
i7 = iArr3.length;
}
} else {
i7 = i8;
}
int[] iArr4 = this.mArrayIndices;
if (i7 >= iArr4.length && this.currentSize < iArr4.length) {
int i9 = 0;
while (true) {
int[] iArr5 = this.mArrayIndices;
if (i9 >= iArr5.length) {
break;
} else if (iArr5[i9] == -1) {
i7 = i9;
break;
} else {
i9++;
}
}
}
int[] iArr6 = this.mArrayIndices;
if (i7 >= iArr6.length) {
i7 = iArr6.length;
int i10 = this.ROW_SIZE * 2;
this.ROW_SIZE = i10;
this.mDidFillOnce = false;
this.mLast = i7 - 1;
this.mArrayValues = Arrays.copyOf(this.mArrayValues, i10);
this.mArrayIndices = Arrays.copyOf(this.mArrayIndices, this.ROW_SIZE);
this.mArrayNextIndices = Arrays.copyOf(this.mArrayNextIndices, this.ROW_SIZE);
}
this.mArrayIndices[i7] = solverVariable.f20id;
this.mArrayValues[i7] = f;
if (i4 != -1) {
int[] iArr7 = this.mArrayNextIndices;
iArr7[i7] = iArr7[i4];
iArr7[i4] = i7;
} else {
this.mArrayNextIndices[i7] = this.mHead;
this.mHead = i7;
}
solverVariable.usageInRowCount++;
solverVariable.addToRow(this.mRow);
int i11 = this.currentSize + 1;
this.currentSize = i11;
if (!this.mDidFillOnce) {
this.mLast++;
}
int[] iArr8 = this.mArrayIndices;
if (i11 >= iArr8.length) {
this.mDidFillOnce = true;
}
if (this.mLast >= iArr8.length) {
this.mDidFillOnce = true;
this.mLast = iArr8.length - 1;
}
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public final float remove(SolverVariable solverVariable, boolean z2) {
if (this.candidate == solverVariable) {
this.candidate = null;
}
int i = this.mHead;
if (i == -1) {
return 0.0f;
}
int i2 = 0;
int i3 = -1;
while (i != -1 && i2 < this.currentSize) {
if (this.mArrayIndices[i] == solverVariable.f20id) {
if (i == this.mHead) {
this.mHead = this.mArrayNextIndices[i];
} else {
int[] iArr = this.mArrayNextIndices;
iArr[i3] = iArr[i];
}
if (z2) {
solverVariable.removeFromRow(this.mRow);
}
solverVariable.usageInRowCount--;
this.currentSize--;
this.mArrayIndices[i] = -1;
if (this.mDidFillOnce) {
this.mLast = i;
}
return this.mArrayValues[i];
}
i2++;
i3 = i;
i = this.mArrayNextIndices[i];
}
return 0.0f;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public int sizeInBytes() {
return (this.mArrayIndices.length * 4 * 3) + 0 + 36;
}
public String toString() {
int i = this.mHead;
String str = "";
int i2 = 0;
while (i != -1 && i2 < this.currentSize) {
2021-07-13 20:23:20 +00:00
StringBuilder L = a.L(a.t(str, " -> "));
2021-06-27 20:44:35 +00:00
L.append(this.mArrayValues[i]);
L.append(" : ");
StringBuilder L2 = a.L(L.toString());
L2.append(this.mCache.mIndexedVariables[this.mArrayIndices[i]]);
str = L2.toString();
i = this.mArrayNextIndices[i];
i2++;
}
return str;
}
@Override // androidx.constraintlayout.solver.ArrayRow.ArrayRowVariables
public float use(ArrayRow arrayRow, boolean z2) {
float f = get(arrayRow.variable);
remove(arrayRow.variable, z2);
ArrayRow.ArrayRowVariables arrayRowVariables = arrayRow.variables;
int currentSize = arrayRowVariables.getCurrentSize();
for (int i = 0; i < currentSize; i++) {
SolverVariable variable = arrayRowVariables.getVariable(i);
add(variable, arrayRowVariables.get(variable) * f, z2);
}
return f;
}
}