package com.google.common.collect; import com.google.common.base.Preconditions; import java.io.Serializable; import java.lang.Comparable; import java.util.Collection; import java.util.Set; /* loaded from: classes.dex */ final class RegularContiguousSet extends ContiguousSet { private final Range a; private static final class SerializedForm implements Serializable { final Range a; final DiscreteDomain b; private Object readResolve() { return new RegularContiguousSet(this.a, this.b); } private SerializedForm(Range range, DiscreteDomain discreteDomain) { this.a = range; this.b = discreteDomain; } } RegularContiguousSet(Range range, DiscreteDomain discreteDomain) { super(discreteDomain); this.a = range; } /* JADX INFO: Access modifiers changed from: private */ public static boolean b(Comparable comparable, Comparable comparable2) { return comparable2 != null && Range.compareOrThrow(comparable, comparable2) == 0; } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { if (obj == null) { return false; } try { return this.a.contains((Comparable) obj); } catch (ClassCastException unused) { return false; } } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean containsAll(Collection collection) { return Collections2.a((Collection) this, collection); } @Override // com.google.common.collect.ImmutableSet ImmutableList createAsList() { return this.domain.a ? new ImmutableAsList() { // from class: com.google.common.collect.RegularContiguousSet.3 /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableAsList public ImmutableSortedSet a() { return RegularContiguousSet.this; } /* JADX WARN: Multi-variable type inference failed */ @Override // java.util.List public C get(int i) { Preconditions.a(i, size()); RegularContiguousSet regularContiguousSet = RegularContiguousSet.this; return (C) regularContiguousSet.domain.a((DiscreteDomain) regularContiguousSet.first(), i); } } : super.createAsList(); } @Override // com.google.common.collect.ImmutableSet, java.util.Collection, java.util.Set public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof RegularContiguousSet) { RegularContiguousSet regularContiguousSet = (RegularContiguousSet) obj; if (this.domain.equals(regularContiguousSet.domain)) { return first().equals(regularContiguousSet.first()) && last().equals(regularContiguousSet.last()); } } return super.equals(obj); } @Override // com.google.common.collect.ImmutableSet, java.util.Collection, java.util.Set public int hashCode() { return Sets.a((Set) this); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableSortedSet int indexOf(Object obj) { if (contains(obj)) { return (int) this.domain.a(first(), (Comparable) obj); } return -1; } @Override // com.google.common.collect.ContiguousSet public ContiguousSet intersection(ContiguousSet contiguousSet) { Preconditions.a(contiguousSet); Preconditions.a(this.domain.equals(contiguousSet.domain)); if (contiguousSet.isEmpty()) { return contiguousSet; } Comparable comparable = (Comparable) Ordering.c().a(first(), contiguousSet.first()); Comparable comparable2 = (Comparable) Ordering.c().b(last(), contiguousSet.last()); return comparable.compareTo(comparable2) <= 0 ? ContiguousSet.create(Range.closed(comparable, comparable2), this.domain) : new EmptyContiguousSet(this.domain); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean isEmpty() { return false; } @Override // com.google.common.collect.ImmutableCollection boolean isPartialView() { return false; } @Override // com.google.common.collect.ContiguousSet public Range range() { BoundType boundType = BoundType.CLOSED; return range(boundType, boundType); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { long a = this.domain.a(first(), last()); if (a >= 2147483647L) { return Integer.MAX_VALUE; } return ((int) a) + 1; } @Override // com.google.common.collect.ImmutableSortedSet, com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection Object writeReplace() { return new SerializedForm(this.a, this.domain); } private ContiguousSet a(Range range) { return this.a.isConnected(range) ? ContiguousSet.create(this.a.intersection(range), this.domain) : new EmptyContiguousSet(this.domain); } @Override // com.google.common.collect.ImmutableSortedSet, java.util.NavigableSet public UnmodifiableIterator descendingIterator() { return new AbstractSequentialIterator(last()) { // from class: com.google.common.collect.RegularContiguousSet.2 final C b; { this.b = (C) RegularContiguousSet.this.first(); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractSequentialIterator public C a(C c) { if (RegularContiguousSet.b(c, this.b)) { return null; } return RegularContiguousSet.this.domain.b(c); } }; } @Override // com.google.common.collect.ImmutableSortedSet, java.util.SortedSet public C first() { return this.a.lowerBound.c(this.domain); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ContiguousSet, com.google.common.collect.ImmutableSortedSet public ContiguousSet headSetImpl(C c, boolean z) { return a(Range.upTo(c, BoundType.forBoolean(z))); } @Override // com.google.common.collect.ImmutableSortedSet, com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet public UnmodifiableIterator iterator() { return new AbstractSequentialIterator(first()) { // from class: com.google.common.collect.RegularContiguousSet.1 final C b; { this.b = (C) RegularContiguousSet.this.last(); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractSequentialIterator public C a(C c) { if (RegularContiguousSet.b(c, this.b)) { return null; } return RegularContiguousSet.this.domain.a(c); } }; } @Override // com.google.common.collect.ImmutableSortedSet, java.util.SortedSet public C last() { return this.a.upperBound.b(this.domain); } @Override // com.google.common.collect.ContiguousSet public Range range(BoundType boundType, BoundType boundType2) { return Range.create(this.a.lowerBound.a(boundType, this.domain), this.a.upperBound.b(boundType2, this.domain)); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ContiguousSet, com.google.common.collect.ImmutableSortedSet public ContiguousSet subSetImpl(C c, boolean z, C c2, boolean z2) { return (c.compareTo(c2) != 0 || z || z2) ? a(Range.range(c, BoundType.forBoolean(z), c2, BoundType.forBoolean(z2))) : new EmptyContiguousSet(this.domain); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ContiguousSet, com.google.common.collect.ImmutableSortedSet public ContiguousSet tailSetImpl(C c, boolean z) { return a(Range.downTo(c, BoundType.forBoolean(z))); } }