diff options
author | Paul Duffin <paulduffin@google.com> | 2015-01-19 12:46:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-19 12:46:40 +0000 |
commit | aab56800fcb95e9b1a2d653588b14158080cc6b4 (patch) | |
tree | 7365392c3ea77742021cf187acfd465f9bb774ab /guava/src/com/google/common/collect/ContiguousSet.java | |
parent | 6fa98dbaae182b511fbeb331e08f5fb827715ea8 (diff) | |
parent | 84fb43aa6a1e752487f2624055ff26b1b6b7c043 (diff) | |
download | android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.tar.gz android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.tar.bz2 android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.zip |
am 84fb43aa: Merge "Revert "Upgraded Guava to unmodified v14.0.1""
* commit '84fb43aa6a1e752487f2624055ff26b1b6b7c043':
Revert "Upgraded Guava to unmodified v14.0.1"
Diffstat (limited to 'guava/src/com/google/common/collect/ContiguousSet.java')
-rw-r--r-- | guava/src/com/google/common/collect/ContiguousSet.java | 72 |
1 files changed, 8 insertions, 64 deletions
diff --git a/guava/src/com/google/common/collect/ContiguousSet.java b/guava/src/com/google/common/collect/ContiguousSet.java index dc9aa83..439f675 100644 --- a/guava/src/com/google/common/collect/ContiguousSet.java +++ b/guava/src/com/google/common/collect/ContiguousSet.java @@ -19,63 +19,19 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; -import com.google.common.annotations.GwtIncompatible; -import java.util.Collections; import java.util.NoSuchElementException; -import java.util.Set; /** * A sorted set of contiguous values in a given {@link DiscreteDomain}. * - * <p><b>Warning:</b> Be extremely careful what you do with conceptually large instances (such as - * {@code ContiguousSet.create(Range.greaterThan(0), DiscreteDomains.integers()}). Certain - * operations on such a set can be performed efficiently, but others (such as {@link Set#hashCode} - * or {@link Collections#frequency}) can cause major performance problems. - * * @author Gregory Kick * @since 10.0 */ @Beta -@GwtCompatible(emulated = true) -@SuppressWarnings("rawtypes") // allow ungenerified Comparable types +@GwtCompatible +@SuppressWarnings("unchecked") // allow ungenerified Comparable types public abstract class ContiguousSet<C extends Comparable> extends ImmutableSortedSet<C> { - /** - * Returns a {@code ContiguousSet} containing the same values in the given domain - * {@linkplain Range#contains contained} by the range. - * - * @throws IllegalArgumentException if neither range nor the domain has a lower bound, or if - * neither has an upper bound - * - * @since 13.0 - */ - public static <C extends Comparable> ContiguousSet<C> create( - Range<C> range, DiscreteDomain<C> domain) { - checkNotNull(range); - checkNotNull(domain); - Range<C> effectiveRange = range; - try { - if (!range.hasLowerBound()) { - effectiveRange = effectiveRange.intersection(Range.atLeast(domain.minValue())); - } - if (!range.hasUpperBound()) { - effectiveRange = effectiveRange.intersection(Range.atMost(domain.maxValue())); - } - } catch (NoSuchElementException e) { - throw new IllegalArgumentException(e); - } - - // Per class spec, we are allowed to throw CCE if necessary - boolean empty = effectiveRange.isEmpty() - || Range.compareOrThrow( - range.lowerBound.leastValueAbove(domain), - range.upperBound.greatestValueBelow(domain)) > 0; - - return empty - ? new EmptyContiguousSet<C>(domain) - : new RegularContiguousSet<C>(effectiveRange, domain); - } - final DiscreteDomain<C> domain; ContiguousSet(DiscreteDomain<C> domain) { @@ -84,14 +40,10 @@ public abstract class ContiguousSet<C extends Comparable> extends ImmutableSorte } @Override public ContiguousSet<C> headSet(C toElement) { - return headSetImpl(checkNotNull(toElement), false); + return headSet(checkNotNull(toElement), false); } - /** - * @since 12.0 - */ - @GwtIncompatible("NavigableSet") - @Override public ContiguousSet<C> headSet(C toElement, boolean inclusive) { + @Override ContiguousSet<C> headSet(C toElement, boolean inclusive) { return headSetImpl(checkNotNull(toElement), inclusive); } @@ -99,14 +51,10 @@ public abstract class ContiguousSet<C extends Comparable> extends ImmutableSorte checkNotNull(fromElement); checkNotNull(toElement); checkArgument(comparator().compare(fromElement, toElement) <= 0); - return subSetImpl(fromElement, true, toElement, false); + return subSet(fromElement, true, toElement, false); } - /** - * @since 12.0 - */ - @GwtIncompatible("NavigableSet") - @Override public ContiguousSet<C> subSet(C fromElement, boolean fromInclusive, C toElement, + @Override ContiguousSet<C> subSet(C fromElement, boolean fromInclusive, C toElement, boolean toInclusive) { checkNotNull(fromElement); checkNotNull(toElement); @@ -115,14 +63,10 @@ public abstract class ContiguousSet<C extends Comparable> extends ImmutableSorte } @Override public ContiguousSet<C> tailSet(C fromElement) { - return tailSetImpl(checkNotNull(fromElement), true); + return tailSet(checkNotNull(fromElement), true); } - /** - * @since 12.0 - */ - @GwtIncompatible("NavigableSet") - @Override public ContiguousSet<C> tailSet(C fromElement, boolean inclusive) { + @Override ContiguousSet<C> tailSet(C fromElement, boolean inclusive){ return tailSetImpl(checkNotNull(fromElement), inclusive); } |