package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Table; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashSet; import java.util.List; /* loaded from: classes.dex */ abstract class RegularImmutableTable extends ImmutableTable { private final class CellSet extends ImmutableSet.Indexed> { private CellSet() { } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { if (!(obj instanceof Table.Cell)) { return false; } Table.Cell cell = (Table.Cell) obj; Object obj2 = RegularImmutableTable.this.get(cell.b(), cell.a()); return obj2 != null && obj2.equals(cell.getValue()); } @Override // com.google.common.collect.ImmutableCollection boolean isPartialView() { return false; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return RegularImmutableTable.this.size(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableSet.Indexed public Table.Cell get(int i) { return RegularImmutableTable.this.getCell(i); } } private final class Values extends ImmutableList { private Values() { } @Override // java.util.List public V get(int i) { return (V) RegularImmutableTable.this.getValue(i); } @Override // com.google.common.collect.ImmutableCollection boolean isPartialView() { return true; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.List public int size() { return RegularImmutableTable.this.size(); } } RegularImmutableTable() { } static RegularImmutableTable a(List> list, final Comparator comparator, final Comparator comparator2) { Preconditions.a(list); if (comparator != null || comparator2 != null) { Collections.sort(list, new Comparator>() { // from class: com.google.common.collect.RegularImmutableTable.1 @Override // java.util.Comparator /* renamed from: a, reason: merged with bridge method [inline-methods] */ public int compare(Table.Cell cell, Table.Cell cell2) { Comparator comparator3 = comparator; int compare = comparator3 == null ? 0 : comparator3.compare(cell.b(), cell2.b()); if (compare != 0) { return compare; } Comparator comparator4 = comparator2; if (comparator4 == null) { return 0; } return comparator4.compare(cell.a(), cell2.a()); } }); } return a((Iterable) list, (Comparator) comparator, (Comparator) comparator2); } abstract Table.Cell getCell(int i); abstract V getValue(int i); /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.AbstractTable public final ImmutableSet> createCellSet() { return isEmpty() ? ImmutableSet.of() : new CellSet(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableTable, com.google.common.collect.AbstractTable public final ImmutableCollection createValues() { return isEmpty() ? ImmutableList.of() : new Values(); } private static final RegularImmutableTable a(Iterable> iterable, Comparator comparator, Comparator comparator2) { ImmutableSet copyOf; ImmutableSet copyOf2; LinkedHashSet linkedHashSet = new LinkedHashSet(); LinkedHashSet linkedHashSet2 = new LinkedHashSet(); ImmutableList copyOf3 = ImmutableList.copyOf(iterable); for (Table.Cell cell : iterable) { linkedHashSet.add(cell.b()); linkedHashSet2.add(cell.a()); } if (comparator == null) { copyOf = ImmutableSet.copyOf((Collection) linkedHashSet); } else { copyOf = ImmutableSet.copyOf((Collection) ImmutableList.sortedCopyOf(comparator, linkedHashSet)); } if (comparator2 == null) { copyOf2 = ImmutableSet.copyOf((Collection) linkedHashSet2); } else { copyOf2 = ImmutableSet.copyOf((Collection) ImmutableList.sortedCopyOf(comparator2, linkedHashSet2)); } return a(copyOf3, copyOf, copyOf2); } static RegularImmutableTable a(ImmutableList> immutableList, ImmutableSet immutableSet, ImmutableSet immutableSet2) { return ((long) immutableList.size()) > (((long) immutableSet.size()) * ((long) immutableSet2.size())) / 2 ? new DenseImmutableTable(immutableList, immutableSet, immutableSet2) : new SparseImmutableTable(immutableList, immutableSet, immutableSet2); } }