package com.google.common.collect; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import java.io.Serializable; import java.lang.Comparable; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.Map; import java.util.NavigableMap; import java.util.NoSuchElementException; import java.util.Set; import java.util.TreeMap; /* loaded from: classes2.dex */ public class TreeRangeSet> extends AbstractRangeSet implements Serializable { private transient Set> asDescendingSetOfRanges; private transient Set> asRanges; private transient RangeSet complement; final NavigableMap, Range> rangesByLowerBound; @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ void addAll(RangeSet rangeSet) { super.addAll(rangeSet); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ void addAll(Iterable iterable) { super.addAll(iterable); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ void clear() { super.clear(); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ boolean contains(Comparable comparable) { return super.contains(comparable); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ boolean enclosesAll(RangeSet rangeSet) { return super.enclosesAll(rangeSet); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ boolean enclosesAll(Iterable iterable) { return super.enclosesAll(iterable); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ boolean equals(Object obj) { return super.equals(obj); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ boolean isEmpty() { return super.isEmpty(); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ void removeAll(RangeSet rangeSet) { super.removeAll(rangeSet); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public /* bridge */ /* synthetic */ void removeAll(Iterable iterable) { super.removeAll(iterable); } public static > TreeRangeSet create() { return new TreeRangeSet<>(new TreeMap()); } public static > TreeRangeSet create(RangeSet rangeSet) { TreeRangeSet create = create(); create.addAll(rangeSet); return create; } public static > TreeRangeSet create(Iterable> iterable) { TreeRangeSet create = create(); create.addAll(iterable); return create; } private TreeRangeSet(NavigableMap, Range> navigableMap) { this.rangesByLowerBound = navigableMap; } @Override // com.google.common.collect.RangeSet public Set> asRanges() { Set> set = this.asRanges; if (set != null) { return set; } AsRanges asRanges = new AsRanges(this, this.rangesByLowerBound.values()); this.asRanges = asRanges; return asRanges; } @Override // com.google.common.collect.RangeSet public Set> asDescendingSetOfRanges() { Set> set = this.asDescendingSetOfRanges; if (set != null) { return set; } AsRanges asRanges = new AsRanges(this, this.rangesByLowerBound.descendingMap().values()); this.asDescendingSetOfRanges = asRanges; return asRanges; } /* loaded from: classes2.dex */ final class AsRanges extends ForwardingCollection> implements Set> { final Collection> delegate; AsRanges(TreeRangeSet treeRangeSet, Collection> collection) { this.delegate = collection; } @Override // java.util.Collection, java.util.Set public final int hashCode() { return Sets.hashCodeImpl(this); } @Override // java.util.Collection, java.util.Set public final boolean equals(Object obj) { return Sets.equalsImpl(this, obj); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingCollection, com.google.common.collect.ForwardingObject public final Collection> delegate() { return this.delegate; } } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public Range rangeContaining(C c) { Preconditions.checkNotNull(c); Map.Entry, Range> floorEntry = this.rangesByLowerBound.floorEntry(Cut.belowValue(c)); if (floorEntry == null || !floorEntry.getValue().contains(c)) { return null; } return floorEntry.getValue(); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public boolean intersects(Range range) { Preconditions.checkNotNull(range); Map.Entry, Range> ceilingEntry = this.rangesByLowerBound.ceilingEntry(range.lowerBound); if (ceilingEntry != null && ceilingEntry.getValue().isConnected(range) && !ceilingEntry.getValue().intersection(range).isEmpty()) { return true; } Map.Entry, Range> lowerEntry = this.rangesByLowerBound.lowerEntry(range.lowerBound); return (lowerEntry == null || !lowerEntry.getValue().isConnected(range) || lowerEntry.getValue().intersection(range).isEmpty()) ? false : true; } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public boolean encloses(Range range) { Preconditions.checkNotNull(range); Map.Entry, Range> floorEntry = this.rangesByLowerBound.floorEntry(range.lowerBound); return floorEntry != null && floorEntry.getValue().encloses(range); } /* JADX INFO: Access modifiers changed from: private */ public Range rangeEnclosing(Range range) { Preconditions.checkNotNull(range); Map.Entry, Range> floorEntry = this.rangesByLowerBound.floorEntry(range.lowerBound); if (floorEntry == null || !floorEntry.getValue().encloses(range)) { return null; } return floorEntry.getValue(); } @Override // com.google.common.collect.RangeSet public Range span() { Map.Entry, Range> firstEntry = this.rangesByLowerBound.firstEntry(); Map.Entry, Range> lastEntry = this.rangesByLowerBound.lastEntry(); if (firstEntry == null) { throw new NoSuchElementException(); } return Range.create(firstEntry.getValue().lowerBound, lastEntry.getValue().upperBound); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public void add(Range range) { Preconditions.checkNotNull(range); if (range.isEmpty()) { return; } Cut cut = range.lowerBound; Cut cut2 = range.upperBound; Map.Entry, Range> lowerEntry = this.rangesByLowerBound.lowerEntry(cut); if (lowerEntry != null) { Range value = lowerEntry.getValue(); if (value.upperBound.compareTo(cut) >= 0) { if (value.upperBound.compareTo(cut2) >= 0) { cut2 = value.upperBound; } cut = value.lowerBound; } } Map.Entry, Range> floorEntry = this.rangesByLowerBound.floorEntry(cut2); if (floorEntry != null) { Range value2 = floorEntry.getValue(); if (value2.upperBound.compareTo(cut2) >= 0) { cut2 = value2.upperBound; } } this.rangesByLowerBound.subMap(cut, cut2).clear(); replaceRangeWithSameLowerBound(Range.create(cut, cut2)); } @Override // com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public void remove(Range range) { Preconditions.checkNotNull(range); if (range.isEmpty()) { return; } Map.Entry, Range> lowerEntry = this.rangesByLowerBound.lowerEntry(range.lowerBound); if (lowerEntry != null) { Range value = lowerEntry.getValue(); if (value.upperBound.compareTo(range.lowerBound) >= 0) { if (range.hasUpperBound() && value.upperBound.compareTo(range.upperBound) >= 0) { replaceRangeWithSameLowerBound(Range.create(range.upperBound, value.upperBound)); } replaceRangeWithSameLowerBound(Range.create(value.lowerBound, range.lowerBound)); } } Map.Entry, Range> floorEntry = this.rangesByLowerBound.floorEntry(range.upperBound); if (floorEntry != null) { Range value2 = floorEntry.getValue(); if (range.hasUpperBound() && value2.upperBound.compareTo(range.upperBound) >= 0) { replaceRangeWithSameLowerBound(Range.create(range.upperBound, value2.upperBound)); } } this.rangesByLowerBound.subMap(range.lowerBound, range.upperBound).clear(); } private void replaceRangeWithSameLowerBound(Range range) { if (range.isEmpty()) { this.rangesByLowerBound.remove(range.lowerBound); } else { this.rangesByLowerBound.put(range.lowerBound, range); } } @Override // com.google.common.collect.RangeSet public RangeSet complement() { RangeSet rangeSet = this.complement; if (rangeSet != null) { return rangeSet; } Complement complement = new Complement(this); this.complement = complement; return complement; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class RangesByUpperBound> extends AbstractNavigableMap, Range> { private final NavigableMap, Range> rangesByLowerBound; private final Range> upperBoundWindow; RangesByUpperBound(NavigableMap, Range> navigableMap) { this.rangesByLowerBound = navigableMap; this.upperBoundWindow = Range.all(); } private RangesByUpperBound(NavigableMap, Range> navigableMap, Range> range) { this.rangesByLowerBound = navigableMap; this.upperBoundWindow = range; } private NavigableMap, Range> subMap(Range> range) { if (range.isConnected(this.upperBoundWindow)) { return new RangesByUpperBound(this.rangesByLowerBound, range.intersection(this.upperBoundWindow)); } return ImmutableSortedMap.of(); } @Override // java.util.NavigableMap public final NavigableMap, Range> subMap(Cut cut, boolean z, Cut cut2, boolean z2) { return subMap(Range.range(cut, BoundType.forBoolean(z), cut2, BoundType.forBoolean(z2))); } @Override // java.util.NavigableMap public final NavigableMap, Range> headMap(Cut cut, boolean z) { return subMap(Range.upTo(cut, BoundType.forBoolean(z))); } @Override // java.util.NavigableMap public final NavigableMap, Range> tailMap(Cut cut, boolean z) { return subMap(Range.downTo(cut, BoundType.forBoolean(z))); } @Override // java.util.SortedMap public final Comparator> comparator() { return Ordering.natural(); } @Override // java.util.AbstractMap, java.util.Map public final boolean containsKey(Object obj) { return get(obj) != null; } @Override // com.google.common.collect.AbstractNavigableMap, java.util.AbstractMap, java.util.Map public final Range get(Object obj) { Map.Entry, Range> lowerEntry; if (obj instanceof Cut) { try { Cut cut = (Cut) obj; if (this.upperBoundWindow.contains(cut) && (lowerEntry = this.rangesByLowerBound.lowerEntry(cut)) != null && lowerEntry.getValue().upperBound.equals(cut)) { return lowerEntry.getValue(); } } catch (ClassCastException unused) { } } return null; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap public final Iterator, Range>> entryIterator() { Iterator> it; if (!this.upperBoundWindow.hasLowerBound()) { it = this.rangesByLowerBound.values().iterator(); } else { Map.Entry lowerEntry = this.rangesByLowerBound.lowerEntry(this.upperBoundWindow.lowerEndpoint()); if (lowerEntry == null) { it = this.rangesByLowerBound.values().iterator(); } else if (this.upperBoundWindow.lowerBound.isLessThan(((Range) lowerEntry.getValue()).upperBound)) { it = this.rangesByLowerBound.tailMap(lowerEntry.getKey(), true).values().iterator(); } else { it = this.rangesByLowerBound.tailMap(this.upperBoundWindow.lowerEndpoint(), true).values().iterator(); } } return new AbstractIterator, Range>>(this, it) { // from class: com.google.common.collect.TreeRangeSet.RangesByUpperBound.1 final RangesByUpperBound this$0; final Iterator val$backingItr; { this.this$0 = this; this.val$backingItr = it; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractIterator public Map.Entry, Range> computeNext() { if (!this.val$backingItr.hasNext()) { return (Map.Entry) endOfData(); } Range range = (Range) this.val$backingItr.next(); if (this.this$0.upperBoundWindow.upperBound.isLessThan(range.upperBound)) { return (Map.Entry) endOfData(); } return Maps.immutableEntry(range.upperBound, range); } }; } @Override // com.google.common.collect.AbstractNavigableMap final Iterator, Range>> descendingEntryIterator() { Collection> values; if (this.upperBoundWindow.hasUpperBound()) { values = this.rangesByLowerBound.headMap(this.upperBoundWindow.upperEndpoint(), false).descendingMap().values(); } else { values = this.rangesByLowerBound.descendingMap().values(); } PeekingIterator peekingIterator = Iterators.peekingIterator(values.iterator()); if (peekingIterator.hasNext() && this.upperBoundWindow.upperBound.isLessThan(((Range) peekingIterator.peek()).upperBound)) { peekingIterator.next(); } return new AbstractIterator, Range>>(this, peekingIterator) { // from class: com.google.common.collect.TreeRangeSet.RangesByUpperBound.2 final RangesByUpperBound this$0; final PeekingIterator val$backingItr; { this.this$0 = this; this.val$backingItr = peekingIterator; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractIterator public Map.Entry, Range> computeNext() { if (!this.val$backingItr.hasNext()) { return (Map.Entry) endOfData(); } Range range = (Range) this.val$backingItr.next(); if (this.this$0.upperBoundWindow.lowerBound.isLessThan(range.upperBound)) { return Maps.immutableEntry(range.upperBound, range); } return (Map.Entry) endOfData(); } }; } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public final int size() { if (this.upperBoundWindow.equals(Range.all())) { return this.rangesByLowerBound.size(); } return Iterators.size(entryIterator()); } @Override // java.util.AbstractMap, java.util.Map public final boolean isEmpty() { if (this.upperBoundWindow.equals(Range.all())) { return this.rangesByLowerBound.isEmpty(); } return !entryIterator().hasNext(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class ComplementRangesByLowerBound> extends AbstractNavigableMap, Range> { private final Range> complementLowerBoundWindow; private final NavigableMap, Range> positiveRangesByLowerBound; private final NavigableMap, Range> positiveRangesByUpperBound; ComplementRangesByLowerBound(NavigableMap, Range> navigableMap) { this(navigableMap, Range.all()); } private ComplementRangesByLowerBound(NavigableMap, Range> navigableMap, Range> range) { this.positiveRangesByLowerBound = navigableMap; this.positiveRangesByUpperBound = new RangesByUpperBound(navigableMap); this.complementLowerBoundWindow = range; } private NavigableMap, Range> subMap(Range> range) { if (!this.complementLowerBoundWindow.isConnected(range)) { return ImmutableSortedMap.of(); } return new ComplementRangesByLowerBound(this.positiveRangesByLowerBound, range.intersection(this.complementLowerBoundWindow)); } @Override // java.util.NavigableMap public final NavigableMap, Range> subMap(Cut cut, boolean z, Cut cut2, boolean z2) { return subMap(Range.range(cut, BoundType.forBoolean(z), cut2, BoundType.forBoolean(z2))); } @Override // java.util.NavigableMap public final NavigableMap, Range> headMap(Cut cut, boolean z) { return subMap(Range.upTo(cut, BoundType.forBoolean(z))); } @Override // java.util.NavigableMap public final NavigableMap, Range> tailMap(Cut cut, boolean z) { return subMap(Range.downTo(cut, BoundType.forBoolean(z))); } @Override // java.util.SortedMap public final Comparator> comparator() { return Ordering.natural(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap public final Iterator, Range>> entryIterator() { Collection> values; Cut cut; if (this.complementLowerBoundWindow.hasLowerBound()) { values = this.positiveRangesByUpperBound.tailMap(this.complementLowerBoundWindow.lowerEndpoint(), this.complementLowerBoundWindow.lowerBoundType() == BoundType.CLOSED).values(); } else { values = this.positiveRangesByUpperBound.values(); } PeekingIterator peekingIterator = Iterators.peekingIterator(values.iterator()); if (this.complementLowerBoundWindow.contains(Cut.belowAll()) && (!peekingIterator.hasNext() || ((Range) peekingIterator.peek()).lowerBound != Cut.belowAll())) { cut = Cut.belowAll(); } else if (peekingIterator.hasNext()) { cut = ((Range) peekingIterator.next()).upperBound; } else { return Iterators.emptyIterator(); } return new AbstractIterator, Range>>(this, cut, peekingIterator) { // from class: com.google.common.collect.TreeRangeSet.ComplementRangesByLowerBound.1 Cut nextComplementRangeLowerBound; final ComplementRangesByLowerBound this$0; final Cut val$firstComplementRangeLowerBound; final PeekingIterator val$positiveItr; { this.this$0 = this; this.val$firstComplementRangeLowerBound = cut; this.val$positiveItr = peekingIterator; this.nextComplementRangeLowerBound = cut; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractIterator public Map.Entry, Range> computeNext() { Range create; if (this.this$0.complementLowerBoundWindow.upperBound.isLessThan(this.nextComplementRangeLowerBound) || this.nextComplementRangeLowerBound == Cut.aboveAll()) { return (Map.Entry) endOfData(); } if (this.val$positiveItr.hasNext()) { Range range = (Range) this.val$positiveItr.next(); create = Range.create(this.nextComplementRangeLowerBound, range.lowerBound); this.nextComplementRangeLowerBound = range.upperBound; } else { create = Range.create(this.nextComplementRangeLowerBound, Cut.aboveAll()); this.nextComplementRangeLowerBound = Cut.aboveAll(); } return Maps.immutableEntry(create.lowerBound, create); } }; } @Override // com.google.common.collect.AbstractNavigableMap final Iterator, Range>> descendingEntryIterator() { Cut aboveAll; Cut higherKey; if (this.complementLowerBoundWindow.hasUpperBound()) { aboveAll = this.complementLowerBoundWindow.upperEndpoint(); } else { aboveAll = Cut.aboveAll(); } PeekingIterator peekingIterator = Iterators.peekingIterator(this.positiveRangesByUpperBound.headMap(aboveAll, this.complementLowerBoundWindow.hasUpperBound() && this.complementLowerBoundWindow.upperBoundType() == BoundType.CLOSED).descendingMap().values().iterator()); if (peekingIterator.hasNext()) { if (((Range) peekingIterator.peek()).upperBound == Cut.aboveAll()) { higherKey = ((Range) peekingIterator.next()).lowerBound; } else { higherKey = this.positiveRangesByLowerBound.higherKey(((Range) peekingIterator.peek()).upperBound); } } else { if (!this.complementLowerBoundWindow.contains(Cut.belowAll()) || this.positiveRangesByLowerBound.containsKey(Cut.belowAll())) { return Iterators.emptyIterator(); } higherKey = this.positiveRangesByLowerBound.higherKey(Cut.belowAll()); } return new AbstractIterator, Range>>(this, (Cut) MoreObjects.firstNonNull(higherKey, Cut.aboveAll()), peekingIterator) { // from class: com.google.common.collect.TreeRangeSet.ComplementRangesByLowerBound.2 Cut nextComplementRangeUpperBound; final ComplementRangesByLowerBound this$0; final Cut val$firstComplementRangeUpperBound; final PeekingIterator val$positiveItr; { this.this$0 = this; this.val$firstComplementRangeUpperBound = r2; this.val$positiveItr = peekingIterator; this.nextComplementRangeUpperBound = r2; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractIterator public Map.Entry, Range> computeNext() { if (this.nextComplementRangeUpperBound == Cut.belowAll()) { return (Map.Entry) endOfData(); } if (!this.val$positiveItr.hasNext()) { if (this.this$0.complementLowerBoundWindow.lowerBound.isLessThan(Cut.belowAll())) { Range create = Range.create(Cut.belowAll(), this.nextComplementRangeUpperBound); this.nextComplementRangeUpperBound = Cut.belowAll(); return Maps.immutableEntry(Cut.belowAll(), create); } } else { Range range = (Range) this.val$positiveItr.next(); Range create2 = Range.create(range.upperBound, this.nextComplementRangeUpperBound); this.nextComplementRangeUpperBound = range.lowerBound; if (this.this$0.complementLowerBoundWindow.lowerBound.isLessThan(create2.lowerBound)) { return Maps.immutableEntry(create2.lowerBound, create2); } } return (Map.Entry) endOfData(); } }; } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public final int size() { return Iterators.size(entryIterator()); } @Override // com.google.common.collect.AbstractNavigableMap, java.util.AbstractMap, java.util.Map public final Range get(Object obj) { if (!(obj instanceof Cut)) { return null; } try { Cut cut = (Cut) obj; Map.Entry, Range> firstEntry = tailMap((Cut) cut, true).firstEntry(); if (firstEntry == null || !firstEntry.getKey().equals(cut)) { return null; } return firstEntry.getValue(); } catch (ClassCastException unused) { return null; } } @Override // java.util.AbstractMap, java.util.Map public final boolean containsKey(Object obj) { return get(obj) != null; } } /* loaded from: classes2.dex */ final class Complement extends TreeRangeSet { final TreeRangeSet this$0; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ Complement(TreeRangeSet treeRangeSet) { super(new ComplementRangesByLowerBound(treeRangeSet.rangesByLowerBound)); this.this$0 = treeRangeSet; } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final void add(Range range) { this.this$0.remove(range); } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final void remove(Range range) { this.this$0.add(range); } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final boolean contains(C c) { return !this.this$0.contains(c); } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.RangeSet public final RangeSet complement() { return this.this$0; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class SubRangeSetRangesByLowerBound> extends AbstractNavigableMap, Range> { private final Range> lowerBoundWindow; private final NavigableMap, Range> rangesByLowerBound; private final NavigableMap, Range> rangesByUpperBound; private final Range restriction; private SubRangeSetRangesByLowerBound(Range> range, Range range2, NavigableMap, Range> navigableMap) { this.lowerBoundWindow = (Range) Preconditions.checkNotNull(range); this.restriction = (Range) Preconditions.checkNotNull(range2); this.rangesByLowerBound = (NavigableMap) Preconditions.checkNotNull(navigableMap); this.rangesByUpperBound = new RangesByUpperBound(navigableMap); } private NavigableMap, Range> subMap(Range> range) { if (!range.isConnected(this.lowerBoundWindow)) { return ImmutableSortedMap.of(); } return new SubRangeSetRangesByLowerBound(this.lowerBoundWindow.intersection(range), this.restriction, this.rangesByLowerBound); } @Override // java.util.NavigableMap public final NavigableMap, Range> subMap(Cut cut, boolean z, Cut cut2, boolean z2) { return subMap(Range.range(cut, BoundType.forBoolean(z), cut2, BoundType.forBoolean(z2))); } @Override // java.util.NavigableMap public final NavigableMap, Range> headMap(Cut cut, boolean z) { return subMap(Range.upTo(cut, BoundType.forBoolean(z))); } @Override // java.util.NavigableMap public final NavigableMap, Range> tailMap(Cut cut, boolean z) { return subMap(Range.downTo(cut, BoundType.forBoolean(z))); } @Override // java.util.SortedMap public final Comparator> comparator() { return Ordering.natural(); } @Override // java.util.AbstractMap, java.util.Map public final boolean containsKey(Object obj) { return get(obj) != null; } @Override // com.google.common.collect.AbstractNavigableMap, java.util.AbstractMap, java.util.Map public final Range get(Object obj) { if (!(obj instanceof Cut)) { return null; } try { Cut cut = (Cut) obj; if (this.lowerBoundWindow.contains(cut) && cut.compareTo(this.restriction.lowerBound) >= 0 && cut.compareTo(this.restriction.upperBound) < 0) { if (cut.equals(this.restriction.lowerBound)) { Range range = (Range) Maps.valueOrNull(this.rangesByLowerBound.floorEntry(cut)); if (range == null || range.upperBound.compareTo((Cut) this.restriction.lowerBound) <= 0) { return null; } return range.intersection(this.restriction); } Range range2 = (Range) this.rangesByLowerBound.get(cut); if (range2 != null) { return range2.intersection(this.restriction); } return null; } return null; } catch (ClassCastException unused) { return null; } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap public final Iterator, Range>> entryIterator() { Iterator> it; if (this.restriction.isEmpty()) { return Iterators.emptyIterator(); } if (this.lowerBoundWindow.upperBound.isLessThan(this.restriction.lowerBound)) { return Iterators.emptyIterator(); } if (this.lowerBoundWindow.lowerBound.isLessThan(this.restriction.lowerBound)) { it = this.rangesByUpperBound.tailMap(this.restriction.lowerBound, false).values().iterator(); } else { it = this.rangesByLowerBound.tailMap(this.lowerBoundWindow.lowerBound.endpoint(), this.lowerBoundWindow.lowerBoundType() == BoundType.CLOSED).values().iterator(); } return new AbstractIterator, Range>>(this, it, (Cut) Ordering.natural().min(this.lowerBoundWindow.upperBound, Cut.belowValue(this.restriction.upperBound))) { // from class: com.google.common.collect.TreeRangeSet.SubRangeSetRangesByLowerBound.1 final SubRangeSetRangesByLowerBound this$0; final Iterator val$completeRangeItr; final Cut val$upperBoundOnLowerBounds; { this.this$0 = this; this.val$completeRangeItr = it; this.val$upperBoundOnLowerBounds = r3; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractIterator public Map.Entry, Range> computeNext() { if (!this.val$completeRangeItr.hasNext()) { return (Map.Entry) endOfData(); } Range range = (Range) this.val$completeRangeItr.next(); if (!this.val$upperBoundOnLowerBounds.isLessThan(range.lowerBound)) { Range intersection = range.intersection(this.this$0.restriction); return Maps.immutableEntry(intersection.lowerBound, intersection); } return (Map.Entry) endOfData(); } }; } @Override // com.google.common.collect.AbstractNavigableMap final Iterator, Range>> descendingEntryIterator() { if (this.restriction.isEmpty()) { return Iterators.emptyIterator(); } Cut cut = (Cut) Ordering.natural().min(this.lowerBoundWindow.upperBound, Cut.belowValue(this.restriction.upperBound)); return new AbstractIterator, Range>>(this, this.rangesByLowerBound.headMap(cut.endpoint(), cut.typeAsUpperBound() == BoundType.CLOSED).descendingMap().values().iterator()) { // from class: com.google.common.collect.TreeRangeSet.SubRangeSetRangesByLowerBound.2 final SubRangeSetRangesByLowerBound this$0; final Iterator val$completeRangeItr; { this.this$0 = this; this.val$completeRangeItr = r2; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.AbstractIterator public Map.Entry, Range> computeNext() { if (!this.val$completeRangeItr.hasNext()) { return (Map.Entry) endOfData(); } Range range = (Range) this.val$completeRangeItr.next(); if (this.this$0.restriction.lowerBound.compareTo((Cut) range.upperBound) < 0) { Range intersection = range.intersection(this.this$0.restriction); if (this.this$0.lowerBoundWindow.contains(intersection.lowerBound)) { return Maps.immutableEntry(intersection.lowerBound, intersection); } return (Map.Entry) endOfData(); } return (Map.Entry) endOfData(); } }; } @Override // com.google.common.collect.Maps.IteratorBasedAbstractMap, java.util.AbstractMap, java.util.Map public final int size() { return Iterators.size(entryIterator()); } } @Override // com.google.common.collect.RangeSet public RangeSet subRangeSet(Range range) { return range.equals(Range.all()) ? this : new SubRangeSet(this, range); } /* loaded from: classes2.dex */ final class SubRangeSet extends TreeRangeSet { private final Range restriction; final TreeRangeSet this$0; /* JADX WARN: Illegal instructions before constructor call */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ SubRangeSet(com.google.common.collect.TreeRangeSet r4, com.google.common.collect.Range r5) { /* r3 = this; r3.this$0 = r4 com.google.common.collect.TreeRangeSet$SubRangeSetRangesByLowerBound r0 = new com.google.common.collect.TreeRangeSet$SubRangeSetRangesByLowerBound com.google.common.collect.Range r1 = com.google.common.collect.Range.all() java.util.NavigableMap>, com.google.common.collect.Range>> r4 = r4.rangesByLowerBound r2 = 0 r0.(r1, r5, r4) r3.(r0) r3.restriction = r5 return */ throw new UnsupportedOperationException("Method not decompiled: com.google.common.collect.TreeRangeSet.SubRangeSet.(com.google.common.collect.TreeRangeSet, com.google.common.collect.Range):void"); } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final boolean encloses(Range range) { Range rangeEnclosing; return (this.restriction.isEmpty() || !this.restriction.encloses(range) || (rangeEnclosing = this.this$0.rangeEnclosing(range)) == null || rangeEnclosing.intersection(this.restriction).isEmpty()) ? false : true; } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final Range rangeContaining(C c) { Range rangeContaining; if (this.restriction.contains(c) && (rangeContaining = this.this$0.rangeContaining(c)) != null) { return rangeContaining.intersection(this.restriction); } return null; } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final void add(Range range) { Preconditions.checkArgument(this.restriction.encloses(range), "Cannot add range %s to subRangeSet(%s)", range, this.restriction); this.this$0.add(range); } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final void remove(Range range) { if (range.isConnected(this.restriction)) { this.this$0.remove(range.intersection(this.restriction)); } } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final boolean contains(C c) { return this.restriction.contains(c) && this.this$0.contains(c); } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.AbstractRangeSet, com.google.common.collect.RangeSet public final void clear() { this.this$0.remove(this.restriction); } @Override // com.google.common.collect.TreeRangeSet, com.google.common.collect.RangeSet public final RangeSet subRangeSet(Range range) { if (range.encloses(this.restriction)) { return this; } if (range.isConnected(this.restriction)) { return new SubRangeSet(this, this.restriction.intersection(range)); } return ImmutableRangeSet.of(); } } }