1503 lines
55 KiB
Java
1503 lines
55 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.collect.AbstractMultimap;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Multimaps;
|
|
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;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public 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;
|
|
|
|
abstract Collection<V> createCollection();
|
|
|
|
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;
|
|
}
|
|
|
|
static /* synthetic */ int access$212(AbstractMapBasedMultimap abstractMapBasedMultimap, int i) {
|
|
int i2 = abstractMapBasedMultimap.totalSize + i;
|
|
abstractMapBasedMultimap.totalSize = i2;
|
|
return i2;
|
|
}
|
|
|
|
static /* synthetic */ int access$220(AbstractMapBasedMultimap abstractMapBasedMultimap, int i) {
|
|
int i2 = abstractMapBasedMultimap.totalSize - i;
|
|
abstractMapBasedMultimap.totalSize = i2;
|
|
return i2;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public AbstractMapBasedMultimap(Map<K, Collection<V>> map) {
|
|
Preconditions.checkArgument(map.isEmpty());
|
|
this.map = map;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void setMap(Map<K, Collection<V>> map) {
|
|
this.map = map;
|
|
this.totalSize = 0;
|
|
for (Collection<V> collection : map.values()) {
|
|
Preconditions.checkArgument(!collection.isEmpty());
|
|
this.totalSize += collection.size();
|
|
}
|
|
}
|
|
|
|
Collection<V> createUnmodifiableEmptyCollection() {
|
|
return (Collection<V>) unmodifiableCollectionSubclass(createCollection());
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public Collection<V> createCollection(K k) {
|
|
return createCollection();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multimap
|
|
public boolean containsKey(Object obj) {
|
|
return this.map.containsKey(obj);
|
|
}
|
|
|
|
@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) {
|
|
Collection<V> createCollection = createCollection(k);
|
|
if (createCollection.add(v)) {
|
|
this.totalSize++;
|
|
this.map.put(k, createCollection);
|
|
return true;
|
|
}
|
|
throw new AssertionError("New Collection violated the Collection spec");
|
|
}
|
|
if (!collection.add(v)) {
|
|
return false;
|
|
}
|
|
this.totalSize++;
|
|
return true;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
|
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 (Collection<V>) unmodifiableCollectionSubclass(createCollection);
|
|
}
|
|
|
|
@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 createCollection = createCollection();
|
|
createCollection.addAll(remove);
|
|
this.totalSize -= remove.size();
|
|
remove.clear();
|
|
return (Collection<V>) unmodifiableCollectionSubclass(createCollection);
|
|
}
|
|
|
|
<E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
|
|
return Collections.unmodifiableCollection(collection);
|
|
}
|
|
|
|
@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 Collection<V> get(K k) {
|
|
Collection<V> collection = this.map.get(k);
|
|
if (collection == null) {
|
|
collection = createCollection(k);
|
|
}
|
|
return wrapCollection(k, collection);
|
|
}
|
|
|
|
Collection<V> wrapCollection(K k, Collection<V> collection) {
|
|
return new WrappedCollection(this, k, collection, null);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final List<V> wrapList(K k, List<V> list, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
if (list instanceof RandomAccess) {
|
|
return new RandomAccessWrappedList(this, k, list, wrappedCollection);
|
|
}
|
|
return new WrappedList(this, k, list, wrappedCollection);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class WrappedCollection extends AbstractCollection<V> {
|
|
final AbstractMapBasedMultimap<K, V>.WrappedCollection ancestor;
|
|
final Collection<V> ancestorDelegate;
|
|
Collection<V> delegate;
|
|
final K key;
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public WrappedCollection(AbstractMapBasedMultimap abstractMapBasedMultimap, K k, Collection<V> collection, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
this.key = k;
|
|
this.delegate = collection;
|
|
this.ancestor = wrappedCollection;
|
|
this.ancestorDelegate = wrappedCollection == null ? null : wrappedCollection.getDelegate();
|
|
}
|
|
|
|
void refreshIfEmpty() {
|
|
Collection<V> collection;
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection = this.ancestor;
|
|
if (wrappedCollection != null) {
|
|
wrappedCollection.refreshIfEmpty();
|
|
if (this.ancestor.getDelegate() != this.ancestorDelegate) {
|
|
throw new ConcurrentModificationException();
|
|
}
|
|
} else {
|
|
if (!this.delegate.isEmpty() || (collection = (Collection) this.this$0.map.get(this.key)) == null) {
|
|
return;
|
|
}
|
|
this.delegate = collection;
|
|
}
|
|
}
|
|
|
|
void removeIfEmpty() {
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection = this.ancestor;
|
|
if (wrappedCollection != null) {
|
|
wrappedCollection.removeIfEmpty();
|
|
} else if (this.delegate.isEmpty()) {
|
|
this.this$0.map.remove(this.key);
|
|
}
|
|
}
|
|
|
|
void addToMap() {
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection = this.ancestor;
|
|
if (wrappedCollection == null) {
|
|
this.this$0.map.put(this.key, this.delegate);
|
|
} else {
|
|
wrappedCollection.addToMap();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public int size() {
|
|
refreshIfEmpty();
|
|
return this.delegate.size();
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public boolean equals(Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
refreshIfEmpty();
|
|
return this.delegate.equals(obj);
|
|
}
|
|
|
|
@Override // java.util.Collection
|
|
public int hashCode() {
|
|
refreshIfEmpty();
|
|
return this.delegate.hashCode();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection
|
|
public String toString() {
|
|
refreshIfEmpty();
|
|
return this.delegate.toString();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
|
public Iterator<V> iterator() {
|
|
refreshIfEmpty();
|
|
return new WrappedIterator(this);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class WrappedIterator implements Iterator<V> {
|
|
final Iterator<V> delegateIterator;
|
|
final Collection<V> originalDelegate;
|
|
final WrappedCollection this$1;
|
|
|
|
WrappedIterator(WrappedCollection wrappedCollection) {
|
|
this.this$1 = wrappedCollection;
|
|
this.originalDelegate = wrappedCollection.delegate;
|
|
this.delegateIterator = AbstractMapBasedMultimap.iteratorOrListIterator(wrappedCollection.delegate);
|
|
}
|
|
|
|
WrappedIterator(WrappedCollection wrappedCollection, Iterator<V> it) {
|
|
this.this$1 = wrappedCollection;
|
|
this.originalDelegate = wrappedCollection.delegate;
|
|
this.delegateIterator = it;
|
|
}
|
|
|
|
void validateIterator() {
|
|
this.this$1.refreshIfEmpty();
|
|
if (this.this$1.delegate != this.originalDelegate) {
|
|
throw new ConcurrentModificationException();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
validateIterator();
|
|
return this.delegateIterator.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public V next() {
|
|
validateIterator();
|
|
return this.delegateIterator.next();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
this.delegateIterator.remove();
|
|
AbstractMapBasedMultimap.access$210(this.this$1.this$0);
|
|
this.this$1.removeIfEmpty();
|
|
}
|
|
|
|
Iterator<V> getDelegateIterator() {
|
|
validateIterator();
|
|
return this.delegateIterator;
|
|
}
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean add(V v) {
|
|
refreshIfEmpty();
|
|
boolean isEmpty = this.delegate.isEmpty();
|
|
boolean add = this.delegate.add(v);
|
|
if (add) {
|
|
AbstractMapBasedMultimap.access$208(this.this$0);
|
|
if (isEmpty) {
|
|
addToMap();
|
|
}
|
|
}
|
|
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.delegate.addAll(collection);
|
|
if (addAll) {
|
|
AbstractMapBasedMultimap.access$212(this.this$0, this.delegate.size() - size);
|
|
if (size == 0) {
|
|
addToMap();
|
|
}
|
|
}
|
|
return addAll;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean contains(Object obj) {
|
|
refreshIfEmpty();
|
|
return this.delegate.contains(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean containsAll(Collection<?> collection) {
|
|
refreshIfEmpty();
|
|
return this.delegate.containsAll(collection);
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public void clear() {
|
|
int size = size();
|
|
if (size == 0) {
|
|
return;
|
|
}
|
|
this.delegate.clear();
|
|
AbstractMapBasedMultimap.access$220(this.this$0, size);
|
|
removeIfEmpty();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean remove(Object obj) {
|
|
refreshIfEmpty();
|
|
boolean remove = this.delegate.remove(obj);
|
|
if (remove) {
|
|
AbstractMapBasedMultimap.access$210(this.this$0);
|
|
removeIfEmpty();
|
|
}
|
|
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.delegate.removeAll(collection);
|
|
if (removeAll) {
|
|
AbstractMapBasedMultimap.access$212(this.this$0, this.delegate.size() - size);
|
|
removeIfEmpty();
|
|
}
|
|
return removeAll;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public boolean retainAll(Collection<?> collection) {
|
|
Preconditions.checkNotNull(collection);
|
|
int size = size();
|
|
boolean retainAll = this.delegate.retainAll(collection);
|
|
if (retainAll) {
|
|
AbstractMapBasedMultimap.access$212(this.this$0, this.delegate.size() - size);
|
|
removeIfEmpty();
|
|
}
|
|
return retainAll;
|
|
}
|
|
|
|
K getKey() {
|
|
return this.key;
|
|
}
|
|
|
|
Collection<V> getDelegate() {
|
|
return this.delegate;
|
|
}
|
|
|
|
AbstractMapBasedMultimap<K, V>.WrappedCollection getAncestor() {
|
|
return this.ancestor;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static <E> Iterator<E> iteratorOrListIterator(Collection<E> collection) {
|
|
if (collection instanceof List) {
|
|
return ((List) collection).listIterator();
|
|
}
|
|
return collection.iterator();
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
class WrappedSet extends WrappedCollection implements Set {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public WrappedSet(AbstractMapBasedMultimap abstractMapBasedMultimap, K k, Set<V> set) {
|
|
super(abstractMapBasedMultimap, k, set, null);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
@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 removeAllImpl = Sets.removeAllImpl((Set<?>) this.delegate, collection);
|
|
if (removeAllImpl) {
|
|
AbstractMapBasedMultimap.access$212(this.this$0, this.delegate.size() - size);
|
|
removeIfEmpty();
|
|
}
|
|
return removeAllImpl;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class WrappedSortedSet extends WrappedCollection implements SortedSet {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public WrappedSortedSet(AbstractMapBasedMultimap abstractMapBasedMultimap, K k, SortedSet<V> sortedSet, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(abstractMapBasedMultimap, k, sortedSet, wrappedCollection);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
SortedSet<V> getSortedSetDelegate() {
|
|
return (SortedSet) getDelegate();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public Comparator<? super V> comparator() {
|
|
return getSortedSetDelegate().comparator();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public V first() {
|
|
refreshIfEmpty();
|
|
return getSortedSetDelegate().first();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public V last() {
|
|
refreshIfEmpty();
|
|
return getSortedSetDelegate().last();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public SortedSet<V> headSet(V v) {
|
|
refreshIfEmpty();
|
|
return new WrappedSortedSet(this.this$0, getKey(), getSortedSetDelegate().headSet(v), getAncestor() == null ? this : getAncestor());
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public SortedSet<V> subSet(V v, V v2) {
|
|
refreshIfEmpty();
|
|
return new WrappedSortedSet(this.this$0, getKey(), getSortedSetDelegate().subSet(v, v2), getAncestor() == null ? this : getAncestor());
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public SortedSet<V> tailSet(V v) {
|
|
refreshIfEmpty();
|
|
return new WrappedSortedSet(this.this$0, getKey(), getSortedSetDelegate().tailSet(v), getAncestor() == null ? this : getAncestor());
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
class WrappedNavigableSet extends WrappedSortedSet implements NavigableSet {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public WrappedNavigableSet(AbstractMapBasedMultimap abstractMapBasedMultimap, K k, NavigableSet<V> navigableSet, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(abstractMapBasedMultimap, k, navigableSet, wrappedCollection);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.WrappedSortedSet
|
|
public NavigableSet<V> getSortedSetDelegate() {
|
|
return (NavigableSet) super.getSortedSetDelegate();
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V lower(V v) {
|
|
return getSortedSetDelegate().lower(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V floor(V v) {
|
|
return getSortedSetDelegate().floor(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V ceiling(V v) {
|
|
return getSortedSetDelegate().ceiling(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V higher(V v) {
|
|
return getSortedSetDelegate().higher(v);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V pollFirst() {
|
|
return (V) Iterators.pollNext(iterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public V pollLast() {
|
|
return (V) Iterators.pollNext(descendingIterator());
|
|
}
|
|
|
|
private NavigableSet<V> wrap(NavigableSet<V> navigableSet) {
|
|
return new WrappedNavigableSet(this.this$0, this.key, navigableSet, getAncestor() == null ? this : getAncestor());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> descendingSet() {
|
|
return wrap(getSortedSetDelegate().descendingSet());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public Iterator<V> descendingIterator() {
|
|
return new WrappedCollection.WrappedIterator(this, getSortedSetDelegate().descendingIterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> subSet(V v, boolean z, V v2, boolean z2) {
|
|
return wrap(getSortedSetDelegate().subSet(v, z, v2, z2));
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> headSet(V v, boolean z) {
|
|
return wrap(getSortedSetDelegate().headSet(v, z));
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<V> tailSet(V v, boolean z) {
|
|
return wrap(getSortedSetDelegate().tailSet(v, z));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class WrappedList extends WrappedCollection implements List {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
WrappedList(AbstractMapBasedMultimap abstractMapBasedMultimap, K k, List<V> list, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(abstractMapBasedMultimap, k, list, wrappedCollection);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
List<V> getListDelegate() {
|
|
return (List) getDelegate();
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public boolean addAll(int i, Collection<? extends V> collection) {
|
|
if (collection.isEmpty()) {
|
|
return false;
|
|
}
|
|
int size = size();
|
|
boolean addAll = getListDelegate().addAll(i, collection);
|
|
if (addAll) {
|
|
AbstractMapBasedMultimap.access$212(this.this$0, getDelegate().size() - size);
|
|
if (size == 0) {
|
|
addToMap();
|
|
}
|
|
}
|
|
return addAll;
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public V get(int i) {
|
|
refreshIfEmpty();
|
|
return getListDelegate().get(i);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public V set(int i, V v) {
|
|
refreshIfEmpty();
|
|
return getListDelegate().set(i, v);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public void add(int i, V v) {
|
|
refreshIfEmpty();
|
|
boolean isEmpty = getDelegate().isEmpty();
|
|
getListDelegate().add(i, v);
|
|
AbstractMapBasedMultimap.access$208(this.this$0);
|
|
if (isEmpty) {
|
|
addToMap();
|
|
}
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public V remove(int i) {
|
|
refreshIfEmpty();
|
|
V remove = getListDelegate().remove(i);
|
|
AbstractMapBasedMultimap.access$210(this.this$0);
|
|
removeIfEmpty();
|
|
return remove;
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public int indexOf(Object obj) {
|
|
refreshIfEmpty();
|
|
return getListDelegate().indexOf(obj);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public int lastIndexOf(Object obj) {
|
|
refreshIfEmpty();
|
|
return getListDelegate().lastIndexOf(obj);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public ListIterator<V> listIterator() {
|
|
refreshIfEmpty();
|
|
return new WrappedListIterator(this);
|
|
}
|
|
|
|
@Override // java.util.List
|
|
public ListIterator<V> listIterator(int i) {
|
|
refreshIfEmpty();
|
|
return new WrappedListIterator(this, i);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // java.util.List
|
|
public List<V> subList(int i, int i2) {
|
|
refreshIfEmpty();
|
|
return this.this$0.wrapList(getKey(), getListDelegate().subList(i, i2), getAncestor() == null ? this : getAncestor());
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
class WrappedListIterator extends WrappedCollection.WrappedIterator implements ListIterator {
|
|
final WrappedList this$1;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
WrappedListIterator(WrappedList wrappedList) {
|
|
super(wrappedList);
|
|
this.this$1 = wrappedList;
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public WrappedListIterator(WrappedList wrappedList, int i) {
|
|
super(wrappedList, wrappedList.getListDelegate().listIterator(i));
|
|
this.this$1 = wrappedList;
|
|
}
|
|
|
|
private ListIterator<V> getDelegateListIterator() {
|
|
return (ListIterator) getDelegateIterator();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public boolean hasPrevious() {
|
|
return getDelegateListIterator().hasPrevious();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public V previous() {
|
|
return getDelegateListIterator().previous();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public int nextIndex() {
|
|
return getDelegateListIterator().nextIndex();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public int previousIndex() {
|
|
return getDelegateListIterator().previousIndex();
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public void set(V v) {
|
|
getDelegateListIterator().set(v);
|
|
}
|
|
|
|
@Override // java.util.ListIterator
|
|
public void add(V v) {
|
|
boolean isEmpty = this.this$1.isEmpty();
|
|
getDelegateListIterator().add(v);
|
|
AbstractMapBasedMultimap.access$208(this.this$1.this$0);
|
|
if (isEmpty) {
|
|
this.this$1.addToMap();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class RandomAccessWrappedList extends WrappedList implements RandomAccess {
|
|
RandomAccessWrappedList(AbstractMapBasedMultimap abstractMapBasedMultimap, K k, List<V> list, AbstractMapBasedMultimap<K, V>.WrappedCollection wrappedCollection) {
|
|
super(abstractMapBasedMultimap, k, list, wrappedCollection);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Set<K> createKeySet() {
|
|
return new KeySet(this, this.map);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final Set<K> createMaybeNavigableKeySet() {
|
|
Map<K, Collection<V>> map = this.map;
|
|
if (map instanceof NavigableMap) {
|
|
return new NavigableKeySet(this, (NavigableMap) this.map);
|
|
}
|
|
if (map instanceof SortedMap) {
|
|
return new SortedKeySet(this, (SortedMap) this.map);
|
|
}
|
|
return new KeySet(this, this.map);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
class KeySet extends Maps.KeySet<K, Collection<V>> {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
KeySet(AbstractMapBasedMultimap abstractMapBasedMultimap, Map<K, Collection<V>> map) {
|
|
super(map);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<K> iterator() {
|
|
return new Iterator<K>(this, map().entrySet().iterator()) { // from class: com.google.common.collect.AbstractMapBasedMultimap.KeySet.1
|
|
Map.Entry<K, Collection<V>> entry;
|
|
final KeySet this$1;
|
|
final Iterator val$entryIterator;
|
|
|
|
{
|
|
this.this$1 = this;
|
|
this.val$entryIterator = r2;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.val$entryIterator.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public K next() {
|
|
Map.Entry<K, Collection<V>> entry = (Map.Entry) this.val$entryIterator.next();
|
|
this.entry = entry;
|
|
return entry.getKey();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
CollectPreconditions.checkRemove(this.entry != null);
|
|
Collection<V> value = this.entry.getValue();
|
|
this.val$entryIterator.remove();
|
|
AbstractMapBasedMultimap.access$220(this.this$1.this$0, value.size());
|
|
value.clear();
|
|
this.entry = null;
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean remove(Object obj) {
|
|
Collection<V> remove = map().remove(obj);
|
|
if (remove != null) {
|
|
int size = remove.size();
|
|
remove.clear();
|
|
AbstractMapBasedMultimap.access$220(this.this$0, size);
|
|
if (size > 0) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.KeySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public void clear() {
|
|
Iterators.clear(iterator());
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean containsAll(Collection<?> collection) {
|
|
return map().keySet().containsAll(collection);
|
|
}
|
|
|
|
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
|
|
public boolean equals(Object obj) {
|
|
return this == obj || map().keySet().equals(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractSet, java.util.Collection, java.util.Set
|
|
public int hashCode() {
|
|
return map().keySet().hashCode();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class SortedKeySet extends KeySet implements SortedSet {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
SortedKeySet(AbstractMapBasedMultimap abstractMapBasedMultimap, SortedMap<K, Collection<V>> sortedMap) {
|
|
super(abstractMapBasedMultimap, sortedMap);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
SortedMap<K, Collection<V>> sortedMap() {
|
|
return (SortedMap) super.map();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public Comparator<? super K> comparator() {
|
|
return sortedMap().comparator();
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public K first() {
|
|
return sortedMap().firstKey();
|
|
}
|
|
|
|
public SortedSet<K> headSet(K k) {
|
|
return new SortedKeySet(this.this$0, sortedMap().headMap(k));
|
|
}
|
|
|
|
@Override // java.util.SortedSet
|
|
public K last() {
|
|
return sortedMap().lastKey();
|
|
}
|
|
|
|
public SortedSet<K> subSet(K k, K k2) {
|
|
return new SortedKeySet(this.this$0, sortedMap().subMap(k, k2));
|
|
}
|
|
|
|
public SortedSet<K> tailSet(K k) {
|
|
return new SortedKeySet(this.this$0, sortedMap().tailMap(k));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class NavigableKeySet extends SortedKeySet implements NavigableSet {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
@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 // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
|
|
public /* bridge */ /* synthetic */ SortedSet tailSet(Object obj) {
|
|
return tailSet((NavigableKeySet) obj);
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
NavigableKeySet(AbstractMapBasedMultimap abstractMapBasedMultimap, NavigableMap<K, Collection<V>> navigableMap) {
|
|
super(abstractMapBasedMultimap, navigableMap);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet
|
|
public NavigableMap<K, Collection<V>> sortedMap() {
|
|
return (NavigableMap) super.sortedMap();
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K lower(K k) {
|
|
return sortedMap().lowerKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K floor(K k) {
|
|
return sortedMap().floorKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K ceiling(K k) {
|
|
return sortedMap().ceilingKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K higher(K k) {
|
|
return sortedMap().higherKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K pollFirst() {
|
|
return (K) Iterators.pollNext(iterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public K pollLast() {
|
|
return (K) Iterators.pollNext(descendingIterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<K> descendingSet() {
|
|
return new NavigableKeySet(this.this$0, sortedMap().descendingMap());
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public Iterator<K> descendingIterator() {
|
|
return descendingSet().iterator();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedKeySet, java.util.SortedSet, java.util.NavigableSet
|
|
public NavigableSet<K> headSet(K k) {
|
|
return headSet(k, false);
|
|
}
|
|
|
|
@Override // java.util.NavigableSet
|
|
public NavigableSet<K> headSet(K k, boolean z) {
|
|
return new NavigableKeySet(this.this$0, sortedMap().headMap(k, z));
|
|
}
|
|
|
|
@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 // java.util.NavigableSet
|
|
public NavigableSet<K> subSet(K k, boolean z, K k2, boolean z2) {
|
|
return new NavigableKeySet(this.this$0, sortedMap().subMap(k, z, k2, z2));
|
|
}
|
|
|
|
@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> tailSet(K k, boolean z) {
|
|
return new NavigableKeySet(this.this$0, sortedMap().tailMap(k, z));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void removeValuesForKey(Object obj) {
|
|
Collection collection = (Collection) Maps.safeRemove(this.map, obj);
|
|
if (collection != null) {
|
|
int size = collection.size();
|
|
collection.clear();
|
|
this.totalSize -= size;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
abstract class Itr<T> implements Iterator<T> {
|
|
final Iterator<Map.Entry<K, Collection<V>>> keyIterator;
|
|
final AbstractMapBasedMultimap this$0;
|
|
K key = null;
|
|
Collection<V> collection = null;
|
|
Iterator<V> valueIterator = Iterators.emptyModifiableIterator();
|
|
|
|
abstract T output(K k, V v);
|
|
|
|
Itr(AbstractMapBasedMultimap abstractMapBasedMultimap) {
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
this.keyIterator = abstractMapBasedMultimap.map.entrySet().iterator();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.keyIterator.hasNext() || this.valueIterator.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public T next() {
|
|
if (!this.valueIterator.hasNext()) {
|
|
Map.Entry<K, Collection<V>> next = this.keyIterator.next();
|
|
this.key = next.getKey();
|
|
Collection<V> value = next.getValue();
|
|
this.collection = value;
|
|
this.valueIterator = value.iterator();
|
|
}
|
|
return output(this.key, this.valueIterator.next());
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
this.valueIterator.remove();
|
|
if (this.collection.isEmpty()) {
|
|
this.keyIterator.remove();
|
|
}
|
|
AbstractMapBasedMultimap.access$210(this.this$0);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
|
public Collection<V> values() {
|
|
return super.values();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Collection<V> createValues() {
|
|
return new AbstractMultimap.Values(this);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Iterator<V> valueIterator() {
|
|
return new Itr(this) { // from class: com.google.common.collect.AbstractMapBasedMultimap.1
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.Itr
|
|
V output(K k, V v) {
|
|
return v;
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Multiset<K> createKeys() {
|
|
return new Multimaps.Keys(this);
|
|
}
|
|
|
|
@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
|
|
Collection<Map.Entry<K, V>> createEntries() {
|
|
if (this instanceof SetMultimap) {
|
|
return new AbstractMultimap.EntrySet(this);
|
|
}
|
|
return new AbstractMultimap.Entries(this);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Iterator<Map.Entry<K, V>> entryIterator() {
|
|
return new Itr(this) { // from class: com.google.common.collect.AbstractMapBasedMultimap.2
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.Itr
|
|
/* bridge */ /* synthetic */ Object output(Object obj, Object obj2) {
|
|
return output((AnonymousClass2) obj, obj2);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.Itr
|
|
Map.Entry<K, V> output(K k, V v) {
|
|
return Maps.immutableEntry(k, v);
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractMultimap
|
|
Map<K, Collection<V>> createAsMap() {
|
|
return new AsMap(this, this.map);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final Map<K, Collection<V>> createMaybeNavigableAsMap() {
|
|
Map<K, Collection<V>> map = this.map;
|
|
if (map instanceof NavigableMap) {
|
|
return new NavigableAsMap(this, (NavigableMap) this.map);
|
|
}
|
|
if (map instanceof SortedMap) {
|
|
return new SortedAsMap(this, (SortedMap) this.map);
|
|
}
|
|
return new AsMap(this, this.map);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class AsMap extends Maps.ViewCachingAbstractMap<K, Collection<V>> {
|
|
final transient Map<K, Collection<V>> submap;
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
AsMap(AbstractMapBasedMultimap abstractMapBasedMultimap, Map<K, Collection<V>> map) {
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
this.submap = map;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
protected Set<Map.Entry<K, Collection<V>>> createEntrySet() {
|
|
return new AsMapEntries(this);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean containsKey(Object obj) {
|
|
return Maps.safeContainsKey(this.submap, obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Collection<V> get(Object obj) {
|
|
Collection<V> collection = (Collection) Maps.safeGet(this.submap, obj);
|
|
if (collection == null) {
|
|
return null;
|
|
}
|
|
return this.this$0.wrapCollection(obj, collection);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
|
|
public Set<K> keySet() {
|
|
return this.this$0.keySet();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public int size() {
|
|
return this.submap.size();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public Collection<V> remove(Object obj) {
|
|
Collection<V> remove = this.submap.remove(obj);
|
|
if (remove == null) {
|
|
return null;
|
|
}
|
|
Collection<V> createCollection = this.this$0.createCollection();
|
|
createCollection.addAll(remove);
|
|
AbstractMapBasedMultimap.access$220(this.this$0, remove.size());
|
|
remove.clear();
|
|
return createCollection;
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public boolean equals(Object obj) {
|
|
return this == obj || this.submap.equals(obj);
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public int hashCode() {
|
|
return this.submap.hashCode();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap
|
|
public String toString() {
|
|
return this.submap.toString();
|
|
}
|
|
|
|
@Override // java.util.AbstractMap, java.util.Map
|
|
public void clear() {
|
|
if (this.submap == this.this$0.map) {
|
|
this.this$0.clear();
|
|
} else {
|
|
Iterators.clear(new AsMapIterator(this));
|
|
}
|
|
}
|
|
|
|
Map.Entry<K, Collection<V>> wrapEntry(Map.Entry<K, Collection<V>> entry) {
|
|
K key = entry.getKey();
|
|
return Maps.immutableEntry(key, this.this$0.wrapCollection(key, entry.getValue()));
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
class AsMapEntries extends Maps.EntrySet<K, Collection<V>> {
|
|
final AsMap this$1;
|
|
|
|
AsMapEntries(AsMap asMap) {
|
|
this.this$1 = asMap;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<Map.Entry<K, Collection<V>>> iterator() {
|
|
return new AsMapIterator(this.this$1);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public boolean contains(Object obj) {
|
|
return Collections2.safeContains(this.this$1.submap.entrySet(), obj);
|
|
}
|
|
|
|
@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;
|
|
}
|
|
this.this$1.this$0.removeValuesForKey(((Map.Entry) obj).getKey());
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.common.collect.Maps.EntrySet
|
|
Map<K, Collection<V>> map() {
|
|
return this.this$1;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
class AsMapIterator implements Iterator<Map.Entry<K, Collection<V>>> {
|
|
Collection<V> collection;
|
|
final Iterator<Map.Entry<K, Collection<V>>> delegateIterator;
|
|
final AsMap this$1;
|
|
|
|
AsMapIterator(AsMap asMap) {
|
|
this.this$1 = asMap;
|
|
this.delegateIterator = asMap.submap.entrySet().iterator();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.delegateIterator.hasNext();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public Map.Entry<K, Collection<V>> next() {
|
|
Map.Entry<K, Collection<V>> next = this.delegateIterator.next();
|
|
this.collection = next.getValue();
|
|
return this.this$1.wrapEntry(next);
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
CollectPreconditions.checkRemove(this.collection != null);
|
|
this.delegateIterator.remove();
|
|
AbstractMapBasedMultimap.access$220(this.this$1.this$0, this.collection.size());
|
|
this.collection.clear();
|
|
this.collection = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class SortedAsMap extends AsMap implements SortedMap {
|
|
SortedSet<K> sortedKeySet;
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
SortedAsMap(AbstractMapBasedMultimap abstractMapBasedMultimap, SortedMap<K, Collection<V>> sortedMap) {
|
|
super(abstractMapBasedMultimap, sortedMap);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
SortedMap<K, Collection<V>> sortedMap() {
|
|
return (SortedMap) this.submap;
|
|
}
|
|
|
|
@Override // java.util.SortedMap
|
|
public Comparator<? super K> comparator() {
|
|
return sortedMap().comparator();
|
|
}
|
|
|
|
@Override // java.util.SortedMap
|
|
public K firstKey() {
|
|
return sortedMap().firstKey();
|
|
}
|
|
|
|
@Override // java.util.SortedMap
|
|
public K lastKey() {
|
|
return sortedMap().lastKey();
|
|
}
|
|
|
|
public SortedMap<K, Collection<V>> headMap(K k) {
|
|
return new SortedAsMap(this.this$0, sortedMap().headMap(k));
|
|
}
|
|
|
|
public SortedMap<K, Collection<V>> subMap(K k, K k2) {
|
|
return new SortedAsMap(this.this$0, sortedMap().subMap(k, k2));
|
|
}
|
|
|
|
public SortedMap<K, Collection<V>> tailMap(K k) {
|
|
return new SortedAsMap(this.this$0, sortedMap().tailMap(k));
|
|
}
|
|
|
|
@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.sortedKeySet;
|
|
if (sortedSet != null) {
|
|
return sortedSet;
|
|
}
|
|
SortedSet<K> createKeySet = createKeySet();
|
|
this.sortedKeySet = createKeySet;
|
|
return createKeySet;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
public SortedSet<K> createKeySet() {
|
|
return new SortedKeySet(this.this$0, sortedMap());
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
class NavigableAsMap extends SortedAsMap implements NavigableMap {
|
|
final AbstractMapBasedMultimap this$0;
|
|
|
|
@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 // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, java.util.SortedMap, java.util.NavigableMap
|
|
public /* bridge */ /* synthetic */ SortedMap tailMap(Object obj) {
|
|
return tailMap((NavigableAsMap) obj);
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
NavigableAsMap(AbstractMapBasedMultimap abstractMapBasedMultimap, NavigableMap<K, Collection<V>> navigableMap) {
|
|
super(abstractMapBasedMultimap, navigableMap);
|
|
this.this$0 = abstractMapBasedMultimap;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap
|
|
public NavigableMap<K, Collection<V>> sortedMap() {
|
|
return (NavigableMap) super.sortedMap();
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> lowerEntry(K k) {
|
|
Map.Entry<K, Collection<V>> lowerEntry = sortedMap().lowerEntry(k);
|
|
if (lowerEntry == null) {
|
|
return null;
|
|
}
|
|
return wrapEntry(lowerEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K lowerKey(K k) {
|
|
return sortedMap().lowerKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> floorEntry(K k) {
|
|
Map.Entry<K, Collection<V>> floorEntry = sortedMap().floorEntry(k);
|
|
if (floorEntry == null) {
|
|
return null;
|
|
}
|
|
return wrapEntry(floorEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K floorKey(K k) {
|
|
return sortedMap().floorKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> ceilingEntry(K k) {
|
|
Map.Entry<K, Collection<V>> ceilingEntry = sortedMap().ceilingEntry(k);
|
|
if (ceilingEntry == null) {
|
|
return null;
|
|
}
|
|
return wrapEntry(ceilingEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K ceilingKey(K k) {
|
|
return sortedMap().ceilingKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> higherEntry(K k) {
|
|
Map.Entry<K, Collection<V>> higherEntry = sortedMap().higherEntry(k);
|
|
if (higherEntry == null) {
|
|
return null;
|
|
}
|
|
return wrapEntry(higherEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public K higherKey(K k) {
|
|
return sortedMap().higherKey(k);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> firstEntry() {
|
|
Map.Entry<K, Collection<V>> firstEntry = sortedMap().firstEntry();
|
|
if (firstEntry == null) {
|
|
return null;
|
|
}
|
|
return wrapEntry(firstEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> lastEntry() {
|
|
Map.Entry<K, Collection<V>> lastEntry = sortedMap().lastEntry();
|
|
if (lastEntry == null) {
|
|
return null;
|
|
}
|
|
return wrapEntry(lastEntry);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> pollFirstEntry() {
|
|
return pollAsMapEntry(entrySet().iterator());
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public Map.Entry<K, Collection<V>> pollLastEntry() {
|
|
return pollAsMapEntry(descendingMap().entrySet().iterator());
|
|
}
|
|
|
|
Map.Entry<K, Collection<V>> pollAsMapEntry(Iterator<Map.Entry<K, Collection<V>>> it) {
|
|
if (!it.hasNext()) {
|
|
return null;
|
|
}
|
|
Map.Entry<K, Collection<V>> next = it.next();
|
|
Collection<V> createCollection = this.this$0.createCollection();
|
|
createCollection.addAll(next.getValue());
|
|
it.remove();
|
|
return Maps.immutableEntry(next.getKey(), this.this$0.unmodifiableCollectionSubclass(createCollection));
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> descendingMap() {
|
|
return new NavigableAsMap(this.this$0, sortedMap().descendingMap());
|
|
}
|
|
|
|
@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();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractMapBasedMultimap.SortedAsMap, com.google.common.collect.Maps.ViewCachingAbstractMap
|
|
public NavigableSet<K> createKeySet() {
|
|
return new NavigableKeySet(this.this$0, sortedMap());
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableSet<K> navigableKeySet() {
|
|
return keySet();
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableSet<K> descendingKeySet() {
|
|
return descendingMap().navigableKeySet();
|
|
}
|
|
|
|
@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 // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> subMap(K k, boolean z, K k2, boolean z2) {
|
|
return new NavigableAsMap(this.this$0, sortedMap().subMap(k, z, k2, z2));
|
|
}
|
|
|
|
@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 // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> headMap(K k, boolean z) {
|
|
return new NavigableAsMap(this.this$0, sortedMap().headMap(k, z));
|
|
}
|
|
|
|
@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);
|
|
}
|
|
|
|
@Override // java.util.NavigableMap
|
|
public NavigableMap<K, Collection<V>> tailMap(K k, boolean z) {
|
|
return new NavigableAsMap(this.this$0, sortedMap().tailMap(k, z));
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multimap
|
|
public int size() {
|
|
return this.totalSize;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public Map<K, Collection<V>> backingMap() {
|
|
return this.map;
|
|
}
|
|
}
|