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.util.LinkedHashMap; import java.util.Map; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class SparseImmutableTable extends RegularImmutableTable { static final ImmutableTable EMPTY = new SparseImmutableTable(ImmutableList.of(), ImmutableSet.of(), ImmutableSet.of()); private final int[] cellColumnInRowIndices; private final int[] cellRowIndices; private final ImmutableMap> columnMap; private final ImmutableMap> rowMap; @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 */ /* JADX WARN: Multi-variable type inference failed */ public SparseImmutableTable(ImmutableList> immutableList, ImmutableSet immutableSet, ImmutableSet immutableSet2) { ImmutableMap indexMap = Maps.indexMap(immutableSet); LinkedHashMap newLinkedHashMap = Maps.newLinkedHashMap(); UnmodifiableIterator it = immutableSet.iterator(); while (it.hasNext()) { newLinkedHashMap.put(it.next(), new LinkedHashMap()); } LinkedHashMap newLinkedHashMap2 = Maps.newLinkedHashMap(); UnmodifiableIterator it2 = immutableSet2.iterator(); while (it2.hasNext()) { newLinkedHashMap2.put(it2.next(), new LinkedHashMap()); } 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(); V value = cell.getValue(); iArr[i] = ((Integer) indexMap.get(rowKey)).intValue(); Map map = (Map) newLinkedHashMap.get(rowKey); iArr2[i] = map.size(); checkNoDuplicate(rowKey, columnKey, map.put(columnKey, value), value); ((Map) newLinkedHashMap2.get(columnKey)).put(rowKey, value); } this.cellRowIndices = iArr; this.cellColumnInRowIndices = iArr2; ImmutableMap.Builder builder = new ImmutableMap.Builder(newLinkedHashMap.size()); for (Map.Entry entry : newLinkedHashMap.entrySet()) { builder.put(entry.getKey(), ImmutableMap.copyOf((Map) entry.getValue())); } this.rowMap = builder.build(); ImmutableMap.Builder builder2 = new ImmutableMap.Builder(newLinkedHashMap2.size()); for (Map.Entry entry2 : newLinkedHashMap2.entrySet()) { builder2.put(entry2.getKey(), ImmutableMap.copyOf((Map) entry2.getValue())); } this.columnMap = builder2.build(); } @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.Table public final int size() { return this.cellRowIndices.length; } @Override // com.google.common.collect.RegularImmutableTable final Table.Cell getCell(int i) { Map.Entry> entry = this.rowMap.entrySet().asList().get(this.cellRowIndices[i]); ImmutableMap value = entry.getValue(); Map.Entry entry2 = value.entrySet().asList().get(this.cellColumnInRowIndices[i]); return cellOf(entry.getKey(), entry2.getKey(), entry2.getValue()); } @Override // com.google.common.collect.RegularImmutableTable final V getValue(int i) { ImmutableMap immutableMap = this.rowMap.values().asList().get(this.cellRowIndices[i]); return immutableMap.values().asList().get(this.cellColumnInRowIndices[i]); } @Override // com.google.common.collect.ImmutableTable final ImmutableTable.SerializedForm createSerializedForm() { ImmutableMap indexMap = Maps.indexMap(columnKeySet()); int[] iArr = new int[cellSet().size()]; UnmodifiableIterator> it = cellSet().iterator(); int i = 0; while (it.hasNext()) { iArr[i] = ((Integer) indexMap.get(it.next().getColumnKey())).intValue(); i++; } return ImmutableTable.SerializedForm.create(this, this.cellRowIndices, iArr); } }