package com.google.common.collect; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableTable; import com.google.common.collect.Table; import java.lang.reflect.Array; import java.util.Map; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class DenseImmutableTable extends RegularImmutableTable { private final int[] cellColumnIndices; private final int[] cellRowIndices; private final int[] columnCounts; private final ImmutableMap columnKeyToIndex; private final ImmutableMap> columnMap; private final int[] rowCounts; private final ImmutableMap rowKeyToIndex; private final ImmutableMap> rowMap; private final V[][] values; @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.Table public final /* bridge */ /* synthetic */ Map columnMap() { return columnMap(); } @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.Table public final /* bridge */ /* synthetic */ Map rowMap() { return rowMap(); } /* JADX INFO: Access modifiers changed from: package-private */ public DenseImmutableTable(ImmutableList> immutableList, ImmutableSet immutableSet, ImmutableSet immutableSet2) { this.values = (V[][]) ((Object[][]) Array.newInstance((Class) Object.class, immutableSet.size(), immutableSet2.size())); ImmutableMap indexMap = Maps.indexMap(immutableSet); this.rowKeyToIndex = indexMap; ImmutableMap indexMap2 = Maps.indexMap(immutableSet2); this.columnKeyToIndex = indexMap2; this.rowCounts = new int[indexMap.size()]; this.columnCounts = new int[indexMap2.size()]; int[] iArr = new int[immutableList.size()]; int[] iArr2 = new int[immutableList.size()]; for (int i = 0; i < immutableList.size(); i++) { Table.Cell cell = immutableList.get(i); R rowKey = cell.getRowKey(); C columnKey = cell.getColumnKey(); int intValue = this.rowKeyToIndex.get(rowKey).intValue(); int intValue2 = this.columnKeyToIndex.get(columnKey).intValue(); checkNoDuplicate(rowKey, columnKey, this.values[intValue][intValue2], cell.getValue()); this.values[intValue][intValue2] = cell.getValue(); int[] iArr3 = this.rowCounts; iArr3[intValue] = iArr3[intValue] + 1; int[] iArr4 = this.columnCounts; iArr4[intValue2] = iArr4[intValue2] + 1; iArr[i] = intValue; iArr2[i] = intValue2; } this.cellRowIndices = iArr; this.cellColumnIndices = iArr2; this.rowMap = new RowMap(); this.columnMap = new ColumnMap(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static abstract class ImmutableArrayMap extends ImmutableMap.IteratorBasedImmutableMap { private final int size; abstract V getValue(int i); abstract ImmutableMap keyToIndex(); ImmutableArrayMap(int i) { this.size = i; } private boolean isFull() { return this.size == keyToIndex().size(); } K getKey(int i) { return keyToIndex().keySet().asList().get(i); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap, com.google.common.collect.ImmutableMap public ImmutableSet createKeySet() { return isFull() ? keyToIndex().keySet() : super.createKeySet(); } @Override // com.google.common.collect.ImmutableMap, java.util.Map public V get(Object obj) { Integer num = keyToIndex().get(obj); if (num == null) { return null; } return getValue(num.intValue()); } @Override // com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap UnmodifiableIterator> entryIterator() { return new AbstractIterator>(this) { // from class: com.google.common.collect.DenseImmutableTable.ImmutableArrayMap.1 private int index = -1; private final int maxIndex; final ImmutableArrayMap this$0; { this.this$0 = this; this.maxIndex = this.keyToIndex().size(); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractIterator public Map.Entry computeNext() { int i = this.index; while (true) { int i2 = i + 1; this.index = i2; if (i2 < this.maxIndex) { Object value = this.this$0.getValue(i2); if (value != null) { return Maps.immutableEntry(this.this$0.getKey(this.index), value); } i = this.index; } else { return endOfData(); } } } }; } @Override // java.util.Map public int size() { return this.size; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class Row extends ImmutableArrayMap { private final int rowIndex; final DenseImmutableTable this$0; /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableMap public final boolean isPartialView() { return true; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ Row(DenseImmutableTable denseImmutableTable, int i) { super(denseImmutableTable.rowCounts[i]); this.this$0 = denseImmutableTable; this.rowIndex = i; } @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap final ImmutableMap keyToIndex() { return this.this$0.columnKeyToIndex; } @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap final V getValue(int i) { return (V) this.this$0.values[this.rowIndex][i]; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class Column extends ImmutableArrayMap { private final int columnIndex; final DenseImmutableTable this$0; /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableMap public final boolean isPartialView() { return true; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ Column(DenseImmutableTable denseImmutableTable, int i) { super(denseImmutableTable.columnCounts[i]); this.this$0 = denseImmutableTable; this.columnIndex = i; } @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap final ImmutableMap keyToIndex() { return this.this$0.rowKeyToIndex; } @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap final V getValue(int i) { return (V) this.this$0.values[i][this.columnIndex]; } } /* loaded from: classes2.dex */ final class RowMap extends ImmutableArrayMap> { final DenseImmutableTable this$0; /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableMap public final boolean isPartialView() { return false; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ private RowMap(DenseImmutableTable denseImmutableTable) { super(denseImmutableTable.rowCounts.length); this.this$0 = denseImmutableTable; } @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap final ImmutableMap keyToIndex() { return this.this$0.rowKeyToIndex; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap public final ImmutableMap getValue(int i) { return new Row(this.this$0, i); } } /* loaded from: classes2.dex */ final class ColumnMap extends ImmutableArrayMap> { final DenseImmutableTable this$0; /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableMap public final boolean isPartialView() { return false; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ private ColumnMap(DenseImmutableTable denseImmutableTable) { super(denseImmutableTable.columnCounts.length); this.this$0 = denseImmutableTable; } @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap final ImmutableMap keyToIndex() { return this.this$0.columnKeyToIndex; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.DenseImmutableTable.ImmutableArrayMap public final ImmutableMap getValue(int i) { return new Column(this.this$0, i); } } @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.Table public final ImmutableMap> columnMap() { return ImmutableMap.copyOf((Map) this.columnMap); } @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.Table public final ImmutableMap> rowMap() { return ImmutableMap.copyOf((Map) this.rowMap); } @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.AbstractTable, com.google.common.collect.Table public final V get(Object obj, Object obj2) { Integer num = this.rowKeyToIndex.get(obj); Integer num2 = this.columnKeyToIndex.get(obj2); if (num == null || num2 == null) { return null; } return this.values[num.intValue()][num2.intValue()]; } @Override // com.google.common.collect.Table public final int size() { return this.cellRowIndices.length; } @Override // com.google.common.collect.RegularImmutableTable final Table.Cell getCell(int i) { int i2 = this.cellRowIndices[i]; int i3 = this.cellColumnIndices[i]; return cellOf(rowKeySet().asList().get(i2), columnKeySet().asList().get(i3), this.values[i2][i3]); } @Override // com.google.common.collect.RegularImmutableTable final V getValue(int i) { return this.values[this.cellRowIndices[i]][this.cellColumnIndices[i]]; } @Override // com.google.common.collect.ImmutableTable final ImmutableTable.SerializedForm createSerializedForm() { return ImmutableTable.SerializedForm.create(this, this.cellRowIndices, this.cellColumnIndices); } }