145 lines
5.3 KiB
Java
145 lines
5.3 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.collect.Multiset;
|
|
import com.google.common.collect.Multisets;
|
|
import com.google.common.collect.SortedMultisets;
|
|
import java.util.Comparator;
|
|
import java.util.Iterator;
|
|
import java.util.NavigableSet;
|
|
import java.util.Set;
|
|
|
|
/* loaded from: classes2.dex */
|
|
abstract class DescendingMultiset<E> extends ForwardingMultiset<E> implements SortedMultiset<E> {
|
|
private transient Comparator<? super E> comparator;
|
|
private transient NavigableSet<E> elementSet;
|
|
private transient Set<Multiset.Entry<E>> entrySet;
|
|
|
|
abstract Iterator<Multiset.Entry<E>> entryIterator();
|
|
|
|
abstract SortedMultiset<E> forwardMultiset();
|
|
|
|
@Override // com.google.common.collect.SortedMultiset, com.google.common.collect.SortedIterable
|
|
public Comparator<? super E> comparator() {
|
|
Comparator<? super E> comparator = this.comparator;
|
|
if (comparator != null) {
|
|
return comparator;
|
|
}
|
|
Ordering reverse = Ordering.from(forwardMultiset().comparator()).reverse();
|
|
this.comparator = reverse;
|
|
return reverse;
|
|
}
|
|
|
|
@Override // com.google.common.collect.ForwardingMultiset, com.google.common.collect.Multiset
|
|
public NavigableSet<E> elementSet() {
|
|
NavigableSet<E> navigableSet = this.elementSet;
|
|
if (navigableSet != null) {
|
|
return navigableSet;
|
|
}
|
|
SortedMultisets.NavigableElementSet navigableElementSet = new SortedMultisets.NavigableElementSet(this);
|
|
this.elementSet = navigableElementSet;
|
|
return navigableElementSet;
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public Multiset.Entry<E> pollFirstEntry() {
|
|
return forwardMultiset().pollLastEntry();
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public Multiset.Entry<E> pollLastEntry() {
|
|
return forwardMultiset().pollFirstEntry();
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public SortedMultiset<E> headMultiset(E e, BoundType boundType) {
|
|
return forwardMultiset().tailMultiset(e, boundType).descendingMultiset();
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public SortedMultiset<E> subMultiset(E e, BoundType boundType, E e2, BoundType boundType2) {
|
|
return forwardMultiset().subMultiset(e2, boundType2, e, boundType).descendingMultiset();
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public SortedMultiset<E> tailMultiset(E e, BoundType boundType) {
|
|
return forwardMultiset().headMultiset(e, boundType).descendingMultiset();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.common.collect.ForwardingMultiset, com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject
|
|
public Multiset<E> delegate() {
|
|
return forwardMultiset();
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public SortedMultiset<E> descendingMultiset() {
|
|
return forwardMultiset();
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public Multiset.Entry<E> firstEntry() {
|
|
return forwardMultiset().lastEntry();
|
|
}
|
|
|
|
@Override // com.google.common.collect.SortedMultiset
|
|
public Multiset.Entry<E> lastEntry() {
|
|
return forwardMultiset().firstEntry();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ForwardingMultiset, com.google.common.collect.Multiset
|
|
public Set<Multiset.Entry<E>> entrySet() {
|
|
Set<Multiset.Entry<E>> set = this.entrySet;
|
|
if (set != null) {
|
|
return set;
|
|
}
|
|
Set<Multiset.Entry<E>> createEntrySet = createEntrySet();
|
|
this.entrySet = createEntrySet;
|
|
return createEntrySet;
|
|
}
|
|
|
|
Set<Multiset.Entry<E>> createEntrySet() {
|
|
return new Multisets.EntrySet<E>(this) { // from class: com.google.common.collect.DescendingMultiset.1EntrySetImpl
|
|
final DescendingMultiset this$0;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<Multiset.Entry<E>> iterator() {
|
|
return this.this$0.entryIterator();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public int size() {
|
|
return this.this$0.forwardMultiset().entrySet().size();
|
|
}
|
|
|
|
@Override // com.google.common.collect.Multisets.EntrySet
|
|
Multiset<E> multiset() {
|
|
return this.this$0;
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<E> iterator() {
|
|
return Multisets.iteratorImpl(this);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set
|
|
public Object[] toArray() {
|
|
return standardToArray();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ForwardingCollection, java.util.Collection, java.util.Set
|
|
public <T> T[] toArray(T[] tArr) {
|
|
return (T[]) standardToArray(tArr);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ForwardingObject
|
|
public String toString() {
|
|
return entrySet().toString();
|
|
}
|
|
}
|