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; /* loaded from: classes.dex */ final class SparseImmutableTable extends RegularImmutableTable { static final ImmutableTable e = new SparseImmutableTable(ImmutableList.of(), ImmutableSet.of(), ImmutableSet.of()); private final ImmutableMap> a; private final ImmutableMap> b; private final int[] c; private final int[] d; SparseImmutableTable(ImmutableList> immutableList, ImmutableSet immutableSet, ImmutableSet immutableSet2) { ImmutableMap a = Maps.a(immutableSet); LinkedHashMap c = Maps.c(); UnmodifiableIterator it = immutableSet.iterator(); while (it.hasNext()) { c.put(it.next(), new LinkedHashMap()); } LinkedHashMap c2 = Maps.c(); UnmodifiableIterator it2 = immutableSet2.iterator(); while (it2.hasNext()) { c2.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 b = cell.b(); C a2 = cell.a(); V value = cell.getValue(); iArr[i] = ((Integer) a.get(b)).intValue(); Map map = (Map) c.get(b); iArr2[i] = map.size(); Object put = map.put(a2, value); if (put != null) { throw new IllegalArgumentException("Duplicate value for row=" + b + ", column=" + a2 + ": " + value + ", " + put); } ((Map) c2.get(a2)).put(b, value); } this.c = iArr; this.d = iArr2; ImmutableMap.Builder builder = new ImmutableMap.Builder(c.size()); for (Map.Entry entry : c.entrySet()) { builder.a(entry.getKey(), ImmutableMap.copyOf((Map) entry.getValue())); } this.a = builder.a(); ImmutableMap.Builder builder2 = new ImmutableMap.Builder(c2.size()); for (Map.Entry entry2 : c2.entrySet()) { builder2.a(entry2.getKey(), ImmutableMap.copyOf((Map) entry2.getValue())); } this.b = builder2.a(); } @Override // com.google.common.collect.ImmutableTable ImmutableTable.SerializedForm createSerializedForm() { ImmutableMap a = Maps.a(columnKeySet()); int[] iArr = new int[cellSet().size()]; UnmodifiableIterator> it = cellSet().iterator(); int i = 0; while (it.hasNext()) { iArr[i] = ((Integer) a.get(it.next().a())).intValue(); i++; } return ImmutableTable.SerializedForm.a(this, this.c, iArr); } @Override // com.google.common.collect.RegularImmutableTable Table.Cell getCell(int i) { Map.Entry> entry = this.a.entrySet().asList().get(this.c[i]); ImmutableMap immutableMap = (ImmutableMap) entry.getValue(); Map.Entry entry2 = (Map.Entry) immutableMap.entrySet().asList().get(this.d[i]); return ImmutableTable.cellOf(entry.getKey(), entry2.getKey(), entry2.getValue()); } @Override // com.google.common.collect.RegularImmutableTable V getValue(int i) { ImmutableMap immutableMap = (ImmutableMap) this.a.values().asList().get(this.c[i]); return immutableMap.values().asList().get(this.d[i]); } @Override // com.google.common.collect.Table public int size() { return this.c.length; } @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.Table public ImmutableMap> columnMap() { return this.b; } @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.Table public ImmutableMap> rowMap() { return this.a; } }