package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.Multiset; import com.google.common.primitives.Ints; import java.util.Comparator; import java.util.NavigableSet; import java.util.Set; import java.util.SortedSet; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class RegularImmutableSortedMultiset extends ImmutableSortedMultiset { private final transient long[] cumulativeCounts; final transient RegularImmutableSortedSet elementSet; private final transient int length; private final transient int offset; private static final long[] ZERO_CUMULATIVE_COUNTS = {0}; static final ImmutableSortedMultiset NATURAL_EMPTY_MULTISET = new RegularImmutableSortedMultiset(Ordering.natural()); @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public final /* bridge */ /* synthetic */ ImmutableSet elementSet() { return elementSet(); } @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public final /* bridge */ /* synthetic */ NavigableSet elementSet() { return elementSet(); } @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public final /* bridge */ /* synthetic */ Set elementSet() { return elementSet(); } @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public final /* bridge */ /* synthetic */ SortedSet elementSet() { return elementSet(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.SortedMultiset public final /* bridge */ /* synthetic */ SortedMultiset headMultiset(Object obj, BoundType boundType) { return headMultiset((RegularImmutableSortedMultiset) obj, boundType); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.SortedMultiset public final /* bridge */ /* synthetic */ SortedMultiset tailMultiset(Object obj, BoundType boundType) { return tailMultiset((RegularImmutableSortedMultiset) obj, boundType); } /* JADX INFO: Access modifiers changed from: package-private */ public RegularImmutableSortedMultiset(Comparator comparator) { this.elementSet = ImmutableSortedSet.emptySet(comparator); this.cumulativeCounts = ZERO_CUMULATIVE_COUNTS; this.offset = 0; this.length = 0; } /* JADX INFO: Access modifiers changed from: package-private */ public RegularImmutableSortedMultiset(RegularImmutableSortedSet regularImmutableSortedSet, long[] jArr, int i, int i2) { this.elementSet = regularImmutableSortedSet; this.cumulativeCounts = jArr; this.offset = i; this.length = i2; } private int getCount(int i) { long[] jArr = this.cumulativeCounts; int i2 = this.offset + i; return (int) (jArr[i2 + 1] - jArr[i2]); } @Override // com.google.common.collect.ImmutableMultiset final Multiset.Entry getEntry(int i) { return Multisets.immutableEntry(this.elementSet.asList().get(i), getCount(i)); } @Override // com.google.common.collect.SortedMultiset public final Multiset.Entry firstEntry() { if (isEmpty()) { return null; } return getEntry(0); } @Override // com.google.common.collect.SortedMultiset public final Multiset.Entry lastEntry() { if (isEmpty()) { return null; } return getEntry(this.length - 1); } @Override // com.google.common.collect.Multiset public final int count(Object obj) { int indexOf = this.elementSet.indexOf(obj); if (indexOf >= 0) { return getCount(indexOf); } return 0; } @Override // java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset public final int size() { long[] jArr = this.cumulativeCounts; int i = this.offset; return Ints.saturatedCast(jArr[this.length + i] - jArr[i]); } @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.SortedMultiset public final ImmutableSortedMultiset headMultiset(E e, BoundType boundType) { return getSubMultiset(0, this.elementSet.headIndex(e, Preconditions.checkNotNull(boundType) == BoundType.CLOSED)); } @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.SortedMultiset public final ImmutableSortedMultiset tailMultiset(E e, BoundType boundType) { return getSubMultiset(this.elementSet.tailIndex(e, Preconditions.checkNotNull(boundType) == BoundType.CLOSED), this.length); } final ImmutableSortedMultiset getSubMultiset(int i, int i2) { Preconditions.checkPositionIndexes(i, i2, this.length); if (i == i2) { return emptyMultiset(comparator()); } return (i == 0 && i2 == this.length) ? this : new RegularImmutableSortedMultiset(this.elementSet.getSubSet(i, i2), this.cumulativeCounts, this.offset + i, i2 - i); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public final boolean isPartialView() { return this.offset > 0 || this.length < this.cumulativeCounts.length - 1; } @Override // com.google.common.collect.ImmutableSortedMultiset, com.google.common.collect.ImmutableMultiset, com.google.common.collect.Multiset public final ImmutableSortedSet elementSet() { return this.elementSet; } }