Rabbit-R1/switch port/java/sources/com/google/common/collect/StandardTable.java
2024-05-21 17:08:36 -04:00

1006 lines
39 KiB
Java

package com.google.common.collect;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Supplier;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.collect.Table;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.annotation.CheckForNull;
/* JADX INFO: Access modifiers changed from: package-private */
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
public class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
private static final long serialVersionUID = 0;
@GwtTransient
final Map<R, Map<C, V>> backingMap;
@CheckForNull
private transient Set<C> columnKeySet;
@CheckForNull
private transient StandardTable<R, C, V>.ColumnMap columnMap;
@GwtTransient
final Supplier<? extends Map<C, V>> factory;
@CheckForNull
private transient Map<R, Map<C, V>> rowMap;
/* JADX INFO: Access modifiers changed from: package-private */
public StandardTable(Map<R, Map<C, V>> map, Supplier<? extends Map<C, V>> supplier) {
this.backingMap = map;
this.factory = supplier;
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public boolean contains(@CheckForNull Object obj, @CheckForNull Object obj2) {
return (obj == null || obj2 == null || !super.contains(obj, obj2)) ? false : true;
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public boolean containsColumn(@CheckForNull Object obj) {
if (obj == null) {
return false;
}
Iterator<Map<C, V>> it = this.backingMap.values().iterator();
while (it.hasNext()) {
if (Maps.safeContainsKey(it.next(), obj)) {
return true;
}
}
return false;
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public boolean containsRow(@CheckForNull Object obj) {
return obj != null && Maps.safeContainsKey(this.backingMap, obj);
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public boolean containsValue(@CheckForNull Object obj) {
return obj != null && super.containsValue(obj);
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
@CheckForNull
public V get(@CheckForNull Object obj, @CheckForNull Object obj2) {
if (obj == null || obj2 == null) {
return null;
}
return (V) super.get(obj, obj2);
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public boolean isEmpty() {
return this.backingMap.isEmpty();
}
@Override // com.google.common.collect.Table
public int size() {
Iterator<Map<C, V>> it = this.backingMap.values().iterator();
int i = 0;
while (it.hasNext()) {
i += it.next().size();
}
return i;
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public void clear() {
this.backingMap.clear();
}
private Map<C, V> getOrCreate(R r) {
Map<C, V> map = this.backingMap.get(r);
if (map != null) {
return map;
}
Map<C, V> map2 = this.factory.get();
this.backingMap.put(r, map2);
return map2;
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
@CheckForNull
public V put(R r, C c, V v) {
Preconditions.checkNotNull(r);
Preconditions.checkNotNull(c);
Preconditions.checkNotNull(v);
return getOrCreate(r).put(c, v);
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
@CheckForNull
public V remove(@CheckForNull Object obj, @CheckForNull Object obj2) {
Map map;
if (obj == null || obj2 == null || (map = (Map) Maps.safeGet(this.backingMap, obj)) == null) {
return null;
}
V v = (V) map.remove(obj2);
if (map.isEmpty()) {
this.backingMap.remove(obj);
}
return v;
}
/* JADX INFO: Access modifiers changed from: private */
public Map<R, V> removeColumn(@CheckForNull Object obj) {
LinkedHashMap linkedHashMap = new LinkedHashMap();
Iterator<Map.Entry<R, Map<C, V>>> it = this.backingMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<R, Map<C, V>> next = it.next();
V remove = next.getValue().remove(obj);
if (remove != null) {
linkedHashMap.put(next.getKey(), remove);
if (next.getValue().isEmpty()) {
it.remove();
}
}
}
return linkedHashMap;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean containsMapping(@CheckForNull Object obj, @CheckForNull Object obj2, @CheckForNull Object obj3) {
return obj3 != null && obj3.equals(get(obj, obj2));
}
/* JADX INFO: Access modifiers changed from: private */
public boolean removeMapping(@CheckForNull Object obj, @CheckForNull Object obj2, @CheckForNull Object obj3) {
if (!containsMapping(obj, obj2, obj3)) {
return false;
}
remove(obj, obj2);
return true;
}
/* loaded from: classes3.dex */
private abstract class TableSet<T> extends Sets.ImprovedAbstractSet<T> {
private TableSet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean isEmpty() {
return StandardTable.this.backingMap.isEmpty();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
StandardTable.this.backingMap.clear();
}
}
@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 CellIterator();
}
/* loaded from: classes3.dex */
private class CellIterator implements Iterator<Table.Cell<R, C, V>> {
Iterator<Map.Entry<C, V>> columnIterator;
@CheckForNull
Map.Entry<R, Map<C, V>> rowEntry;
final Iterator<Map.Entry<R, Map<C, V>>> rowIterator;
private CellIterator() {
this.rowIterator = StandardTable.this.backingMap.entrySet().iterator();
this.columnIterator = Iterators.emptyModifiableIterator();
}
@Override // java.util.Iterator
public boolean hasNext() {
return this.rowIterator.hasNext() || this.columnIterator.hasNext();
}
@Override // java.util.Iterator
public Table.Cell<R, C, V> next() {
if (!this.columnIterator.hasNext()) {
Map.Entry<R, Map<C, V>> next = this.rowIterator.next();
this.rowEntry = next;
this.columnIterator = next.getValue().entrySet().iterator();
}
Objects.requireNonNull(this.rowEntry);
Map.Entry<C, V> next2 = this.columnIterator.next();
return Tables.immutableCell(this.rowEntry.getKey(), next2.getKey(), next2.getValue());
}
@Override // java.util.Iterator
public void remove() {
this.columnIterator.remove();
if (((Map) ((Map.Entry) Objects.requireNonNull(this.rowEntry)).getValue()).isEmpty()) {
this.rowIterator.remove();
this.rowEntry = null;
}
}
}
@Override // com.google.common.collect.Table
public Map<C, V> row(R r) {
return new Row(r);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class Row extends Maps.IteratorBasedAbstractMap<C, V> {
@CheckForNull
Map<C, V> backingRowMap;
final R rowKey;
/* JADX INFO: Access modifiers changed from: package-private */
public Row(R r) {
this.rowKey = (R) Preconditions.checkNotNull(r);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void updateBackingRowMapField() {
Map<C, V> map = this.backingRowMap;
if (map == null || (map.isEmpty() && StandardTable.this.backingMap.containsKey(this.rowKey))) {
this.backingRowMap = computeBackingRowMap();
}
}
@CheckForNull
Map<C, V> computeBackingRowMap() {
return StandardTable.this.backingMap.get(this.rowKey);
}
void maintainEmptyInvariant() {
updateBackingRowMapField();
Map<C, V> map = this.backingRowMap;
if (map == null || !map.isEmpty()) {
return;
}
StandardTable.this.backingMap.remove(this.rowKey);
this.backingRowMap = null;
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(@CheckForNull Object obj) {
Map<C, V> map;
updateBackingRowMapField();
return (obj == null || (map = this.backingRowMap) == null || !Maps.safeContainsKey(map, obj)) ? false : true;
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public V get(@CheckForNull Object obj) {
Map<C, V> map;
updateBackingRowMapField();
if (obj == null || (map = this.backingRowMap) == null) {
return null;
}
return (V) Maps.safeGet(map, obj);
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public V put(C c, V v) {
Preconditions.checkNotNull(c);
Preconditions.checkNotNull(v);
Map<C, V> map = this.backingRowMap;
if (map != null && !map.isEmpty()) {
return this.backingRowMap.put(c, v);
}
return (V) StandardTable.this.put(this.rowKey, c, v);
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public V remove(@CheckForNull Object obj) {
updateBackingRowMapField();
Map<C, V> map = this.backingRowMap;
if (map == null) {
return null;
}
V v = (V) Maps.safeRemove(map, obj);
maintainEmptyInvariant();
return v;
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public void clear() {
updateBackingRowMapField();
Map<C, V> map = this.backingRowMap;
if (map != null) {
map.clear();
}
maintainEmptyInvariant();
}
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
public int size() {
updateBackingRowMapField();
Map<C, V> map = this.backingRowMap;
if (map == null) {
return 0;
}
return map.size();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap
public Iterator<Map.Entry<C, V>> entryIterator() {
updateBackingRowMapField();
Map<C, V> map = this.backingRowMap;
if (map == null) {
return Iterators.emptyModifiableIterator();
}
final Iterator<Map.Entry<C, V>> it = map.entrySet().iterator();
return new Iterator<Map.Entry<C, V>>() { // from class: com.google.common.collect.StandardTable.Row.1
@Override // java.util.Iterator
public boolean hasNext() {
return it.hasNext();
}
@Override // java.util.Iterator
public Map.Entry<C, V> next() {
return Row.this.wrapEntry((Map.Entry) it.next());
}
@Override // java.util.Iterator
public void remove() {
it.remove();
Row.this.maintainEmptyInvariant();
}
};
}
Map.Entry<C, V> wrapEntry(final Map.Entry<C, V> entry) {
return new ForwardingMapEntry<C, V>(this) { // from class: com.google.common.collect.StandardTable.Row.2
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.ForwardingMapEntry, com.google.common.collect.ForwardingObject
public Map.Entry<C, V> delegate() {
return entry;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.ForwardingMapEntry, java.util.Map.Entry
public V setValue(V v) {
return (V) super.setValue(Preconditions.checkNotNull(v));
}
@Override // com.google.common.collect.ForwardingMapEntry, java.util.Map.Entry
public boolean equals(@CheckForNull Object obj) {
return standardEquals(obj);
}
};
}
}
@Override // com.google.common.collect.Table
public Map<R, V> column(C c) {
return new Column(c);
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public class Column extends Maps.ViewCachingAbstractMap<R, V> {
final C columnKey;
Column(C c) {
this.columnKey = (C) Preconditions.checkNotNull(c);
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public V put(R r, V v) {
return (V) StandardTable.this.put(r, this.columnKey, v);
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public V get(@CheckForNull Object obj) {
return (V) StandardTable.this.get(obj, this.columnKey);
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(@CheckForNull Object obj) {
return StandardTable.this.contains(obj, this.columnKey);
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public V remove(@CheckForNull Object obj) {
return (V) StandardTable.this.remove(obj, this.columnKey);
}
boolean removeFromColumnIf(Predicate<? super Map.Entry<R, V>> predicate) {
Iterator<Map.Entry<R, Map<C, V>>> it = StandardTable.this.backingMap.entrySet().iterator();
boolean z = false;
while (it.hasNext()) {
Map.Entry<R, Map<C, V>> next = it.next();
Map<C, V> value = next.getValue();
V v = value.get(this.columnKey);
if (v != null && predicate.apply(Maps.immutableEntry(next.getKey(), v))) {
value.remove(this.columnKey);
if (value.isEmpty()) {
it.remove();
}
z = true;
}
}
return z;
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Set<Map.Entry<R, V>> createEntrySet() {
return new EntrySet();
}
/* loaded from: classes3.dex */
private class EntrySet extends Sets.ImprovedAbstractSet<Map.Entry<R, V>> {
private EntrySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<R, V>> iterator() {
return new EntrySetIterator();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
Iterator<Map<C, V>> it = StandardTable.this.backingMap.values().iterator();
int i = 0;
while (it.hasNext()) {
if (it.next().containsKey(Column.this.columnKey)) {
i++;
}
}
return i;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean isEmpty() {
return !StandardTable.this.containsColumn(Column.this.columnKey);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
Column.this.removeFromColumnIf(Predicates.alwaysTrue());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(@CheckForNull Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return StandardTable.this.containsMapping(entry.getKey(), Column.this.columnKey, entry.getValue());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(@CheckForNull Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return StandardTable.this.removeMapping(entry.getKey(), Column.this.columnKey, entry.getValue());
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
return Column.this.removeFromColumnIf(Predicates.not(Predicates.in(collection)));
}
}
/* loaded from: classes3.dex */
private class EntrySetIterator extends AbstractIterator<Map.Entry<R, V>> {
final Iterator<Map.Entry<R, Map<C, V>>> iterator;
private EntrySetIterator() {
this.iterator = StandardTable.this.backingMap.entrySet().iterator();
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.collect.AbstractIterator
@CheckForNull
public Map.Entry<R, V> computeNext() {
while (this.iterator.hasNext()) {
final Map.Entry<R, Map<C, V>> next = this.iterator.next();
if (next.getValue().containsKey(Column.this.columnKey)) {
return new AbstractMapEntry<R, V>() { // from class: com.google.common.collect.StandardTable.Column.EntrySetIterator.1EntryImpl
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public R getKey() {
return (R) next.getKey();
}
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public V getValue() {
return (V) ((Map) next.getValue()).get(Column.this.columnKey);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
public V setValue(V v) {
return (V) NullnessCasts.uncheckedCastNullableTToT(((Map) next.getValue()).put(Column.this.columnKey, Preconditions.checkNotNull(v)));
}
};
}
}
return endOfData();
}
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Set<R> createKeySet() {
return new KeySet();
}
/* loaded from: classes3.dex */
private class KeySet extends Maps.KeySet<R, V> {
KeySet() {
super(Column.this);
}
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(@CheckForNull Object obj) {
return StandardTable.this.contains(obj, Column.this.columnKey);
}
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(@CheckForNull Object obj) {
return StandardTable.this.remove(obj, Column.this.columnKey) != null;
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
return Column.this.removeFromColumnIf(Maps.keyPredicateOnEntries(Predicates.not(Predicates.in(collection))));
}
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Collection<V> createValues() {
return new Values();
}
/* loaded from: classes3.dex */
private class Values extends Maps.Values<R, V> {
Values() {
super(Column.this);
}
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public boolean remove(@CheckForNull Object obj) {
return obj != null && Column.this.removeFromColumnIf(Maps.valuePredicateOnEntries(Predicates.equalTo(obj)));
}
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public boolean removeAll(Collection<?> collection) {
return Column.this.removeFromColumnIf(Maps.valuePredicateOnEntries(Predicates.in(collection)));
}
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public boolean retainAll(Collection<?> collection) {
return Column.this.removeFromColumnIf(Maps.valuePredicateOnEntries(Predicates.not(Predicates.in(collection))));
}
}
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public Set<R> rowKeySet() {
return rowMap().keySet();
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public Set<C> columnKeySet() {
Set<C> set = this.columnKeySet;
if (set != null) {
return set;
}
ColumnKeySet columnKeySet = new ColumnKeySet();
this.columnKeySet = columnKeySet;
return columnKeySet;
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public class ColumnKeySet extends StandardTable<R, C, V>.TableSet<C> {
private ColumnKeySet() {
super();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<C> iterator() {
return StandardTable.this.createColumnKeyIterator();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return Iterators.size(iterator());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(@CheckForNull Object obj) {
boolean z = false;
if (obj == null) {
return false;
}
Iterator<Map<C, V>> it = StandardTable.this.backingMap.values().iterator();
while (it.hasNext()) {
Map<C, V> next = it.next();
if (next.keySet().remove(obj)) {
if (next.isEmpty()) {
it.remove();
}
z = true;
}
}
return z;
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean removeAll(Collection<?> collection) {
Preconditions.checkNotNull(collection);
Iterator<Map<C, V>> it = StandardTable.this.backingMap.values().iterator();
boolean z = false;
while (it.hasNext()) {
Map<C, V> next = it.next();
if (Iterators.removeAll(next.keySet().iterator(), collection)) {
if (next.isEmpty()) {
it.remove();
}
z = true;
}
}
return z;
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
Preconditions.checkNotNull(collection);
Iterator<Map<C, V>> it = StandardTable.this.backingMap.values().iterator();
boolean z = false;
while (it.hasNext()) {
Map<C, V> next = it.next();
if (next.keySet().retainAll(collection)) {
if (next.isEmpty()) {
it.remove();
}
z = true;
}
}
return z;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(@CheckForNull Object obj) {
return StandardTable.this.containsColumn(obj);
}
}
Iterator<C> createColumnKeyIterator() {
return new ColumnKeyIterator();
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public class ColumnKeyIterator extends AbstractIterator<C> {
Iterator<Map.Entry<C, V>> entryIterator;
final Iterator<Map<C, V>> mapIterator;
final Map<C, V> seen;
private ColumnKeyIterator() {
this.seen = StandardTable.this.factory.get();
this.mapIterator = StandardTable.this.backingMap.values().iterator();
this.entryIterator = Iterators.emptyIterator();
}
@Override // com.google.common.collect.AbstractIterator
@CheckForNull
protected C computeNext() {
while (true) {
if (this.entryIterator.hasNext()) {
Map.Entry<C, V> next = this.entryIterator.next();
if (!this.seen.containsKey(next.getKey())) {
this.seen.put(next.getKey(), next.getValue());
return next.getKey();
}
} else if (this.mapIterator.hasNext()) {
this.entryIterator = this.mapIterator.next().entrySet().iterator();
} else {
return endOfData();
}
}
}
}
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
public Collection<V> values() {
return super.values();
}
@Override // com.google.common.collect.Table
public Map<R, Map<C, V>> rowMap() {
Map<R, Map<C, V>> map = this.rowMap;
if (map != null) {
return map;
}
Map<R, Map<C, V>> createRowMap = createRowMap();
this.rowMap = createRowMap;
return createRowMap;
}
Map<R, Map<C, V>> createRowMap() {
return new RowMap();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class RowMap extends Maps.ViewCachingAbstractMap<R, Map<C, V>> {
/* JADX INFO: Access modifiers changed from: package-private */
public RowMap() {
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(@CheckForNull Object obj) {
return StandardTable.this.containsRow(obj);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public Map<C, V> get(@CheckForNull Object obj) {
if (StandardTable.this.containsRow(obj)) {
return StandardTable.this.row(Objects.requireNonNull(obj));
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public Map<C, V> remove(@CheckForNull Object obj) {
if (obj == null) {
return null;
}
return StandardTable.this.backingMap.remove(obj);
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
protected Set<Map.Entry<R, Map<C, V>>> createEntrySet() {
return new EntrySet();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class EntrySet extends StandardTable<R, C, V>.TableSet<Map.Entry<R, Map<C, V>>> {
EntrySet() {
super();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<R, Map<C, V>>> iterator() {
return Maps.asMapEntryIterator(StandardTable.this.backingMap.keySet(), new Function<R, Map<C, V>>() { // from class: com.google.common.collect.StandardTable.RowMap.EntrySet.1
@Override // com.google.common.base.Function
public /* bridge */ /* synthetic */ Object apply(Object obj) {
return apply((AnonymousClass1) obj);
}
@Override // com.google.common.base.Function
public Map<C, V> apply(R r) {
return StandardTable.this.row(r);
}
});
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return StandardTable.this.backingMap.size();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(@CheckForNull Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return entry.getKey() != null && (entry.getValue() instanceof Map) && Collections2.safeContains(StandardTable.this.backingMap.entrySet(), entry);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(@CheckForNull Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return entry.getKey() != null && (entry.getValue() instanceof Map) && StandardTable.this.backingMap.entrySet().remove(entry);
}
}
}
@Override // com.google.common.collect.Table
public Map<C, Map<R, V>> columnMap() {
StandardTable<R, C, V>.ColumnMap columnMap = this.columnMap;
if (columnMap != null) {
return columnMap;
}
StandardTable<R, C, V>.ColumnMap columnMap2 = new ColumnMap();
this.columnMap = columnMap2;
return columnMap2;
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public class ColumnMap extends Maps.ViewCachingAbstractMap<C, Map<R, V>> {
private ColumnMap() {
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public Map<R, V> get(@CheckForNull Object obj) {
if (StandardTable.this.containsColumn(obj)) {
return StandardTable.this.column(Objects.requireNonNull(obj));
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(@CheckForNull Object obj) {
return StandardTable.this.containsColumn(obj);
}
@Override // java.util.AbstractMap, java.util.Map
@CheckForNull
public Map<R, V> remove(@CheckForNull Object obj) {
if (StandardTable.this.containsColumn(obj)) {
return StandardTable.this.removeColumn(obj);
}
return null;
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
public Set<Map.Entry<C, Map<R, V>>> createEntrySet() {
return new ColumnMapEntrySet();
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
public Set<C> keySet() {
return StandardTable.this.columnKeySet();
}
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
Collection<Map<R, V>> createValues() {
return new ColumnMapValues();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class ColumnMapEntrySet extends StandardTable<R, C, V>.TableSet<Map.Entry<C, Map<R, V>>> {
ColumnMapEntrySet() {
super();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<C, Map<R, V>>> iterator() {
return Maps.asMapEntryIterator(StandardTable.this.columnKeySet(), new Function<C, Map<R, V>>() { // from class: com.google.common.collect.StandardTable.ColumnMap.ColumnMapEntrySet.1
@Override // com.google.common.base.Function
public /* bridge */ /* synthetic */ Object apply(Object obj) {
return apply((AnonymousClass1) obj);
}
@Override // com.google.common.base.Function
public Map<R, V> apply(C c) {
return StandardTable.this.column(c);
}
});
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return StandardTable.this.columnKeySet().size();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(@CheckForNull Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
if (StandardTable.this.containsColumn(entry.getKey())) {
return ((Map) Objects.requireNonNull(ColumnMap.this.get(entry.getKey()))).equals(entry.getValue());
}
return false;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(@CheckForNull Object obj) {
if (!contains(obj) || !(obj instanceof Map.Entry)) {
return false;
}
StandardTable.this.removeColumn(((Map.Entry) obj).getKey());
return true;
}
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean removeAll(Collection<?> collection) {
Preconditions.checkNotNull(collection);
return Sets.removeAllImpl(this, collection.iterator());
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean retainAll(Collection<?> collection) {
Preconditions.checkNotNull(collection);
Iterator it = Lists.newArrayList(StandardTable.this.columnKeySet().iterator()).iterator();
boolean z = false;
while (it.hasNext()) {
Object next = it.next();
if (!collection.contains(Maps.immutableEntry(next, StandardTable.this.column(next)))) {
StandardTable.this.removeColumn(next);
z = true;
}
}
return z;
}
}
/* loaded from: classes3.dex */
private class ColumnMapValues extends Maps.Values<C, Map<R, V>> {
ColumnMapValues() {
super(ColumnMap.this);
}
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public boolean remove(@CheckForNull Object obj) {
for (Map.Entry<C, Map<R, V>> entry : ColumnMap.this.entrySet()) {
if (entry.getValue().equals(obj)) {
StandardTable.this.removeColumn(entry.getKey());
return true;
}
}
return false;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public boolean removeAll(Collection<?> collection) {
Preconditions.checkNotNull(collection);
Iterator it = Lists.newArrayList(StandardTable.this.columnKeySet().iterator()).iterator();
boolean z = false;
while (it.hasNext()) {
Object next = it.next();
if (collection.contains(StandardTable.this.column(next))) {
StandardTable.this.removeColumn(next);
z = true;
}
}
return z;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
public boolean retainAll(Collection<?> collection) {
Preconditions.checkNotNull(collection);
Iterator it = Lists.newArrayList(StandardTable.this.columnKeySet().iterator()).iterator();
boolean z = false;
while (it.hasNext()) {
Object next = it.next();
if (!collection.contains(StandardTable.this.column(next))) {
StandardTable.this.removeColumn(next);
z = true;
}
}
return z;
}
}
}
}