what-the-bank/sources/com/google/common/collect/RegularImmutableMultiset.java

133 lines
4.6 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.Multiset;
import com.google.common.primitives.Ints;
import java.io.Serializable;
import java.util.Set;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class RegularImmutableMultiset<E> extends ImmutableMultiset<E> {
static final RegularImmutableMultiset<Object> EMPTY = new RegularImmutableMultiset<>(ObjectCountHashMap.create());
final transient ObjectCountHashMap<E> contents;
private transient ImmutableSet<E> elementSet;
private final transient int size;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public boolean isPartialView() {
return false;
}
@Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset
public /* bridge */ /* synthetic */ Set elementSet() {
return elementSet();
}
/* JADX INFO: Access modifiers changed from: package-private */
public RegularImmutableMultiset(ObjectCountHashMap<E> objectCountHashMap) {
this.contents = objectCountHashMap;
long j = 0;
for (int i = 0; i < objectCountHashMap.size(); i++) {
j += objectCountHashMap.getValue(i);
}
this.size = Ints.saturatedCast(j);
}
@Override // com.google.common.collect.Multiset
public int count(Object obj) {
return this.contents.get(obj);
}
@Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset
public ImmutableSet<E> elementSet() {
ImmutableSet<E> immutableSet = this.elementSet;
if (immutableSet != null) {
return immutableSet;
}
ElementSet elementSet = new ElementSet();
this.elementSet = elementSet;
return elementSet;
}
/* loaded from: classes2.dex */
final class ElementSet extends IndexedImmutableSet<E> {
final RegularImmutableMultiset this$0;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public final boolean isPartialView() {
return true;
}
private ElementSet(RegularImmutableMultiset regularImmutableMultiset) {
this.this$0 = regularImmutableMultiset;
}
@Override // com.google.common.collect.IndexedImmutableSet
final E get(int i) {
return this.this$0.contents.getKey(i);
}
@Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return this.this$0.contains(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return this.this$0.contents.size();
}
}
@Override // com.google.common.collect.ImmutableMultiset
Multiset.Entry<E> getEntry(int i) {
return this.contents.getEntry(i);
}
/* loaded from: classes2.dex */
static class SerializedForm implements Serializable {
private static final long serialVersionUID = 0;
final int[] counts;
final Object[] elements;
SerializedForm(Multiset<?> multiset) {
int size = multiset.entrySet().size();
this.elements = new Object[size];
this.counts = new int[size];
int i = 0;
for (Multiset.Entry<?> entry : multiset.entrySet()) {
this.elements[i] = entry.getElement();
this.counts[i] = entry.getCount();
i++;
}
}
/* JADX WARN: Multi-variable type inference failed */
Object readResolve() {
ImmutableMultiset.Builder builder = new ImmutableMultiset.Builder(this.elements.length);
int i = 0;
while (true) {
Object[] objArr = this.elements;
if (i < objArr.length) {
builder.addCopies(objArr[i], this.counts[i]);
i++;
} else {
return builder.build();
}
}
}
}
@Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.ImmutableCollection
Object writeReplace() {
return new SerializedForm(this);
}
@Override // java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset
public int size() {
return this.size;
}
}