package com.google.common.collect; import com.google.common.collect.ImmutableMultiset; import com.google.common.collect.Multiset; import com.google.common.primitives.Ints; import com.google.errorprone.annotations.concurrent.LazyInit; import java.io.Serializable; import javax.annotation.CheckForNull; /* JADX INFO: Access modifiers changed from: package-private */ @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public class RegularImmutableMultiset extends ImmutableMultiset { static final RegularImmutableMultiset EMPTY = new RegularImmutableMultiset<>(ObjectCountHashMap.create()); final transient ObjectCountHashMap contents; @CheckForNull @LazyInit private transient ImmutableSet 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 // java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset public int size() { return this.size; } /* JADX INFO: Access modifiers changed from: package-private */ public RegularImmutableMultiset(ObjectCountHashMap 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(@CheckForNull Object obj) { return this.contents.get(obj); } @Override // com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public ImmutableSet elementSet() { ImmutableSet immutableSet = this.elementSet; if (immutableSet != null) { return immutableSet; } ElementSet elementSet = new ElementSet(); this.elementSet = elementSet; return elementSet; } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public final class ElementSet extends IndexedImmutableSet { /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public boolean isPartialView() { return true; } private ElementSet() { } @Override // com.google.common.collect.IndexedImmutableSet E get(int i) { return RegularImmutableMultiset.this.contents.getKey(i); } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { return RegularImmutableMultiset.this.contains(obj); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return RegularImmutableMultiset.this.contents.size(); } } @Override // com.google.common.collect.ImmutableMultiset Multiset.Entry getEntry(int i) { return this.contents.getEntry(i); } /* loaded from: classes3.dex */ private 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); } }