discord-jadx/app/src/main/java/c/i/e/n/b.java

160 lines
4.3 KiB
Java

package c.i.e.n;
import java.util.Arrays;
/* compiled from: BitMatrix */
public final class b implements Cloneable {
public final int i;
public final int j;
public final int k;
public final int[] l;
public b(int i, int i2) {
if (i <= 0 || i2 <= 0) {
throw new IllegalArgumentException("Both dimensions must be greater than 0");
}
this.i = i;
this.j = i2;
int i3 = (i + 31) / 32;
this.k = i3;
this.l = new int[(i3 * i2)];
}
public b(int i, int i2, int i3, int[] iArr) {
this.i = i;
this.j = i2;
this.k = i3;
this.l = iArr;
}
public void b(int i, int i2) {
int i3 = (i / 32) + (i2 * this.k);
int[] iArr = this.l;
iArr[i3] = (1 << (i & 31)) ^ iArr[i3];
}
@Override // java.lang.Object
public Object clone() throws CloneNotSupportedException {
return new b(this.i, this.j, this.k, (int[]) this.l.clone());
}
@Override // java.lang.Object
public boolean equals(Object obj) {
if (!(obj instanceof b)) {
return false;
}
b bVar = (b) obj;
return this.i == bVar.i && this.j == bVar.j && this.k == bVar.k && Arrays.equals(this.l, bVar.l);
}
public boolean f(int i, int i2) {
return ((this.l[(i / 32) + (i2 * this.k)] >>> (i & 31)) & 1) != 0;
}
public int[] g() {
int length = this.l.length - 1;
while (length >= 0 && this.l[length] == 0) {
length--;
}
if (length < 0) {
return null;
}
int i = this.k;
int i2 = length / i;
int i3 = (length % i) << 5;
int i4 = 31;
while ((this.l[length] >>> i4) == 0) {
i4--;
}
return new int[]{i3 + i4, i2};
}
public a h(int i, a aVar) {
int i2 = aVar.j;
int i3 = this.i;
if (i2 < i3) {
aVar = new a(i3);
} else {
int length = aVar.i.length;
for (int i4 = 0; i4 < length; i4++) {
aVar.i[i4] = 0;
}
}
int i5 = i * this.k;
for (int i6 = 0; i6 < this.k; i6++) {
aVar.i[(i6 << 5) / 32] = this.l[i5 + i6];
}
return aVar;
}
@Override // java.lang.Object
public int hashCode() {
int i = this.i;
return Arrays.hashCode(this.l) + (((((((i * 31) + i) * 31) + this.j) * 31) + this.k) * 31);
}
public int[] i() {
int[] iArr;
int i = 0;
while (true) {
iArr = this.l;
if (i >= iArr.length || iArr[i] != 0) {
break;
}
i++;
}
if (i == iArr.length) {
return null;
}
int i2 = this.k;
int i3 = i / i2;
int i4 = (i % i2) << 5;
int i5 = iArr[i];
int i6 = 0;
while ((i5 << (31 - i6)) == 0) {
i6++;
}
return new int[]{i4 + i6, i3};
}
public void j(int i, int i2) {
int i3 = (i / 32) + (i2 * this.k);
int[] iArr = this.l;
iArr[i3] = (1 << (i & 31)) | iArr[i3];
}
public void k(int i, int i2, int i3, int i4) {
if (i2 < 0 || i < 0) {
throw new IllegalArgumentException("Left and top must be nonnegative");
} else if (i4 <= 0 || i3 <= 0) {
throw new IllegalArgumentException("Height and width must be at least 1");
} else {
int i5 = i3 + i;
int i6 = i4 + i2;
if (i6 > this.j || i5 > this.i) {
throw new IllegalArgumentException("The region must fit inside the matrix");
}
while (i2 < i6) {
int i7 = this.k * i2;
for (int i8 = i; i8 < i5; i8++) {
int[] iArr = this.l;
int i9 = (i8 / 32) + i7;
iArr[i9] = iArr[i9] | (1 << (i8 & 31));
}
i2++;
}
}
}
@Override // java.lang.Object
public String toString() {
StringBuilder sb = new StringBuilder((this.i + 1) * this.j);
for (int i = 0; i < this.j; i++) {
for (int i2 = 0; i2 < this.i; i2++) {
sb.append(f(i2, i) ? "X " : " ");
}
sb.append("\n");
}
return sb.toString();
}
}