mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 09:02:34 -06:00
513 lines
16 KiB
Java
513 lines
16 KiB
Java
package com.google.common.primitives;
|
|
|
|
import com.google.common.base.Converter;
|
|
import com.google.common.base.Preconditions;
|
|
import java.io.Serializable;
|
|
import java.util.AbstractList;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.RandomAccess;
|
|
import javax.annotation.CheckForNull;
|
|
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
public final class Longs {
|
|
public static final int BYTES = 8;
|
|
public static final long MAX_POWER_OF_TWO = 4611686018427387904L;
|
|
|
|
public static int compare(long j, long j2) {
|
|
if (j < j2) {
|
|
return -1;
|
|
}
|
|
return j > j2 ? 1 : 0;
|
|
}
|
|
|
|
public static long fromBytes(byte b, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7, byte b8) {
|
|
return ((b2 & 255) << 48) | ((b & 255) << 56) | ((b3 & 255) << 40) | ((b4 & 255) << 32) | ((b5 & 255) << 24) | ((b6 & 255) << 16) | ((b7 & 255) << 8) | (b8 & 255);
|
|
}
|
|
|
|
public static int hashCode(long j) {
|
|
return (int) (j ^ (j >>> 32));
|
|
}
|
|
|
|
private Longs() {
|
|
}
|
|
|
|
public static boolean contains(long[] jArr, long j) {
|
|
for (long j2 : jArr) {
|
|
if (j2 == j) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static int indexOf(long[] jArr, long j) {
|
|
return indexOf(jArr, j, 0, jArr.length);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static int indexOf(long[] jArr, long j, int i, int i2) {
|
|
while (i < i2) {
|
|
if (jArr[i] == j) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:15:0x0025, code lost:
|
|
|
|
r0 = r0 + 1;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public static int indexOf(long[] r7, long[] r8) {
|
|
/*
|
|
java.lang.String r0 = "array"
|
|
com.google.common.base.Preconditions.checkNotNull(r7, r0)
|
|
java.lang.String r0 = "target"
|
|
com.google.common.base.Preconditions.checkNotNull(r8, r0)
|
|
int r0 = r8.length
|
|
r1 = 0
|
|
if (r0 != 0) goto Lf
|
|
return r1
|
|
Lf:
|
|
r0 = r1
|
|
L10:
|
|
int r2 = r7.length
|
|
int r3 = r8.length
|
|
int r2 = r2 - r3
|
|
int r2 = r2 + 1
|
|
if (r0 >= r2) goto L2c
|
|
r2 = r1
|
|
L18:
|
|
int r3 = r8.length
|
|
if (r2 >= r3) goto L2b
|
|
int r3 = r0 + r2
|
|
r3 = r7[r3]
|
|
r5 = r8[r2]
|
|
int r3 = (r3 > r5 ? 1 : (r3 == r5 ? 0 : -1))
|
|
if (r3 == 0) goto L28
|
|
int r0 = r0 + 1
|
|
goto L10
|
|
L28:
|
|
int r2 = r2 + 1
|
|
goto L18
|
|
L2b:
|
|
return r0
|
|
L2c:
|
|
r7 = -1
|
|
return r7
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.common.primitives.Longs.indexOf(long[], long[]):int");
|
|
}
|
|
|
|
public static int lastIndexOf(long[] jArr, long j) {
|
|
return lastIndexOf(jArr, j, 0, jArr.length);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static int lastIndexOf(long[] jArr, long j, int i, int i2) {
|
|
for (int i3 = i2 - 1; i3 >= i; i3--) {
|
|
if (jArr[i3] == j) {
|
|
return i3;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public static long min(long... jArr) {
|
|
Preconditions.checkArgument(jArr.length > 0);
|
|
long j = jArr[0];
|
|
for (int i = 1; i < jArr.length; i++) {
|
|
long j2 = jArr[i];
|
|
if (j2 < j) {
|
|
j = j2;
|
|
}
|
|
}
|
|
return j;
|
|
}
|
|
|
|
public static long max(long... jArr) {
|
|
Preconditions.checkArgument(jArr.length > 0);
|
|
long j = jArr[0];
|
|
for (int i = 1; i < jArr.length; i++) {
|
|
long j2 = jArr[i];
|
|
if (j2 > j) {
|
|
j = j2;
|
|
}
|
|
}
|
|
return j;
|
|
}
|
|
|
|
public static long constrainToRange(long j, long j2, long j3) {
|
|
Preconditions.checkArgument(j2 <= j3, "min (%s) must be less than or equal to max (%s)", j2, j3);
|
|
return Math.min(Math.max(j, j2), j3);
|
|
}
|
|
|
|
public static long[] concat(long[]... jArr) {
|
|
int i = 0;
|
|
for (long[] jArr2 : jArr) {
|
|
i += jArr2.length;
|
|
}
|
|
long[] jArr3 = new long[i];
|
|
int i2 = 0;
|
|
for (long[] jArr4 : jArr) {
|
|
System.arraycopy(jArr4, 0, jArr3, i2, jArr4.length);
|
|
i2 += jArr4.length;
|
|
}
|
|
return jArr3;
|
|
}
|
|
|
|
public static byte[] toByteArray(long j) {
|
|
byte[] bArr = new byte[8];
|
|
for (int i = 7; i >= 0; i--) {
|
|
bArr[i] = (byte) (255 & j);
|
|
j >>= 8;
|
|
}
|
|
return bArr;
|
|
}
|
|
|
|
public static long fromByteArray(byte[] bArr) {
|
|
Preconditions.checkArgument(bArr.length >= 8, "array too small: %s < %s", bArr.length, 8);
|
|
return fromBytes(bArr[0], bArr[1], bArr[2], bArr[3], bArr[4], bArr[5], bArr[6], bArr[7]);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes3.dex */
|
|
public static final class AsciiDigits {
|
|
private static final byte[] asciiDigits;
|
|
|
|
private AsciiDigits() {
|
|
}
|
|
|
|
static {
|
|
byte[] bArr = new byte[128];
|
|
Arrays.fill(bArr, (byte) -1);
|
|
for (int i = 0; i < 10; i++) {
|
|
bArr[i + 48] = (byte) i;
|
|
}
|
|
for (int i2 = 0; i2 < 26; i2++) {
|
|
byte b = (byte) (i2 + 10);
|
|
bArr[i2 + 65] = b;
|
|
bArr[i2 + 97] = b;
|
|
}
|
|
asciiDigits = bArr;
|
|
}
|
|
|
|
static int digit(char c) {
|
|
if (c < 128) {
|
|
return asciiDigits[c];
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
@CheckForNull
|
|
public static Long tryParse(String str) {
|
|
return tryParse(str, 10);
|
|
}
|
|
|
|
@CheckForNull
|
|
public static Long tryParse(String str, int i) {
|
|
if (((String) Preconditions.checkNotNull(str)).isEmpty()) {
|
|
return null;
|
|
}
|
|
if (i < 2 || i > 36) {
|
|
throw new IllegalArgumentException(new StringBuilder(65).append("radix must be between MIN_RADIX and MAX_RADIX but was ").append(i).toString());
|
|
}
|
|
int i2 = str.charAt(0) == '-' ? 1 : 0;
|
|
if (i2 == str.length()) {
|
|
return null;
|
|
}
|
|
int i3 = i2 + 1;
|
|
int digit = AsciiDigits.digit(str.charAt(i2));
|
|
if (digit < 0 || digit >= i) {
|
|
return null;
|
|
}
|
|
long j = -digit;
|
|
long j2 = i;
|
|
long j3 = Long.MIN_VALUE / j2;
|
|
while (i3 < str.length()) {
|
|
int i4 = i3 + 1;
|
|
int digit2 = AsciiDigits.digit(str.charAt(i3));
|
|
if (digit2 < 0 || digit2 >= i || j < j3) {
|
|
return null;
|
|
}
|
|
long j4 = j * j2;
|
|
long j5 = digit2;
|
|
if (j4 < j5 - Long.MIN_VALUE) {
|
|
return null;
|
|
}
|
|
j = j4 - j5;
|
|
i3 = i4;
|
|
}
|
|
if (i2 != 0) {
|
|
return Long.valueOf(j);
|
|
}
|
|
if (j == Long.MIN_VALUE) {
|
|
return null;
|
|
}
|
|
return Long.valueOf(-j);
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
private static final class LongConverter extends Converter<String, Long> implements Serializable {
|
|
static final LongConverter INSTANCE = new LongConverter();
|
|
private static final long serialVersionUID = 1;
|
|
|
|
private Object readResolve() {
|
|
return INSTANCE;
|
|
}
|
|
|
|
public String toString() {
|
|
return "Longs.stringConverter()";
|
|
}
|
|
|
|
private LongConverter() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.base.Converter
|
|
public Long doForward(String str) {
|
|
return Long.decode(str);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.base.Converter
|
|
public String doBackward(Long l) {
|
|
return l.toString();
|
|
}
|
|
}
|
|
|
|
public static Converter<String, Long> stringConverter() {
|
|
return LongConverter.INSTANCE;
|
|
}
|
|
|
|
public static long[] ensureCapacity(long[] jArr, int i, int i2) {
|
|
Preconditions.checkArgument(i >= 0, "Invalid minLength: %s", i);
|
|
Preconditions.checkArgument(i2 >= 0, "Invalid padding: %s", i2);
|
|
return jArr.length < i ? Arrays.copyOf(jArr, i + i2) : jArr;
|
|
}
|
|
|
|
public static String join(String str, long... jArr) {
|
|
Preconditions.checkNotNull(str);
|
|
if (jArr.length == 0) {
|
|
return "";
|
|
}
|
|
StringBuilder sb = new StringBuilder(jArr.length * 10);
|
|
sb.append(jArr[0]);
|
|
for (int i = 1; i < jArr.length; i++) {
|
|
sb.append(str).append(jArr[i]);
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public static Comparator<long[]> lexicographicalComparator() {
|
|
return LexicographicalComparator.INSTANCE;
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
private enum LexicographicalComparator implements Comparator<long[]> {
|
|
INSTANCE;
|
|
|
|
@Override // java.lang.Enum
|
|
public String toString() {
|
|
return "Longs.lexicographicalComparator()";
|
|
}
|
|
|
|
@Override // java.util.Comparator
|
|
public int compare(long[] jArr, long[] jArr2) {
|
|
int min = Math.min(jArr.length, jArr2.length);
|
|
for (int i = 0; i < min; i++) {
|
|
int compare = Longs.compare(jArr[i], jArr2[i]);
|
|
if (compare != 0) {
|
|
return compare;
|
|
}
|
|
}
|
|
return jArr.length - jArr2.length;
|
|
}
|
|
}
|
|
|
|
public static void sortDescending(long[] jArr) {
|
|
Preconditions.checkNotNull(jArr);
|
|
sortDescending(jArr, 0, jArr.length);
|
|
}
|
|
|
|
public static void sortDescending(long[] jArr, int i, int i2) {
|
|
Preconditions.checkNotNull(jArr);
|
|
Preconditions.checkPositionIndexes(i, i2, jArr.length);
|
|
Arrays.sort(jArr, i, i2);
|
|
reverse(jArr, i, i2);
|
|
}
|
|
|
|
public static void reverse(long[] jArr) {
|
|
Preconditions.checkNotNull(jArr);
|
|
reverse(jArr, 0, jArr.length);
|
|
}
|
|
|
|
public static void reverse(long[] jArr, int i, int i2) {
|
|
Preconditions.checkNotNull(jArr);
|
|
Preconditions.checkPositionIndexes(i, i2, jArr.length);
|
|
for (int i3 = i2 - 1; i < i3; i3--) {
|
|
long j = jArr[i];
|
|
jArr[i] = jArr[i3];
|
|
jArr[i3] = j;
|
|
i++;
|
|
}
|
|
}
|
|
|
|
public static long[] toArray(Collection<? extends Number> collection) {
|
|
if (collection instanceof LongArrayAsList) {
|
|
return ((LongArrayAsList) collection).toLongArray();
|
|
}
|
|
Object[] array = collection.toArray();
|
|
int length = array.length;
|
|
long[] jArr = new long[length];
|
|
for (int i = 0; i < length; i++) {
|
|
jArr[i] = ((Number) Preconditions.checkNotNull(array[i])).longValue();
|
|
}
|
|
return jArr;
|
|
}
|
|
|
|
public static List<Long> asList(long... jArr) {
|
|
if (jArr.length == 0) {
|
|
return Collections.emptyList();
|
|
}
|
|
return new LongArrayAsList(jArr);
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
private static class LongArrayAsList extends AbstractList<Long> implements RandomAccess, Serializable {
|
|
private static final long serialVersionUID = 0;
|
|
final long[] array;
|
|
final int end;
|
|
final int start;
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean isEmpty() {
|
|
return false;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public int size() {
|
|
return this.end - this.start;
|
|
}
|
|
|
|
LongArrayAsList(long[] jArr) {
|
|
this(jArr, 0, jArr.length);
|
|
}
|
|
|
|
LongArrayAsList(long[] jArr, int i, int i2) {
|
|
this.array = jArr;
|
|
this.start = i;
|
|
this.end = i2;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public Long get(int i) {
|
|
Preconditions.checkElementIndex(i, size());
|
|
return Long.valueOf(this.array[this.start + i]);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean contains(@CheckForNull Object obj) {
|
|
return (obj instanceof Long) && Longs.indexOf(this.array, ((Long) obj).longValue(), this.start, this.end) != -1;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public int indexOf(@CheckForNull Object obj) {
|
|
int indexOf;
|
|
if (!(obj instanceof Long) || (indexOf = Longs.indexOf(this.array, ((Long) obj).longValue(), this.start, this.end)) < 0) {
|
|
return -1;
|
|
}
|
|
return indexOf - this.start;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public int lastIndexOf(@CheckForNull Object obj) {
|
|
int lastIndexOf;
|
|
if (!(obj instanceof Long) || (lastIndexOf = Longs.lastIndexOf(this.array, ((Long) obj).longValue(), this.start, this.end)) < 0) {
|
|
return -1;
|
|
}
|
|
return lastIndexOf - this.start;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public Long set(int i, Long l) {
|
|
Preconditions.checkElementIndex(i, size());
|
|
long[] jArr = this.array;
|
|
int i2 = this.start;
|
|
long j = jArr[i2 + i];
|
|
jArr[i2 + i] = ((Long) Preconditions.checkNotNull(l)).longValue();
|
|
return Long.valueOf(j);
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public List<Long> subList(int i, int i2) {
|
|
Preconditions.checkPositionIndexes(i, i2, size());
|
|
if (i == i2) {
|
|
return Collections.emptyList();
|
|
}
|
|
long[] jArr = this.array;
|
|
int i3 = this.start;
|
|
return new LongArrayAsList(jArr, i + i3, i3 + i2);
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.Collection, java.util.List
|
|
public boolean equals(@CheckForNull Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
if (obj instanceof LongArrayAsList) {
|
|
LongArrayAsList longArrayAsList = (LongArrayAsList) obj;
|
|
int size = size();
|
|
if (longArrayAsList.size() != size) {
|
|
return false;
|
|
}
|
|
for (int i = 0; i < size; i++) {
|
|
if (this.array[this.start + i] != longArrayAsList.array[longArrayAsList.start + i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return super.equals(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.Collection, java.util.List
|
|
public int hashCode() {
|
|
int i = 1;
|
|
for (int i2 = this.start; i2 < this.end; i2++) {
|
|
i = (i * 31) + Longs.hashCode(this.array[i2]);
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder(size() * 10);
|
|
sb.append('[').append(this.array[this.start]);
|
|
int i = this.start;
|
|
while (true) {
|
|
i++;
|
|
if (i < this.end) {
|
|
sb.append(", ").append(this.array[i]);
|
|
} else {
|
|
return sb.append(']').toString();
|
|
}
|
|
}
|
|
}
|
|
|
|
long[] toLongArray() {
|
|
return Arrays.copyOfRange(this.array, this.start, this.end);
|
|
}
|
|
}
|
|
}
|