mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 17:42:33 -06:00
577 lines
20 KiB
Java
577 lines
20 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.base.Objects;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Table;
|
|
import com.google.common.collect.Tables;
|
|
import java.io.Serializable;
|
|
import java.lang.reflect.Array;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import javax.annotation.CheckForNull;
|
|
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
public final class ArrayTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
|
|
private static final long serialVersionUID = 0;
|
|
private final V[][] array;
|
|
private final ImmutableMap<C, Integer> columnKeyToIndex;
|
|
private final ImmutableList<C> columnList;
|
|
|
|
@CheckForNull
|
|
private transient ArrayTable<R, C, V>.ColumnMap columnMap;
|
|
private final ImmutableMap<R, Integer> rowKeyToIndex;
|
|
private final ImmutableList<R> rowList;
|
|
|
|
@CheckForNull
|
|
private transient ArrayTable<R, C, V>.RowMap rowMap;
|
|
|
|
public ImmutableList<C> columnKeyList() {
|
|
return this.columnList;
|
|
}
|
|
|
|
public ImmutableList<R> rowKeyList() {
|
|
return this.rowList;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public /* bridge */ /* synthetic */ boolean equals(@CheckForNull Object obj) {
|
|
return super.equals(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public /* bridge */ /* synthetic */ int hashCode() {
|
|
return super.hashCode();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ String toString() {
|
|
return super.toString();
|
|
}
|
|
|
|
public static <R, C, V> ArrayTable<R, C, V> create(Iterable<? extends R> iterable, Iterable<? extends C> iterable2) {
|
|
return new ArrayTable<>(iterable, iterable2);
|
|
}
|
|
|
|
public static <R, C, V> ArrayTable<R, C, V> create(Table<R, C, ? extends V> table) {
|
|
if (table instanceof ArrayTable) {
|
|
return new ArrayTable<>((ArrayTable) table);
|
|
}
|
|
return new ArrayTable<>(table);
|
|
}
|
|
|
|
private ArrayTable(Iterable<? extends R> iterable, Iterable<? extends C> iterable2) {
|
|
ImmutableList<R> copyOf = ImmutableList.copyOf(iterable);
|
|
this.rowList = copyOf;
|
|
ImmutableList<C> copyOf2 = ImmutableList.copyOf(iterable2);
|
|
this.columnList = copyOf2;
|
|
Preconditions.checkArgument(copyOf.isEmpty() == copyOf2.isEmpty());
|
|
this.rowKeyToIndex = Maps.indexMap(copyOf);
|
|
this.columnKeyToIndex = Maps.indexMap(copyOf2);
|
|
this.array = (V[][]) ((Object[][]) Array.newInstance((Class<?>) Object.class, copyOf.size(), copyOf2.size()));
|
|
eraseAll();
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private ArrayTable(Table<R, C, ? extends V> table) {
|
|
this(table.rowKeySet(), table.columnKeySet());
|
|
putAll(table);
|
|
}
|
|
|
|
private ArrayTable(ArrayTable<R, C, V> arrayTable) {
|
|
ImmutableList<R> immutableList = arrayTable.rowList;
|
|
this.rowList = immutableList;
|
|
ImmutableList<C> immutableList2 = arrayTable.columnList;
|
|
this.columnList = immutableList2;
|
|
this.rowKeyToIndex = arrayTable.rowKeyToIndex;
|
|
this.columnKeyToIndex = arrayTable.columnKeyToIndex;
|
|
V[][] vArr = (V[][]) ((Object[][]) Array.newInstance((Class<?>) Object.class, immutableList.size(), immutableList2.size()));
|
|
this.array = vArr;
|
|
for (int i = 0; i < this.rowList.size(); i++) {
|
|
V[] vArr2 = arrayTable.array[i];
|
|
System.arraycopy(vArr2, 0, vArr[i], 0, vArr2.length);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes3.dex */
|
|
public static abstract class ArrayMap<K, V> extends Maps.IteratorBasedAbstractMap<K, V> {
|
|
private final ImmutableMap<K, Integer> keyIndex;
|
|
|
|
abstract String getKeyRole();
|
|
|
|
@ParametricNullness
|
|
abstract V getValue(int i);
|
|
|
|
@ParametricNullness
|
|
abstract V setValue(int i, @ParametricNullness V v);
|
|
|
|
private ArrayMap(ImmutableMap<K, Integer> immutableMap) {
|
|
this.keyIndex = immutableMap;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Set<K> keySet() {
|
|
return this.keyIndex.keySet();
|
|
}
|
|
|
|
K getKey(int i) {
|
|
return this.keyIndex.keySet().asList().get(i);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public int size() {
|
|
return this.keyIndex.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean isEmpty() {
|
|
return this.keyIndex.isEmpty();
|
|
}
|
|
|
|
Map.Entry<K, V> getEntry(final int i) {
|
|
Preconditions.checkElementIndex(i, size());
|
|
return new AbstractMapEntry<K, V>() { // from class: com.google.common.collect.ArrayTable.ArrayMap.1
|
|
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
|
|
public K getKey() {
|
|
return (K) ArrayMap.this.getKey(i);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
|
|
@ParametricNullness
|
|
public V getValue() {
|
|
return (V) ArrayMap.this.getValue(i);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
|
|
@ParametricNullness
|
|
public V setValue(@ParametricNullness V v) {
|
|
return (V) ArrayMap.this.setValue(i, v);
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap
|
|
public Iterator<Map.Entry<K, V>> entryIterator() {
|
|
return new AbstractIndexedListIterator<Map.Entry<K, V>>(size()) { // from class: com.google.common.collect.ArrayTable.ArrayMap.2
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.collect.AbstractIndexedListIterator
|
|
public Map.Entry<K, V> get(int i) {
|
|
return ArrayMap.this.getEntry(i);
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(@CheckForNull Object obj) {
|
|
return this.keyIndex.containsKey(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
@CheckForNull
|
|
public V get(@CheckForNull Object obj) {
|
|
Integer num = this.keyIndex.get(obj);
|
|
if (num == null) {
|
|
return null;
|
|
}
|
|
return getValue(num.intValue());
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
@CheckForNull
|
|
public V put(K k, @ParametricNullness V v) {
|
|
Integer num = this.keyIndex.get(k);
|
|
if (num == null) {
|
|
String keyRole = getKeyRole();
|
|
String valueOf = String.valueOf(k);
|
|
String valueOf2 = String.valueOf(this.keyIndex.keySet());
|
|
throw new IllegalArgumentException(new StringBuilder(String.valueOf(keyRole).length() + 9 + String.valueOf(valueOf).length() + String.valueOf(valueOf2).length()).append(keyRole).append(" ").append(valueOf).append(" not in ").append(valueOf2).toString());
|
|
}
|
|
return setValue(num.intValue(), v);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
@CheckForNull
|
|
public V remove(@CheckForNull Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public void clear() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
@CheckForNull
|
|
public V at(int i, int i2) {
|
|
Preconditions.checkElementIndex(i, this.rowList.size());
|
|
Preconditions.checkElementIndex(i2, this.columnList.size());
|
|
return this.array[i][i2];
|
|
}
|
|
|
|
@CheckForNull
|
|
public V set(int i, int i2, @CheckForNull V v) {
|
|
Preconditions.checkElementIndex(i, this.rowList.size());
|
|
Preconditions.checkElementIndex(i2, this.columnList.size());
|
|
V[] vArr = this.array[i];
|
|
V v2 = vArr[i2];
|
|
vArr[i2] = v;
|
|
return v2;
|
|
}
|
|
|
|
public V[][] toArray(Class<V> cls) {
|
|
V[][] vArr = (V[][]) ((Object[][]) Array.newInstance((Class<?>) cls, this.rowList.size(), this.columnList.size()));
|
|
for (int i = 0; i < this.rowList.size(); i++) {
|
|
V[] vArr2 = this.array[i];
|
|
System.arraycopy(vArr2, 0, vArr[i], 0, vArr2.length);
|
|
}
|
|
return vArr;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
@Deprecated
|
|
public void clear() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public void eraseAll() {
|
|
for (V[] vArr : this.array) {
|
|
Arrays.fill(vArr, (Object) null);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public boolean contains(@CheckForNull Object obj, @CheckForNull Object obj2) {
|
|
return containsRow(obj) && containsColumn(obj2);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public boolean containsColumn(@CheckForNull Object obj) {
|
|
return this.columnKeyToIndex.containsKey(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public boolean containsRow(@CheckForNull Object obj) {
|
|
return this.rowKeyToIndex.containsKey(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public boolean containsValue(@CheckForNull Object obj) {
|
|
for (V[] vArr : this.array) {
|
|
for (V v : vArr) {
|
|
if (Objects.equal(obj, v)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
@CheckForNull
|
|
public V get(@CheckForNull Object obj, @CheckForNull Object obj2) {
|
|
Integer num = this.rowKeyToIndex.get(obj);
|
|
Integer num2 = this.columnKeyToIndex.get(obj2);
|
|
if (num == null || num2 == null) {
|
|
return null;
|
|
}
|
|
return at(num.intValue(), num2.intValue());
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public boolean isEmpty() {
|
|
return this.rowList.isEmpty() || this.columnList.isEmpty();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
@CheckForNull
|
|
public V put(R r, C c, @CheckForNull V v) {
|
|
Preconditions.checkNotNull(r);
|
|
Preconditions.checkNotNull(c);
|
|
Integer num = this.rowKeyToIndex.get(r);
|
|
Preconditions.checkArgument(num != null, "Row %s not in %s", r, this.rowList);
|
|
Integer num2 = this.columnKeyToIndex.get(c);
|
|
Preconditions.checkArgument(num2 != null, "Column %s not in %s", c, this.columnList);
|
|
return set(num.intValue(), num2.intValue(), v);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
|
|
super.putAll(table);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
@CheckForNull
|
|
@Deprecated
|
|
public V remove(@CheckForNull Object obj, @CheckForNull Object obj2) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@CheckForNull
|
|
public V erase(@CheckForNull Object obj, @CheckForNull Object obj2) {
|
|
Integer num = this.rowKeyToIndex.get(obj);
|
|
Integer num2 = this.columnKeyToIndex.get(obj2);
|
|
if (num == null || num2 == null) {
|
|
return null;
|
|
}
|
|
return set(num.intValue(), num2.intValue(), null);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table
|
|
public int size() {
|
|
return this.rowList.size() * this.columnList.size();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public Set<Table.Cell<R, C, V>> cellSet() {
|
|
return super.cellSet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
Iterator<Table.Cell<R, C, V>> cellIterator() {
|
|
return new AbstractIndexedListIterator<Table.Cell<R, C, V>>(size()) { // from class: com.google.common.collect.ArrayTable.1
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.collect.AbstractIndexedListIterator
|
|
public Table.Cell<R, C, V> get(int i) {
|
|
return ArrayTable.this.getCell(i);
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Table.Cell<R, C, V> getCell(int i) {
|
|
return new Tables.AbstractCell<R, C, V>(i) { // from class: com.google.common.collect.ArrayTable.2
|
|
final int columnIndex;
|
|
final int rowIndex;
|
|
final /* synthetic */ int val$index;
|
|
|
|
{
|
|
this.val$index = i;
|
|
this.rowIndex = i / ArrayTable.this.columnList.size();
|
|
this.columnIndex = i % ArrayTable.this.columnList.size();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table.Cell
|
|
public R getRowKey() {
|
|
return (R) ArrayTable.this.rowList.get(this.rowIndex);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table.Cell
|
|
public C getColumnKey() {
|
|
return (C) ArrayTable.this.columnList.get(this.columnIndex);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table.Cell
|
|
@CheckForNull
|
|
public V getValue() {
|
|
return (V) ArrayTable.this.at(this.rowIndex, this.columnIndex);
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
@CheckForNull
|
|
public V getValue(int i) {
|
|
return at(i / this.columnList.size(), i % this.columnList.size());
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table
|
|
public Map<R, V> column(C c) {
|
|
Preconditions.checkNotNull(c);
|
|
Integer num = this.columnKeyToIndex.get(c);
|
|
if (num == null) {
|
|
return Collections.emptyMap();
|
|
}
|
|
return new Column(num.intValue());
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes3.dex */
|
|
public class Column extends ArrayMap<R, V> {
|
|
final int columnIndex;
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
String getKeyRole() {
|
|
return "Row";
|
|
}
|
|
|
|
Column(int i) {
|
|
super(ArrayTable.this.rowKeyToIndex);
|
|
this.columnIndex = i;
|
|
}
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
@CheckForNull
|
|
V getValue(int i) {
|
|
return (V) ArrayTable.this.at(i, this.columnIndex);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
@CheckForNull
|
|
V setValue(int i, @CheckForNull V v) {
|
|
return (V) ArrayTable.this.set(i, this.columnIndex, v);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public ImmutableSet<C> columnKeySet() {
|
|
return this.columnKeyToIndex.keySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table
|
|
public Map<C, Map<R, V>> columnMap() {
|
|
ArrayTable<R, C, V>.ColumnMap columnMap = this.columnMap;
|
|
if (columnMap != null) {
|
|
return columnMap;
|
|
}
|
|
ArrayTable<R, C, V>.ColumnMap columnMap2 = new ColumnMap();
|
|
this.columnMap = columnMap2;
|
|
return columnMap2;
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
private class ColumnMap extends ArrayMap<C, Map<R, V>> {
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
String getKeyRole() {
|
|
return "Column";
|
|
}
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap, java.util.AbstractMap, java.util.Map
|
|
@CheckForNull
|
|
public /* bridge */ /* synthetic */ Object put(Object obj, Object obj2) {
|
|
return put((ColumnMap) obj, (Map) obj2);
|
|
}
|
|
|
|
private ColumnMap() {
|
|
super(ArrayTable.this.columnKeyToIndex);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
public Map<R, V> getValue(int i) {
|
|
return new Column(i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
public Map<R, V> setValue(int i, Map<R, V> map) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@CheckForNull
|
|
public Map<R, V> put(C c, Map<R, V> map) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table
|
|
public Map<C, V> row(R r) {
|
|
Preconditions.checkNotNull(r);
|
|
Integer num = this.rowKeyToIndex.get(r);
|
|
if (num == null) {
|
|
return Collections.emptyMap();
|
|
}
|
|
return new Row(num.intValue());
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes3.dex */
|
|
public class Row extends ArrayMap<C, V> {
|
|
final int rowIndex;
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
String getKeyRole() {
|
|
return "Column";
|
|
}
|
|
|
|
Row(int i) {
|
|
super(ArrayTable.this.columnKeyToIndex);
|
|
this.rowIndex = i;
|
|
}
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
@CheckForNull
|
|
V getValue(int i) {
|
|
return (V) ArrayTable.this.at(this.rowIndex, i);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
@CheckForNull
|
|
V setValue(int i, @CheckForNull V v) {
|
|
return (V) ArrayTable.this.set(this.rowIndex, i, v);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public ImmutableSet<R> rowKeySet() {
|
|
return this.rowKeyToIndex.keySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table
|
|
public Map<R, Map<C, V>> rowMap() {
|
|
ArrayTable<R, C, V>.RowMap rowMap = this.rowMap;
|
|
if (rowMap != null) {
|
|
return rowMap;
|
|
}
|
|
ArrayTable<R, C, V>.RowMap rowMap2 = new RowMap();
|
|
this.rowMap = rowMap2;
|
|
return rowMap2;
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
private class RowMap extends ArrayMap<R, Map<C, V>> {
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
String getKeyRole() {
|
|
return "Row";
|
|
}
|
|
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap, java.util.AbstractMap, java.util.Map
|
|
@CheckForNull
|
|
public /* bridge */ /* synthetic */ Object put(Object obj, Object obj2) {
|
|
return put((RowMap) obj, (Map) obj2);
|
|
}
|
|
|
|
private RowMap() {
|
|
super(ArrayTable.this.rowKeyToIndex);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
public Map<C, V> getValue(int i) {
|
|
return new Row(i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ArrayTable.ArrayMap
|
|
public Map<C, V> setValue(int i, Map<C, V> map) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@CheckForNull
|
|
public Map<C, V> put(R r, Map<C, V> map) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public Collection<V> values() {
|
|
return super.values();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
Iterator<V> valuesIterator() {
|
|
return new AbstractIndexedListIterator<V>(size()) { // from class: com.google.common.collect.ArrayTable.3
|
|
@Override // com.google.common.collect.AbstractIndexedListIterator
|
|
@CheckForNull
|
|
protected V get(int i) {
|
|
return (V) ArrayTable.this.getValue(i);
|
|
}
|
|
};
|
|
}
|
|
}
|