205 lines
6.1 KiB
Java
205 lines
6.1 KiB
Java
package com.google.common.primitives;
|
|
|
|
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.List;
|
|
import java.util.RandomAccess;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Ints {
|
|
|
|
private static class IntArrayAsList extends AbstractList<Integer> implements RandomAccess, Serializable {
|
|
final int[] a;
|
|
final int b;
|
|
final int c;
|
|
|
|
IntArrayAsList(int[] iArr, int i, int i2) {
|
|
this.a = iArr;
|
|
this.b = i;
|
|
this.c = i2;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public Integer set(int i, Integer num) {
|
|
Preconditions.a(i, size());
|
|
int[] iArr = this.a;
|
|
int i2 = this.b;
|
|
int i3 = iArr[i2 + i];
|
|
Preconditions.a(num);
|
|
iArr[i2 + i] = num.intValue();
|
|
return Integer.valueOf(i3);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean contains(Object obj) {
|
|
return (obj instanceof Integer) && Ints.c(this.a, ((Integer) obj).intValue(), this.b, this.c) != -1;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.Collection, java.util.List
|
|
public boolean equals(Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof IntArrayAsList)) {
|
|
return super.equals(obj);
|
|
}
|
|
IntArrayAsList intArrayAsList = (IntArrayAsList) obj;
|
|
int size = size();
|
|
if (intArrayAsList.size() != size) {
|
|
return false;
|
|
}
|
|
for (int i = 0; i < size; i++) {
|
|
if (this.a[this.b + i] != intArrayAsList.a[intArrayAsList.b + i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.Collection, java.util.List
|
|
public int hashCode() {
|
|
int i = 1;
|
|
for (int i2 = this.b; i2 < this.c; i2++) {
|
|
int i3 = this.a[i2];
|
|
Ints.a(i3);
|
|
i = (i * 31) + i3;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public int indexOf(Object obj) {
|
|
int c;
|
|
if (!(obj instanceof Integer) || (c = Ints.c(this.a, ((Integer) obj).intValue(), this.b, this.c)) < 0) {
|
|
return -1;
|
|
}
|
|
return c - this.b;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean isEmpty() {
|
|
return false;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public int lastIndexOf(Object obj) {
|
|
int d;
|
|
if (!(obj instanceof Integer) || (d = Ints.d(this.a, ((Integer) obj).intValue(), this.b, this.c)) < 0) {
|
|
return -1;
|
|
}
|
|
return d - this.b;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public int size() {
|
|
return this.c - this.b;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public List<Integer> subList(int i, int i2) {
|
|
Preconditions.b(i, i2, size());
|
|
if (i == i2) {
|
|
return Collections.emptyList();
|
|
}
|
|
int[] iArr = this.a;
|
|
int i3 = this.b;
|
|
return new IntArrayAsList(iArr, i + i3, i3 + i2);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder(size() * 5);
|
|
sb.append('[');
|
|
sb.append(this.a[this.b]);
|
|
int i = this.b;
|
|
while (true) {
|
|
i++;
|
|
if (i >= this.c) {
|
|
sb.append(']');
|
|
return sb.toString();
|
|
}
|
|
sb.append(", ");
|
|
sb.append(this.a[i]);
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public Integer get(int i) {
|
|
Preconditions.a(i, size());
|
|
return Integer.valueOf(this.a[this.b + i]);
|
|
}
|
|
|
|
int[] a() {
|
|
return Arrays.copyOfRange(this.a, this.b, this.c);
|
|
}
|
|
}
|
|
|
|
public static int a(int i) {
|
|
return i;
|
|
}
|
|
|
|
public static int a(int i, int i2) {
|
|
if (i < i2) {
|
|
return -1;
|
|
}
|
|
return i > i2 ? 1 : 0;
|
|
}
|
|
|
|
public static int b(long j) {
|
|
if (j > 2147483647L) {
|
|
return Integer.MAX_VALUE;
|
|
}
|
|
if (j < -2147483648L) {
|
|
return Integer.MIN_VALUE;
|
|
}
|
|
return (int) j;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static int c(int[] iArr, int i, int i2, int i3) {
|
|
while (i2 < i3) {
|
|
if (iArr[i2] == i) {
|
|
return i2;
|
|
}
|
|
i2++;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static int d(int[] iArr, int i, int i2, int i3) {
|
|
for (int i4 = i3 - 1; i4 >= i2; i4--) {
|
|
if (iArr[i4] == i) {
|
|
return i4;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public static int a(long j) {
|
|
int i = (int) j;
|
|
Preconditions.a(((long) i) == j, "Out of range: %s", j);
|
|
return i;
|
|
}
|
|
|
|
public static int[] a(Collection<? extends Number> collection) {
|
|
if (collection instanceof IntArrayAsList) {
|
|
return ((IntArrayAsList) collection).a();
|
|
}
|
|
Object[] array = collection.toArray();
|
|
int length = array.length;
|
|
int[] iArr = new int[length];
|
|
for (int i = 0; i < length; i++) {
|
|
Object obj = array[i];
|
|
Preconditions.a(obj);
|
|
iArr[i] = ((Number) obj).intValue();
|
|
}
|
|
return iArr;
|
|
}
|
|
}
|