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

150 lines
5.5 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;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
abstract class DescendingMultiset<E> extends ForwardingMultiset<E> implements SortedMultiset<E> {
@CheckForNull
private transient Comparator<? super E> comparator;
@CheckForNull
private transient NavigableSet<E> elementSet;
@CheckForNull
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
@CheckForNull
public Multiset.Entry<E> pollFirstEntry() {
return forwardMultiset().pollLastEntry();
}
@Override // com.google.common.collect.SortedMultiset
@CheckForNull
public Multiset.Entry<E> pollLastEntry() {
return forwardMultiset().pollFirstEntry();
}
@Override // com.google.common.collect.SortedMultiset
public SortedMultiset<E> headMultiset(@ParametricNullness E e, BoundType boundType) {
return forwardMultiset().tailMultiset(e, boundType).descendingMultiset();
}
@Override // com.google.common.collect.SortedMultiset
public SortedMultiset<E> subMultiset(@ParametricNullness E e, BoundType boundType, @ParametricNullness E e2, BoundType boundType2) {
return forwardMultiset().subMultiset(e2, boundType2, e, boundType).descendingMultiset();
}
@Override // com.google.common.collect.SortedMultiset
public SortedMultiset<E> tailMultiset(@ParametricNullness 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
@CheckForNull
public Multiset.Entry<E> firstEntry() {
return forwardMultiset().lastEntry();
}
@Override // com.google.common.collect.SortedMultiset
@CheckForNull
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>() { // from class: com.google.common.collect.DescendingMultiset.1EntrySetImpl
@Override // com.google.common.collect.Multisets.EntrySet
Multiset<E> multiset() {
return DescendingMultiset.this;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Multiset.Entry<E>> iterator() {
return DescendingMultiset.this.entryIterator();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return DescendingMultiset.this.forwardMultiset().entrySet().size();
}
};
}
@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();
}
}