1345 lines
46 KiB
Java
1345 lines
46 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.collect.Maps;
|
|
import java.io.Serializable;
|
|
import java.util.AbstractCollection;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.ConcurrentModificationException;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.ListIterator;
|
|
import java.util.Map;
|
|
import java.util.NavigableMap;
|
|
import java.util.NavigableSet;
|
|
import java.util.RandomAccess;
|
|
import java.util.Set;
|
|
import java.util.SortedMap;
|
|
import java.util.SortedSet;
|
|
|
|
/* loaded from: classes.dex */
|
|
abstract class AbstractMapBasedMultimap<K, V> extends AbstractMultimap<K, V> implements Serializable {
|
|
private static final long serialVersionUID = 2447537837011683357L;
|
|
private transient Map<K, Collection<V>> map;
|
|
private transient int totalSize;
|
|
|
|
private class AsMap extends Maps.ViewCachingAbstractMap<K, Collection<V>> {
|
|
final transient Map<K, Collection<V>> d;
|
|
|
|
class AsMapEntries extends Maps.EntrySet<K, Collection<V>> {
|
|
AsMapEntries() {
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.EntrySet
|
|
Map<K, Collection<V>> c() {
|
|
return AsMap.this;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean contains(Object obj) {
|
|
return Collections2.a(AsMap.this.d.entrySet(), obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<Map.Entry<K, Collection<V>>> iterator() {
|
|
return AsMap.this.new AsMapIterator();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean remove(Object obj) {
|
|
if (!contains(obj)) {
|
|
return false;
|
|
}
|
|
AbstractMapBasedMultimap.this.removeValuesForKey(((Map.Entry) obj).getKey());
|
|
return true;
|
|
}
|
|
}
|
|
|
|
class AsMapIterator implements Iterator<Map.Entry<K, Collection<V>>> {
|
|
final Iterator<Map.Entry<K, Collection<V>>> a;
|
|
Collection<V> b;
|
|
|
|
AsMapIterator() {
|
|
this.a = AsMap.this.d.entrySet().iterator();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.a.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
this.a.remove();
|
|
AbstractMapBasedMultimap.this.totalSize -= this.b.size();
|
|
this.b.clear();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public Map.Entry<K, Collection<V>> next() {
|
|
Map.Entry<K, Collection<V>> next = this.a.next();
|
|
this.b = next.getValue();
|
|
return AsMap.this.a(next);
|
|
}
|
|
}
|
|
|
|
AsMap(Map<K, Collection<V>> map) {
|
|
this.d = map;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
protected Set<Map.Entry<K, Collection<V>>> a() {
|
|
return new AsMapEntries();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public void clear() {
|
|
if (this.d == AbstractMapBasedMultimap.this.map) {
|
|
AbstractMapBasedMultimap.this.clear();
|
|
} else {
|
|
Iterators.b(new AsMapIterator());
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
return Maps.d(this.d, obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean equals(Object obj) {
|
|
return this == obj || this.d.equals(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public int hashCode() {
|
|
return this.d.hashCode();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public Set<K> keySet() {
|
|
return AbstractMapBasedMultimap.this.keySet();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public int size() {
|
|
return this.d.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap
|
|
public String toString() {
|
|
return this.d.toString();
|
|
}
|
|
|
|
Map.Entry<K, Collection<V>> a(Map.Entry<K, Collection<V>> entry) {
|
|
K key = entry.getKey();
|
|
return Maps.a(key, AbstractMapBasedMultimap.this.wrapCollection(key, entry.getValue()));
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Collection<V> get(Object obj) {
|
|
Collection<V> collection = (Collection) Maps.e(this.d, obj);
|
|
if (collection == null) {
|
|
return null;
|
|
}
|
|
return AbstractMapBasedMultimap.this.wrapCollection(obj, collection);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Collection<V> remove(Object obj) {
|
|
Collection<V> remove = this.d.remove(obj);
|
|
if (remove == null) {
|
|
return null;
|
|
}
|
|
Collection<V> createCollection = AbstractMapBasedMultimap.this.createCollection();
|
|
createCollection.addAll(remove);
|
|
AbstractMapBasedMultimap.this.totalSize -= remove.size();
|
|
remove.clear();
|
|
return createCollection;
|
|
}
|
|
}
|
|
|
|
private abstract class Itr<T> implements Iterator<T> {
|
|
final Iterator<Map.Entry<K, Collection<V>>> a;
|
|
K b = null;
|
|
Collection<V> c = null;
|
|
Iterator<V> d = Iterators.c();
|
|
|
|
Itr() {
|
|
this.a = AbstractMapBasedMultimap.this.map.entrySet().iterator();
|
|
}
|
|
|
|
abstract T a(K k, V v);
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.a.hasNext() || this.d.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public T next() {
|
|
if (!this.d.hasNext()) {
|
|
Map.Entry<K, Collection<V>> next = this.a.next();
|
|
this.b = next.getKey();
|
|
this.c = next.getValue();
|
|
this.d = this.c.iterator();
|
|
}
|
|
return a(this.b, this.d.next());
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
this.d.remove();
|
|
if (this.c.isEmpty()) {
|
|
this.a.remove();
|
|
}
|
|
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
|
}
|
|
}
|
|
|
|
private class KeySet extends Maps.KeySet<K, Collection<V>> {
|
|
KeySet(Map<K, Collection<V>> map) {
|
|
super(map);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public void clear() {
|
|
Iterators.b(iterator());
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean containsAll(Collection<?> collection) {
|
|
return c().keySet().containsAll(collection);
|
|
}
|
|
|
|
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
|
|
public boolean equals(Object obj) {
|
|
return this == obj || c().keySet().equals(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
|
|
public int hashCode() {
|
|
return c().keySet().hashCode();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<K> iterator() {
|
|
final Iterator<Map.Entry<K, Collection<V>>> it = c().entrySet().iterator();
|
|
return new Iterator<K>() { // from class: com.google.common.collect.AbstractMapBasedMultimap.KeySet.1
|
|
Map.Entry<K, Collection<V>> a;
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return it.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public K next() {
|
|
this.a = (Map.Entry) it.next();
|
|
return this.a.getKey();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
CollectPreconditions.a(this.a != null);
|
|
Collection<V> value = this.a.getValue();
|
|
it.remove();
|
|
AbstractMapBasedMultimap.this.totalSize -= value.size();
|
|
value.clear();
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean remove(Object obj) {
|
|
int i;
|
|
Collection<V> remove = c().remove(obj);
|
|
if (remove != null) {
|
|
i = remove.size();
|
|
remove.clear();
|
|
AbstractMapBasedMultimap.this.totalSize -= i;
|
|
} else {
|
|
i = 0;
|
|
}
|
|
return i > 0;
|
|
}
|
|
}
|
|
|
|
class NavigableAsMap extends AbstractMapBasedMultimap<K, V>.SortedAsMap implements NavigableMap<K, Collection<V>> {
|
|
NavigableAsMap(NavigableMap<K, Collection<V>> navigableMap) {
|
|
super(navigableMap);
|
|
}
|
|
|
|
Map.Entry<K, Collection<V>> a(Iterator<Map.Entry<K, Collection<V>>> it) {
|
|
if (!it.hasNext()) {
|
|
return null;
|
|
}
|
|
Map.Entry<K, Collection<V>> next = it.next();
|
|
Collection<V> createCollection = AbstractMapBasedMultimap.this.createCollection();
|
|
createCollection.addAll(next.getValue());
|
|
it.remove();
|
|
return Maps.a(next.getKey(), AbstractMapBasedMultimap.unmodifiableCollectionSubclass(createCollection));
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> ceilingEntry(K k) {
|
|
Map.Entry<K, Collection<V>> ceilingEntry = d().ceilingEntry(k);
|
|
if (ceilingEntry == null) {
|
|
return null;
|
|
}
|
|
return a(ceilingEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K ceilingKey(K k) {
|
|
return d().ceilingKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableSet<K> descendingKeySet() {
|
|
return descendingMap().navigableKeySet();
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> descendingMap() {
|
|
return new NavigableAsMap(d().descendingMap());
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> firstEntry() {
|
|
Map.Entry<K, Collection<V>> firstEntry = d().firstEntry();
|
|
if (firstEntry == null) {
|
|
return null;
|
|
}
|
|
return a(firstEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> floorEntry(K k) {
|
|
Map.Entry<K, Collection<V>> floorEntry = d().floorEntry(k);
|
|
if (floorEntry == null) {
|
|
return null;
|
|
}
|
|
return a(floorEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K floorKey(K k) {
|
|
return d().floorKey(k);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, java.util.SortedMap, java.util.NavigableMap
|
|
public /* bridge */ /* synthetic */ SortedMap headMap(Object obj) {
|
|
return headMap((NavigableAsMap) obj);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> higherEntry(K k) {
|
|
Map.Entry<K, Collection<V>> higherEntry = d().higherEntry(k);
|
|
if (higherEntry == null) {
|
|
return null;
|
|
}
|
|
return a(higherEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K higherKey(K k) {
|
|
return d().higherKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> lastEntry() {
|
|
Map.Entry<K, Collection<V>> lastEntry = d().lastEntry();
|
|
if (lastEntry == null) {
|
|
return null;
|
|
}
|
|
return a(lastEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> lowerEntry(K k) {
|
|
Map.Entry<K, Collection<V>> lowerEntry = d().lowerEntry(k);
|
|
if (lowerEntry == null) {
|
|
return null;
|
|
}
|
|
return a(lowerEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K lowerKey(K k) {
|
|
return d().lowerKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableSet<K> navigableKeySet() {
|
|
return keySet();
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> pollFirstEntry() {
|
|
return a(entrySet().iterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> pollLastEntry() {
|
|
return a(descendingMap().entrySet().iterator());
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, java.util.SortedMap, java.util.NavigableMap
|
|
public /* bridge */ /* synthetic */ SortedMap tailMap(Object obj) {
|
|
return tailMap((NavigableAsMap) obj);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap
|
|
public NavigableMap<K, Collection<V>> d() {
|
|
return (NavigableMap) super.d();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, java.util.SortedMap, java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> headMap(K k) {
|
|
return headMap(k, false);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, java.util.SortedMap, java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> subMap(K k, K k2) {
|
|
return subMap(k, true, k2, false);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, java.util.SortedMap, java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> tailMap(K k) {
|
|
return tailMap(k, true);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
public NavigableSet<K> b() {
|
|
return new NavigableKeySet(d());
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> headMap(K k, boolean z) {
|
|
return new NavigableAsMap(d().headMap(k, z));
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, com.google.common.collect.AbstractMapBasedMultimap.AsMap, com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public NavigableSet<K> keySet() {
|
|
return (NavigableSet) super.keySet();
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> subMap(K k, boolean z, K k2, boolean z2) {
|
|
return new NavigableAsMap(d().subMap(k, z, k2, z2));
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> tailMap(K k, boolean z) {
|
|
return new NavigableAsMap(d().tailMap(k, z));
|
|
}
|
|
}
|
|
|
|
class NavigableKeySet extends AbstractMapBasedMultimap<K, V>.SortedKeySet implements NavigableSet<K> {
|
|
NavigableKeySet(NavigableMap<K, Collection<V>> navigableMap) {
|
|
super(navigableMap);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K ceiling(K k) {
|
|
return d().ceilingKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public Iterator<K> descendingIterator() {
|
|
return descendingSet().iterator();
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<K> descendingSet() {
|
|
return new NavigableKeySet(d().descendingMap());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K floor(K k) {
|
|
return d().floorKey(k);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
|
|
public /* bridge */ /* synthetic */ SortedSet headSet(Object obj) {
|
|
return headSet((NavigableKeySet) obj);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K higher(K k) {
|
|
return d().higherKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K lower(K k) {
|
|
return d().lowerKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K pollFirst() {
|
|
return (K) Iterators.g(iterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K pollLast() {
|
|
return (K) Iterators.g(descendingIterator());
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
|
|
public /* bridge */ /* synthetic */ SortedSet tailSet(Object obj) {
|
|
return tailSet((NavigableKeySet) obj);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet
|
|
public NavigableMap<K, Collection<V>> d() {
|
|
return (NavigableMap) super.d();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
|
|
public NavigableSet<K> headSet(K k) {
|
|
return headSet(k, false);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
|
|
public NavigableSet<K> subSet(K k, K k2) {
|
|
return subSet(k, true, k2, false);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
|
|
public NavigableSet<K> tailSet(K k) {
|
|
return tailSet(k, true);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<K> headSet(K k, boolean z) {
|
|
return new NavigableKeySet(d().headMap(k, z));
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<K> subSet(K k, boolean z, K k2, boolean z2) {
|
|
return new NavigableKeySet(d().subMap(k, z, k2, z2));
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<K> tailSet(K k, boolean z) {
|
|
return new NavigableKeySet(d().tailMap(k, z));
|
|
}
|
|
}
|
|
|
|
private class RandomAccessWrappedList extends AbstractMapBasedMultimap<K, V>.WrappedList implements RandomAccess {
|
|
RandomAccessWrappedList(AbstractMapBasedMultimap abstractMapBasedMultimap, K k, List<V> list, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(k, list, wrappedCollection);
|
|
}
|
|
}
|
|
|
|
private class SortedAsMap extends AbstractMapBasedMultimap<K, V>.AsMap implements SortedMap<K, Collection<V>> {
|
|
SortedSet<K> f;
|
|
|
|
SortedAsMap(SortedMap<K, Collection<V>> sortedMap) {
|
|
super(sortedMap);
|
|
}
|
|
|
|
@Override // java.util.SortedMap
|
|
public Comparator<? super K> comparator() {
|
|
return d().comparator();
|
|
}
|
|
|
|
SortedMap<K, Collection<V>> d() {
|
|
return (SortedMap) this.d;
|
|
}
|
|
|
|
@Override // java.util.SortedMap
|
|
public K firstKey() {
|
|
return d().firstKey();
|
|
}
|
|
|
|
public SortedMap<K, Collection<V>> headMap(K k) {
|
|
return new SortedAsMap(d().headMap(k));
|
|
}
|
|
|
|
@Override // java.util.SortedMap
|
|
public K lastKey() {
|
|
return d().lastKey();
|
|
}
|
|
|
|
public SortedMap<K, Collection<V>> subMap(K k, K k2) {
|
|
return new SortedAsMap(d().subMap(k, k2));
|
|
}
|
|
|
|
public SortedMap<K, Collection<V>> tailMap(K k) {
|
|
return new SortedAsMap(d().tailMap(k));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
public SortedSet<K> b() {
|
|
return new SortedKeySet(d());
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.AsMap, com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public SortedSet<K> keySet() {
|
|
SortedSet<K> sortedSet = this.f;
|
|
if (sortedSet != null) {
|
|
return sortedSet;
|
|
}
|
|
SortedSet<K> b = b();
|
|
this.f = b;
|
|
return b;
|
|
}
|
|
}
|
|
|
|
private class SortedKeySet extends AbstractMapBasedMultimap<K, V>.KeySet implements SortedSet<K> {
|
|
SortedKeySet(SortedMap<K, Collection<V>> sortedMap) {
|
|
super(sortedMap);
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public Comparator<? super K> comparator() {
|
|
return d().comparator();
|
|
}
|
|
|
|
SortedMap<K, Collection<V>> d() {
|
|
return (SortedMap) super.c();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public K first() {
|
|
return d().firstKey();
|
|
}
|
|
|
|
public SortedSet<K> headSet(K k) {
|
|
return new SortedKeySet(d().headMap(k));
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public K last() {
|
|
return d().lastKey();
|
|
}
|
|
|
|
public SortedSet<K> subSet(K k, K k2) {
|
|
return new SortedKeySet(d().subMap(k, k2));
|
|
}
|
|
|
|
public SortedSet<K> tailSet(K k) {
|
|
return new SortedKeySet(d().tailMap(k));
|
|
}
|
|
}
|
|
|
|
class WrappedNavigableSet extends AbstractMapBasedMultimap<K, V>.WrappedSortedSet implements NavigableSet<V> {
|
|
WrappedNavigableSet(K k, NavigableSet<V> navigableSet, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(k, navigableSet, wrappedCollection);
|
|
}
|
|
|
|
private NavigableSet<V> a(NavigableSet<V> navigableSet) {
|
|
return new WrappedNavigableSet(this.a, navigableSet, b() == null ? this : b());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V ceiling(V v) {
|
|
return g().ceiling(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public Iterator<V> descendingIterator() {
|
|
return new WrappedCollection.WrappedIterator(g().descendingIterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> descendingSet() {
|
|
return a(g().descendingSet());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V floor(V v) {
|
|
return g().floor(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> headSet(V v, boolean z) {
|
|
return a(g().headSet(v, z));
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V higher(V v) {
|
|
return g().higher(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V lower(V v) {
|
|
return g().lower(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V pollFirst() {
|
|
return (V) Iterators.g(iterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V pollLast() {
|
|
return (V) Iterators.g(descendingIterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> subSet(V v, boolean z, V v2, boolean z2) {
|
|
return a(g().subSet(v, z, v2, z2));
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> tailSet(V v, boolean z) {
|
|
return a(g().tailSet(v, z));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.WrappedSortedSet
|
|
public NavigableSet<V> g() {
|
|
return (NavigableSet) super.g();
|
|
}
|
|
}
|
|
|
|
private class WrappedSet extends AbstractMapBasedMultimap<K, V>.WrappedCollection implements Set<V> {
|
|
WrappedSet(K k, Set<V> set) {
|
|
super(k, set, null);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.WrappedCollection, java.util.AbstractCollection, java.util.Collection
|
|
public boolean removeAll(Collection<?> collection) {
|
|
if (collection.isEmpty()) {
|
|
return false;
|
|
}
|
|
int size = size();
|
|
boolean a = Sets.a((Set<?>) this.b, collection);
|
|
if (a) {
|
|
int size2 = this.b.size();
|
|
AbstractMapBasedMultimap.this.totalSize += size2 - size;
|
|
f();
|
|
}
|
|
return a;
|
|
}
|
|
}
|
|
|
|
private class WrappedSortedSet extends AbstractMapBasedMultimap<K, V>.WrappedCollection implements SortedSet<V> {
|
|
WrappedSortedSet(K k, SortedSet<V> sortedSet, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(k, sortedSet, wrappedCollection);
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public Comparator<? super V> comparator() {
|
|
return g().comparator();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public V first() {
|
|
e();
|
|
return g().first();
|
|
}
|
|
|
|
SortedSet<V> g() {
|
|
return (SortedSet) c();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public SortedSet<V> headSet(V v) {
|
|
e();
|
|
return new WrappedSortedSet(d(), g().headSet(v), b() == null ? this : b());
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public V last() {
|
|
e();
|
|
return g().last();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public SortedSet<V> subSet(V v, V v2) {
|
|
e();
|
|
return new WrappedSortedSet(d(), g().subSet(v, v2), b() == null ? this : b());
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public SortedSet<V> tailSet(V v) {
|
|
e();
|
|
return new WrappedSortedSet(d(), g().tailSet(v), b() == null ? this : b());
|
|
}
|
|
}
|
|
|
|
protected AbstractMapBasedMultimap(Map<K, Collection<V>> map) {
|
|
Preconditions.a(map.isEmpty());
|
|
this.map = map;
|
|
}
|
|
|
|
static /* synthetic */ int access$208(AbstractMapBasedMultimap abstractMapBasedMultimap) {
|
|
int i = abstractMapBasedMultimap.totalSize;
|
|
abstractMapBasedMultimap.totalSize = i + 1;
|
|
return i;
|
|
}
|
|
|
|
static /* synthetic */ int access$210(AbstractMapBasedMultimap abstractMapBasedMultimap) {
|
|
int i = abstractMapBasedMultimap.totalSize;
|
|
abstractMapBasedMultimap.totalSize = i - 1;
|
|
return i;
|
|
}
|
|
|
|
private Collection<V> getOrCreateCollection(K k) {
|
|
Collection<V> collection = this.map.get(k);
|
|
if (collection != null) {
|
|
return collection;
|
|
}
|
|
Collection<V> createCollection = createCollection(k);
|
|
this.map.put(k, createCollection);
|
|
return createCollection;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static <E> Iterator<E> iteratorOrListIterator(Collection<E> collection) {
|
|
return collection instanceof List ? ((List) collection).listIterator() : collection.iterator();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void removeValuesForKey(Object obj) {
|
|
Collection collection = (Collection) Maps.f(this.map, obj);
|
|
if (collection != null) {
|
|
int size = collection.size();
|
|
collection.clear();
|
|
this.totalSize -= size;
|
|
}
|
|
}
|
|
|
|
static <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
|
|
return collection instanceof NavigableSet ? Sets.a((NavigableSet) collection) : collection instanceof SortedSet ? Collections.unmodifiableSortedSet((SortedSet) collection) : collection instanceof Set ? Collections.unmodifiableSet((Set) collection) : collection instanceof List ? Collections.unmodifiableList((List) collection) : Collections.unmodifiableCollection(collection);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public List<V> wrapList(K k, List<V> list, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
return list instanceof RandomAccess ? new RandomAccessWrappedList(this, k, list, wrappedCollection) : new WrappedList(k, list, wrappedCollection);
|
|
}
|
|
|
|
Map<K, Collection<V>> backingMap() {
|
|
return this.map;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multimap
|
|
public void clear() {
|
|
Iterator<Collection<V>> it = this.map.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().clear();
|
|
}
|
|
this.map.clear();
|
|
this.totalSize = 0;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multimap
|
|
public boolean containsKey(Object obj) {
|
|
return this.map.containsKey(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Map<K, Collection<V>> createAsMap() {
|
|
Map<K, Collection<V>> map = this.map;
|
|
return map instanceof NavigableMap ? new NavigableAsMap((NavigableMap) map) : map instanceof SortedMap ? new SortedAsMap((SortedMap) map) : new AsMap(map);
|
|
}
|
|
|
|
abstract Collection<V> createCollection();
|
|
|
|
Collection<V> createCollection(K k) {
|
|
return createCollection();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Set<K> createKeySet() {
|
|
Map<K, Collection<V>> map = this.map;
|
|
return map instanceof NavigableMap ? new NavigableKeySet((NavigableMap) map) : map instanceof SortedMap ? new SortedKeySet((SortedMap) map) : new KeySet(map);
|
|
}
|
|
|
|
abstract Collection<V> createUnmodifiableEmptyCollection();
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
|
public Collection<Map.Entry<K, V>> entries() {
|
|
return super.entries();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Iterator<Map.Entry<K, V>> entryIterator() {
|
|
return new AbstractMapBasedMultimap<K, V>.Itr<Map.Entry<K, V>>(this) { // from class: com.google.common.collect.AbstractMapBasedMultimap.2
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.Itr
|
|
/* bridge */ /* synthetic */ Object a(Object obj, Object obj2) {
|
|
return a((AnonymousClass2) obj, obj2);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.Itr
|
|
Map.Entry<K, V> a(K k, V v) {
|
|
return Maps.a(k, v);
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multimap
|
|
public Collection<V> get(K k) {
|
|
Collection<V> collection = this.map.get(k);
|
|
if (collection == null) {
|
|
collection = createCollection(k);
|
|
}
|
|
return wrapCollection(k, collection);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
|
public boolean put(K k, V v) {
|
|
Collection<V> collection = this.map.get(k);
|
|
if (collection != null) {
|
|
if (!collection.add(v)) {
|
|
return false;
|
|
}
|
|
this.totalSize++;
|
|
return true;
|
|
}
|
|
Collection<V> createCollection = createCollection(k);
|
|
if (!createCollection.add(v)) {
|
|
throw new AssertionError("New Collection violated the Collection spec");
|
|
}
|
|
this.totalSize++;
|
|
this.map.put(k, createCollection);
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multimap
|
|
public Collection<V> removeAll(Object obj) {
|
|
Collection<V> remove = this.map.remove(obj);
|
|
if (remove == null) {
|
|
return createUnmodifiableEmptyCollection();
|
|
}
|
|
Collection<V> createCollection = createCollection();
|
|
createCollection.addAll(remove);
|
|
this.totalSize -= remove.size();
|
|
remove.clear();
|
|
return unmodifiableCollectionSubclass(createCollection);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
public Collection<V> replaceValues(K k, Iterable<? extends V> iterable) {
|
|
Iterator<? extends V> it = iterable.iterator();
|
|
if (!it.hasNext()) {
|
|
return removeAll(k);
|
|
}
|
|
Collection<V> orCreateCollection = getOrCreateCollection(k);
|
|
Collection<V> createCollection = createCollection();
|
|
createCollection.addAll(orCreateCollection);
|
|
this.totalSize -= orCreateCollection.size();
|
|
orCreateCollection.clear();
|
|
while (it.hasNext()) {
|
|
if (orCreateCollection.add(it.next())) {
|
|
this.totalSize++;
|
|
}
|
|
}
|
|
return unmodifiableCollectionSubclass(createCollection);
|
|
}
|
|
|
|
final void setMap(Map<K, Collection<V>> map) {
|
|
this.map = map;
|
|
this.totalSize = 0;
|
|
for (Collection<V> collection : map.values()) {
|
|
Preconditions.a(!collection.isEmpty());
|
|
this.totalSize += collection.size();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multimap
|
|
public int size() {
|
|
return this.totalSize;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Iterator<V> valueIterator() {
|
|
return new AbstractMapBasedMultimap<K, V>.Itr<V>(this) { // from class: com.google.common.collect.AbstractMapBasedMultimap.1
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.Itr
|
|
V a(K k, V v) {
|
|
return v;
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
public Collection<V> values() {
|
|
return super.values();
|
|
}
|
|
|
|
Collection<V> wrapCollection(K k, Collection<V> collection) {
|
|
return collection instanceof NavigableSet ? new WrappedNavigableSet(k, (NavigableSet) collection, null) : collection instanceof SortedSet ? new WrappedSortedSet(k, (SortedSet) collection, null) : collection instanceof Set ? new WrappedSet(k, (Set) collection) : collection instanceof List ? wrapList(k, (List) collection, null) : new WrappedCollection(k, collection, null);
|
|
}
|
|
|
|
private class WrappedCollection extends AbstractCollection<V> {
|
|
final K a;
|
|
Collection<V> b;
|
|
final AbstractMapBasedMultimap<K, V>.WrappedCollection c;
|
|
final Collection<V> d;
|
|
|
|
WrappedCollection(K k, Collection<V> collection, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
this.a = k;
|
|
this.b = collection;
|
|
this.c = wrappedCollection;
|
|
this.d = wrappedCollection == null ? null : wrappedCollection.c();
|
|
}
|
|
|
|
void a() {
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection = this.c;
|
|
if (wrappedCollection != null) {
|
|
wrappedCollection.a();
|
|
} else {
|
|
AbstractMapBasedMultimap.this.map.put(this.a, this.b);
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean add(V v) {
|
|
e();
|
|
boolean isEmpty = this.b.isEmpty();
|
|
boolean add = this.b.add(v);
|
|
if (add) {
|
|
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
|
|
if (isEmpty) {
|
|
a();
|
|
}
|
|
}
|
|
return add;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean addAll(Collection<? extends V> collection) {
|
|
if (collection.isEmpty()) {
|
|
return false;
|
|
}
|
|
int size = size();
|
|
boolean addAll = this.b.addAll(collection);
|
|
if (addAll) {
|
|
int size2 = this.b.size();
|
|
AbstractMapBasedMultimap.this.totalSize += size2 - size;
|
|
if (size == 0) {
|
|
a();
|
|
}
|
|
}
|
|
return addAll;
|
|
}
|
|
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection b() {
|
|
return this.c;
|
|
}
|
|
|
|
Collection<V> c() {
|
|
return this.b;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public void clear() {
|
|
int size = size();
|
|
if (size == 0) {
|
|
return;
|
|
}
|
|
this.b.clear();
|
|
AbstractMapBasedMultimap.this.totalSize -= size;
|
|
f();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean contains(Object obj) {
|
|
e();
|
|
return this.b.contains(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean containsAll(Collection<?> collection) {
|
|
e();
|
|
return this.b.containsAll(collection);
|
|
}
|
|
|
|
K d() {
|
|
return this.a;
|
|
}
|
|
|
|
void e() {
|
|
Collection<V> collection;
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection = this.c;
|
|
if (wrappedCollection != null) {
|
|
wrappedCollection.e();
|
|
if (this.c.c() != this.d) {
|
|
throw new ConcurrentModificationException();
|
|
}
|
|
} else {
|
|
if (!this.b.isEmpty() || (collection = (Collection) AbstractMapBasedMultimap.this.map.get(this.a)) == null) {
|
|
return;
|
|
}
|
|
this.b = collection;
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public boolean equals(Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
e();
|
|
return this.b.equals(obj);
|
|
}
|
|
|
|
void f() {
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection = this.c;
|
|
if (wrappedCollection != null) {
|
|
wrappedCollection.f();
|
|
} else if (this.b.isEmpty()) {
|
|
AbstractMapBasedMultimap.this.map.remove(this.a);
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public int hashCode() {
|
|
e();
|
|
return this.b.hashCode();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
|
public Iterator<V> iterator() {
|
|
e();
|
|
return new WrappedIterator();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean remove(Object obj) {
|
|
e();
|
|
boolean remove = this.b.remove(obj);
|
|
if (remove) {
|
|
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
|
f();
|
|
}
|
|
return remove;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean removeAll(Collection<?> collection) {
|
|
if (collection.isEmpty()) {
|
|
return false;
|
|
}
|
|
int size = size();
|
|
boolean removeAll = this.b.removeAll(collection);
|
|
if (removeAll) {
|
|
int size2 = this.b.size();
|
|
AbstractMapBasedMultimap.this.totalSize += size2 - size;
|
|
f();
|
|
}
|
|
return removeAll;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean retainAll(Collection<?> collection) {
|
|
Preconditions.a(collection);
|
|
int size = size();
|
|
boolean retainAll = this.b.retainAll(collection);
|
|
if (retainAll) {
|
|
int size2 = this.b.size();
|
|
AbstractMapBasedMultimap.this.totalSize += size2 - size;
|
|
f();
|
|
}
|
|
return retainAll;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public int size() {
|
|
e();
|
|
return this.b.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection
|
|
public String toString() {
|
|
e();
|
|
return this.b.toString();
|
|
}
|
|
|
|
class WrappedIterator implements Iterator<V> {
|
|
final Iterator<V> a;
|
|
final Collection<V> b;
|
|
|
|
WrappedIterator() {
|
|
this.b = WrappedCollection.this.b;
|
|
this.a = AbstractMapBasedMultimap.iteratorOrListIterator(WrappedCollection.this.b);
|
|
}
|
|
|
|
Iterator<V> a() {
|
|
b();
|
|
return this.a;
|
|
}
|
|
|
|
void b() {
|
|
WrappedCollection.this.e();
|
|
if (WrappedCollection.this.b != this.b) {
|
|
throw new ConcurrentModificationException();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
b();
|
|
return this.a.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public V next() {
|
|
b();
|
|
return this.a.next();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
this.a.remove();
|
|
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
|
WrappedCollection.this.f();
|
|
}
|
|
|
|
WrappedIterator(Iterator<V> it) {
|
|
this.b = WrappedCollection.this.b;
|
|
this.a = it;
|
|
}
|
|
}
|
|
}
|
|
|
|
private class WrappedList extends AbstractMapBasedMultimap<K, V>.WrappedCollection implements List<V> {
|
|
|
|
private class WrappedListIterator extends AbstractMapBasedMultimap<K, V>.WrappedCollection.WrappedIterator implements ListIterator<V> {
|
|
WrappedListIterator() {
|
|
super();
|
|
}
|
|
|
|
private ListIterator<V> c() {
|
|
return (ListIterator) a();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public void add(V v) {
|
|
boolean isEmpty = WrappedList.this.isEmpty();
|
|
c().add(v);
|
|
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
|
|
if (isEmpty) {
|
|
WrappedList.this.a();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public boolean hasPrevious() {
|
|
return c().hasPrevious();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public int nextIndex() {
|
|
return c().nextIndex();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public V previous() {
|
|
return c().previous();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public int previousIndex() {
|
|
return c().previousIndex();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public void set(V v) {
|
|
c().set(v);
|
|
}
|
|
|
|
public WrappedListIterator(int i) {
|
|
super(WrappedList.this.g().listIterator(i));
|
|
}
|
|
}
|
|
|
|
WrappedList(K k, List<V> list, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(k, list, wrappedCollection);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public void add(int i, V v) {
|
|
e();
|
|
boolean isEmpty = c().isEmpty();
|
|
g().add(i, v);
|
|
AbstractMapBasedMultimap.access$208(AbstractMapBasedMultimap.this);
|
|
if (isEmpty) {
|
|
a();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public boolean addAll(int i, Collection<? extends V> collection) {
|
|
if (collection.isEmpty()) {
|
|
return false;
|
|
}
|
|
int size = size();
|
|
boolean addAll = g().addAll(i, collection);
|
|
if (addAll) {
|
|
int size2 = c().size();
|
|
AbstractMapBasedMultimap.this.totalSize += size2 - size;
|
|
if (size == 0) {
|
|
a();
|
|
}
|
|
}
|
|
return addAll;
|
|
}
|
|
|
|
List<V> g() {
|
|
return (List) c();
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public V get(int i) {
|
|
e();
|
|
return g().get(i);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public int indexOf(Object obj) {
|
|
e();
|
|
return g().indexOf(obj);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public int lastIndexOf(Object obj) {
|
|
e();
|
|
return g().lastIndexOf(obj);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public ListIterator<V> listIterator() {
|
|
e();
|
|
return new WrappedListIterator();
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public V remove(int i) {
|
|
e();
|
|
V remove = g().remove(i);
|
|
AbstractMapBasedMultimap.access$210(AbstractMapBasedMultimap.this);
|
|
f();
|
|
return remove;
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public V set(int i, V v) {
|
|
e();
|
|
return g().set(i, v);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public List<V> subList(int i, int i2) {
|
|
e();
|
|
return AbstractMapBasedMultimap.this.wrapList(d(), g().subList(i, i2), b() == null ? this : b());
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public ListIterator<V> listIterator(int i) {
|
|
e();
|
|
return new WrappedListIterator(i);
|
|
}
|
|
}
|
|
}
|