940 lines
34 KiB
Java
940 lines
34 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.Set;
|
|
|
|
/* loaded from: classes.dex */
|
|
class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
|
|
private static final long serialVersionUID = 0;
|
|
final Map<R, Map<C, V>> backingMap;
|
|
private transient Set<C> columnKeySet;
|
|
private transient StandardTable<R, C, V>.ColumnMap columnMap;
|
|
final Supplier<? extends Map<C, V>> factory;
|
|
private transient Map<R, Map<C, V>> rowMap;
|
|
|
|
private class CellIterator implements Iterator<Table.Cell<R, C, V>> {
|
|
final Iterator<Map.Entry<R, Map<C, V>>> a;
|
|
Map.Entry<R, Map<C, V>> b;
|
|
Iterator<Map.Entry<C, V>> c;
|
|
|
|
private CellIterator() {
|
|
this.a = StandardTable.this.backingMap.entrySet().iterator();
|
|
this.c = Iterators.c();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.a.hasNext() || this.c.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
this.c.remove();
|
|
if (this.b.getValue().isEmpty()) {
|
|
this.a.remove();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public Table.Cell<R, C, V> next() {
|
|
if (!this.c.hasNext()) {
|
|
this.b = this.a.next();
|
|
this.c = this.b.getValue().entrySet().iterator();
|
|
}
|
|
Map.Entry<C, V> next = this.c.next();
|
|
return Tables.a(this.b.getKey(), next.getKey(), next.getValue());
|
|
}
|
|
}
|
|
|
|
private class ColumnKeyIterator extends AbstractIterator<C> {
|
|
final Map<C, V> c;
|
|
final Iterator<Map<C, V>> d;
|
|
Iterator<Map.Entry<C, V>> e;
|
|
|
|
private ColumnKeyIterator() {
|
|
this.c = StandardTable.this.factory.get();
|
|
this.d = StandardTable.this.backingMap.values().iterator();
|
|
this.e = Iterators.a();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractIterator
|
|
protected C a() {
|
|
while (true) {
|
|
if (this.e.hasNext()) {
|
|
Map.Entry<C, V> next = this.e.next();
|
|
if (!this.c.containsKey(next.getKey())) {
|
|
this.c.put(next.getKey(), next.getValue());
|
|
return next.getKey();
|
|
}
|
|
} else {
|
|
if (!this.d.hasNext()) {
|
|
return b();
|
|
}
|
|
this.e = this.d.next().entrySet().iterator();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private class ColumnKeySet extends StandardTable<R, C, V>.TableSet<C> {
|
|
private ColumnKeySet() {
|
|
super();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean contains(Object obj) {
|
|
return StandardTable.this.containsColumn(obj);
|
|
}
|
|
|
|
@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 boolean remove(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)) {
|
|
z = true;
|
|
if (next.isEmpty()) {
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
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.a(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.a((Iterator<?>) next.keySet().iterator(), collection)) {
|
|
z = true;
|
|
if (next.isEmpty()) {
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Sets.ImprovedAbstractSet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean retainAll(Collection<?> collection) {
|
|
Preconditions.a(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)) {
|
|
z = true;
|
|
if (next.isEmpty()) {
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public int size() {
|
|
return Iterators.h(iterator());
|
|
}
|
|
}
|
|
|
|
private class ColumnMap extends Maps.ViewCachingAbstractMap<C, Map<R, V>> {
|
|
|
|
class ColumnMapEntrySet extends StandardTable<R, C, V>.TableSet<Map.Entry<C, Map<R, V>>> {
|
|
ColumnMapEntrySet() {
|
|
super();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean contains(Object obj) {
|
|
if (!(obj instanceof Map.Entry)) {
|
|
return false;
|
|
}
|
|
Map.Entry entry = (Map.Entry) obj;
|
|
if (!StandardTable.this.containsColumn(entry.getKey())) {
|
|
return false;
|
|
}
|
|
return ColumnMap.this.get(entry.getKey()).equals(entry.getValue());
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<Map.Entry<C, Map<R, V>>> iterator() {
|
|
return Maps.a((Set) StandardTable.this.columnKeySet(), (Function) 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 boolean remove(Object obj) {
|
|
if (!contains(obj)) {
|
|
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.a(collection);
|
|
return Sets.a((Set<?>) 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.a(collection);
|
|
Iterator it = Lists.a(StandardTable.this.columnKeySet().iterator()).iterator();
|
|
boolean z = false;
|
|
while (it.hasNext()) {
|
|
Object next = it.next();
|
|
if (!collection.contains(Maps.a(next, StandardTable.this.column(next)))) {
|
|
StandardTable.this.removeColumn(next);
|
|
z = true;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public int size() {
|
|
return StandardTable.this.columnKeySet().size();
|
|
}
|
|
}
|
|
|
|
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(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.a(collection);
|
|
Iterator it = Lists.a(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.a(collection);
|
|
Iterator it = Lists.a(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;
|
|
}
|
|
}
|
|
|
|
private ColumnMap() {
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
public Set<Map.Entry<C, Map<R, V>>> a() {
|
|
return new ColumnMapEntrySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
Collection<Map<R, V>> c() {
|
|
return new ColumnMapValues();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
return StandardTable.this.containsColumn(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public Set<C> keySet() {
|
|
return StandardTable.this.columnKeySet();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Map<R, V> get(Object obj) {
|
|
if (StandardTable.this.containsColumn(obj)) {
|
|
return StandardTable.this.column(obj);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Map<R, V> remove(Object obj) {
|
|
if (StandardTable.this.containsColumn(obj)) {
|
|
return StandardTable.this.removeColumn(obj);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
class RowMap extends Maps.ViewCachingAbstractMap<R, Map<C, V>> {
|
|
|
|
class EntrySet extends StandardTable<R, C, V>.TableSet<Map.Entry<R, Map<C, V>>> {
|
|
EntrySet() {
|
|
super();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean contains(Object obj) {
|
|
if (!(obj instanceof Map.Entry)) {
|
|
return false;
|
|
}
|
|
Map.Entry entry = (Map.Entry) obj;
|
|
return entry.getKey() != null && (entry.getValue() instanceof Map) && Collections2.a(StandardTable.this.backingMap.entrySet(), entry);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<Map.Entry<R, Map<C, V>>> iterator() {
|
|
return Maps.a((Set) StandardTable.this.backingMap.keySet(), (Function) 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 boolean remove(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 // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public int size() {
|
|
return StandardTable.this.backingMap.size();
|
|
}
|
|
}
|
|
|
|
RowMap() {
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
protected Set<Map.Entry<R, Map<C, V>>> a() {
|
|
return new EntrySet();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
return StandardTable.this.containsRow(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Map<C, V> get(Object obj) {
|
|
if (StandardTable.this.containsRow(obj)) {
|
|
return StandardTable.this.row(obj);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Map<C, V> remove(Object obj) {
|
|
if (obj == null) {
|
|
return null;
|
|
}
|
|
return StandardTable.this.backingMap.remove(obj);
|
|
}
|
|
}
|
|
|
|
private abstract class TableSet<T> extends Sets.ImprovedAbstractSet<T> {
|
|
private TableSet() {
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public void clear() {
|
|
StandardTable.this.backingMap.clear();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean isEmpty() {
|
|
return StandardTable.this.backingMap.isEmpty();
|
|
}
|
|
}
|
|
|
|
StandardTable(Map<R, Map<C, V>> map, Supplier<? extends Map<C, V>> supplier) {
|
|
this.backingMap = map;
|
|
this.factory = supplier;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public boolean containsMapping(Object obj, Object obj2, Object obj3) {
|
|
return obj3 != null && obj3.equals(get(obj, obj2));
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Map<R, V> removeColumn(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 removeMapping(Object obj, Object obj2, Object obj3) {
|
|
if (!containsMapping(obj, obj2, obj3)) {
|
|
return false;
|
|
}
|
|
remove(obj, obj2);
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
Iterator<Table.Cell<R, C, V>> cellIterator() {
|
|
return new CellIterator();
|
|
}
|
|
|
|
@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
|
|
public void clear() {
|
|
this.backingMap.clear();
|
|
}
|
|
|
|
public Map<R, V> column(C c) {
|
|
return new Column(c);
|
|
}
|
|
|
|
@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;
|
|
}
|
|
|
|
@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;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public boolean contains(Object obj, Object obj2) {
|
|
return (obj == null || obj2 == null || !super.contains(obj, obj2)) ? false : true;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public boolean containsColumn(Object obj) {
|
|
if (obj == null) {
|
|
return false;
|
|
}
|
|
Iterator<Map<C, V>> it = this.backingMap.values().iterator();
|
|
while (it.hasNext()) {
|
|
if (Maps.d(it.next(), obj)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public boolean containsRow(Object obj) {
|
|
return obj != null && Maps.d(this.backingMap, obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public boolean containsValue(Object obj) {
|
|
return obj != null && super.containsValue(obj);
|
|
}
|
|
|
|
Iterator<C> createColumnKeyIterator() {
|
|
return new ColumnKeyIterator();
|
|
}
|
|
|
|
Map<R, Map<C, V>> createRowMap() {
|
|
return new RowMap();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public V get(Object obj, Object obj2) {
|
|
if (obj == null || obj2 == null) {
|
|
return null;
|
|
}
|
|
return (V) super.get(obj, obj2);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public boolean isEmpty() {
|
|
return this.backingMap.isEmpty();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public V put(R r, C c, V v) {
|
|
Preconditions.a(r);
|
|
Preconditions.a(c);
|
|
Preconditions.a(v);
|
|
return getOrCreate(r).put(c, v);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public V remove(Object obj, Object obj2) {
|
|
Map map;
|
|
if (obj == null || obj2 == null || (map = (Map) Maps.e(this.backingMap, obj)) == null) {
|
|
return null;
|
|
}
|
|
V v = (V) map.remove(obj2);
|
|
if (map.isEmpty()) {
|
|
this.backingMap.remove(obj);
|
|
}
|
|
return v;
|
|
}
|
|
|
|
public Map<C, V> row(R r) {
|
|
return new Row(r);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public Set<R> rowKeySet() {
|
|
return rowMap().keySet();
|
|
}
|
|
|
|
@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;
|
|
}
|
|
|
|
@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
|
|
public Collection<V> values() {
|
|
return super.values();
|
|
}
|
|
|
|
class Row extends Maps.IteratorBasedAbstractMap<C, V> {
|
|
final R a;
|
|
Map<C, V> b;
|
|
|
|
Row(R r) {
|
|
Preconditions.a(r);
|
|
this.a = r;
|
|
}
|
|
|
|
Map<C, V> a() {
|
|
Map<C, V> map = this.b;
|
|
if (map != null && (!map.isEmpty() || !StandardTable.this.backingMap.containsKey(this.a))) {
|
|
return this.b;
|
|
}
|
|
Map<C, V> b = b();
|
|
this.b = b;
|
|
return b;
|
|
}
|
|
|
|
Map<C, V> b() {
|
|
return StandardTable.this.backingMap.get(this.a);
|
|
}
|
|
|
|
void c() {
|
|
if (a() == null || !this.b.isEmpty()) {
|
|
return;
|
|
}
|
|
StandardTable.this.backingMap.remove(this.a);
|
|
this.b = null;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public void clear() {
|
|
Map<C, V> a = a();
|
|
if (a != null) {
|
|
a.clear();
|
|
}
|
|
c();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
Map<C, V> a = a();
|
|
return (obj == null || a == null || !Maps.d(a, obj)) ? false : true;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap
|
|
Iterator<Map.Entry<C, V>> entryIterator() {
|
|
Map<C, V> a = a();
|
|
if (a == null) {
|
|
return Iterators.c();
|
|
}
|
|
final Iterator<Map.Entry<C, V>> it = a.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 void remove() {
|
|
it.remove();
|
|
Row.this.c();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public Map.Entry<C, V> next() {
|
|
return Row.this.a((Map.Entry) it.next());
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V get(Object obj) {
|
|
Map<C, V> a = a();
|
|
if (obj == null || a == null) {
|
|
return null;
|
|
}
|
|
return (V) Maps.e(a, obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V put(C c, V v) {
|
|
Preconditions.a(c);
|
|
Preconditions.a(v);
|
|
Map<C, V> map = this.b;
|
|
return (map == null || map.isEmpty()) ? (V) StandardTable.this.put(this.a, c, v) : this.b.put(c, v);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V remove(Object obj) {
|
|
Map<C, V> a = a();
|
|
if (a == null) {
|
|
return null;
|
|
}
|
|
V v = (V) Maps.f(a, obj);
|
|
c();
|
|
return v;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public int size() {
|
|
Map<C, V> a = a();
|
|
if (a == null) {
|
|
return 0;
|
|
}
|
|
return a.size();
|
|
}
|
|
|
|
Map.Entry<C, V> a(final Map.Entry<C, V> entry) {
|
|
return new ForwardingMapEntry<C, V>(this) { // from class: com.google.common.collect.StandardTable.Row.2
|
|
@Override // com.google.common.collect.ForwardingMapEntry, java.util.Map.Entry
|
|
public boolean equals(Object obj) {
|
|
return standardEquals(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ForwardingMapEntry, java.util.Map.Entry
|
|
public V setValue(V v) {
|
|
Preconditions.a(v);
|
|
return (V) super.setValue(v);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.collect.ForwardingObject
|
|
public Map.Entry<C, V> delegate() {
|
|
return entry;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
private class Column extends Maps.ViewCachingAbstractMap<R, V> {
|
|
final C d;
|
|
|
|
private class EntrySet extends Sets.ImprovedAbstractSet<Map.Entry<R, V>> {
|
|
private EntrySet() {
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public void clear() {
|
|
Column.this.a(Predicates.a());
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean contains(Object obj) {
|
|
if (!(obj instanceof Map.Entry)) {
|
|
return false;
|
|
}
|
|
Map.Entry entry = (Map.Entry) obj;
|
|
return StandardTable.this.containsMapping(entry.getKey(), Column.this.d, entry.getValue());
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean isEmpty() {
|
|
Column column = Column.this;
|
|
return !StandardTable.this.containsColumn(column.d);
|
|
}
|
|
|
|
@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 boolean remove(Object obj) {
|
|
if (!(obj instanceof Map.Entry)) {
|
|
return false;
|
|
}
|
|
Map.Entry entry = (Map.Entry) obj;
|
|
return StandardTable.this.removeMapping(entry.getKey(), Column.this.d, 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.a(Predicates.a(Predicates.a((Collection) collection)));
|
|
}
|
|
|
|
@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.d)) {
|
|
i++;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
}
|
|
|
|
private class EntrySetIterator extends AbstractIterator<Map.Entry<R, V>> {
|
|
final Iterator<Map.Entry<R, Map<C, V>>> c;
|
|
|
|
private EntrySetIterator() {
|
|
this.c = StandardTable.this.backingMap.entrySet().iterator();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.collect.AbstractIterator
|
|
public Map.Entry<R, V> a() {
|
|
while (this.c.hasNext()) {
|
|
final Map.Entry<R, Map<C, V>> next = this.c.next();
|
|
if (next.getValue().containsKey(Column.this.d)) {
|
|
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.d);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapEntry, java.util.Map.Entry
|
|
public V setValue(V v) {
|
|
Map map = (Map) next.getValue();
|
|
C c = Column.this.d;
|
|
Preconditions.a(v);
|
|
return (V) map.put(c, v);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
return b();
|
|
}
|
|
}
|
|
|
|
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(Object obj) {
|
|
Column column = Column.this;
|
|
return StandardTable.this.contains(obj, column.d);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean remove(Object obj) {
|
|
Column column = Column.this;
|
|
return StandardTable.this.remove(obj, column.d) != 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.a(Maps.a(Predicates.a(Predicates.a((Collection) collection))));
|
|
}
|
|
}
|
|
|
|
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(Object obj) {
|
|
return obj != null && Column.this.a(Maps.b(Predicates.a(obj)));
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
|
|
public boolean removeAll(Collection<?> collection) {
|
|
return Column.this.a(Maps.b(Predicates.a((Collection) collection)));
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.Values, java.util.AbstractCollection, java.util.Collection
|
|
public boolean retainAll(Collection<?> collection) {
|
|
return Column.this.a(Maps.b(Predicates.a(Predicates.a((Collection) collection))));
|
|
}
|
|
}
|
|
|
|
Column(C c) {
|
|
Preconditions.a(c);
|
|
this.d = c;
|
|
}
|
|
|
|
boolean a(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.d);
|
|
if (v != null && predicate.apply(Maps.a(next.getKey(), v))) {
|
|
value.remove(this.d);
|
|
z = true;
|
|
if (value.isEmpty()) {
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
Set<R> b() {
|
|
return new KeySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
Collection<V> c() {
|
|
return new Values();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
return StandardTable.this.contains(obj, this.d);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V get(Object obj) {
|
|
return (V) StandardTable.this.get(obj, this.d);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V put(R r, V v) {
|
|
return (V) StandardTable.this.put(r, this.d, v);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public V remove(Object obj) {
|
|
return (V) StandardTable.this.remove(obj, this.d);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
Set<Map.Entry<R, V>> a() {
|
|
return new EntrySet();
|
|
}
|
|
}
|
|
}
|