Rabbit-R1/switch port/java/sources/com/google/common/collect/AbstractRangeSet.java

110 lines
3.1 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package com.google.common.collect;
import java.lang.Comparable;
import java.util.Iterator;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
abstract class AbstractRangeSet<C extends Comparable> implements RangeSet<C> {
@Override // com.google.common.collect.RangeSet
public abstract boolean encloses(Range<C> range);
@Override // com.google.common.collect.RangeSet
@CheckForNull
public abstract Range<C> rangeContaining(C c);
@Override // com.google.common.collect.RangeSet
public boolean contains(C c) {
return rangeContaining(c) != null;
}
@Override // com.google.common.collect.RangeSet
public boolean isEmpty() {
return asRanges().isEmpty();
}
@Override // com.google.common.collect.RangeSet
public void add(Range<C> range) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.RangeSet
public void remove(Range<C> range) {
throw new UnsupportedOperationException();
}
@Override // com.google.common.collect.RangeSet
public void clear() {
remove(Range.all());
}
@Override // com.google.common.collect.RangeSet
public boolean enclosesAll(RangeSet<C> rangeSet) {
return enclosesAll(rangeSet.asRanges());
}
@Override // com.google.common.collect.RangeSet
public boolean enclosesAll(Iterable<Range<C>> iterable) {
Iterator<Range<C>> it = iterable.iterator();
while (it.hasNext()) {
if (!encloses(it.next())) {
return false;
}
}
return true;
}
@Override // com.google.common.collect.RangeSet
public void addAll(RangeSet<C> rangeSet) {
addAll(rangeSet.asRanges());
}
@Override // com.google.common.collect.RangeSet
public void addAll(Iterable<Range<C>> iterable) {
Iterator<Range<C>> it = iterable.iterator();
while (it.hasNext()) {
add(it.next());
}
}
@Override // com.google.common.collect.RangeSet
public void removeAll(RangeSet<C> rangeSet) {
removeAll(rangeSet.asRanges());
}
@Override // com.google.common.collect.RangeSet
public void removeAll(Iterable<Range<C>> iterable) {
Iterator<Range<C>> it = iterable.iterator();
while (it.hasNext()) {
remove(it.next());
}
}
@Override // com.google.common.collect.RangeSet
public boolean intersects(Range<C> range) {
return !subRangeSet(range).isEmpty();
}
@Override // com.google.common.collect.RangeSet
public boolean equals(@CheckForNull Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof RangeSet) {
return asRanges().equals(((RangeSet) obj).asRanges());
}
return false;
}
@Override // com.google.common.collect.RangeSet
public final int hashCode() {
return asRanges().hashCode();
}
@Override // com.google.common.collect.RangeSet
public final String toString() {
return asRanges().toString();
}
}