本文整理了Java中com.google.common.collect.Range.cast
方法的一些代码示例,展示了Range.cast
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.cast
方法的具体详情如下:
包路径:com.google.common.collect.Range
类名称:Range
方法名:cast
[英]Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557
[中]用来避免http://bugs.sun.com/view_bug.do?bug_id=6558557
代码示例来源:origin: google/guava
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: google/guava
/**
* Returns the minimal range that {@linkplain Range#contains(Comparable) contains} all of the
* given values. The returned range is {@linkplain BoundType#CLOSED closed} on both ends.
*
* @throws ClassCastException if the values are not mutually comparable
* @throws NoSuchElementException if {@code values} is empty
* @throws NullPointerException if any of {@code values} is null
* @since 14.0
*/
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
checkNotNull(values);
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return closed(set.first(), set.last());
}
}
Iterator<C> valueIterator = values.iterator();
C min = checkNotNull(valueIterator.next());
C max = min;
while (valueIterator.hasNext()) {
C value = checkNotNull(valueIterator.next());
min = Ordering.natural().min(min, value);
max = Ordering.natural().max(max, value);
}
return closed(min, max);
}
代码示例来源:origin: google/j2objc
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: google/j2objc
/**
* Returns the minimal range that {@linkplain Range#contains(Comparable) contains} all of the
* given values. The returned range is {@linkplain BoundType#CLOSED closed} on both ends.
*
* @throws ClassCastException if the parameters are not <i>mutually comparable</i>
* @throws NoSuchElementException if {@code values} is empty
* @throws NullPointerException if any of {@code values} is null
* @since 14.0
*/
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
checkNotNull(values);
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return closed(set.first(), set.last());
}
}
Iterator<C> valueIterator = values.iterator();
C min = checkNotNull(valueIterator.next());
C max = min;
while (valueIterator.hasNext()) {
C value = checkNotNull(valueIterator.next());
min = Ordering.natural().min(min, value);
max = Ordering.natural().max(max, value);
}
return closed(min, max);
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns the minimal range that {@linkplain Range#contains(Comparable) contains} all of the
* given values. The returned range is {@linkplain BoundType#CLOSED closed} on both ends.
*
* @throws ClassCastException if the parameters are not <i>mutually comparable</i>
* @throws NoSuchElementException if {@code values} is empty
* @throws NullPointerException if any of {@code values} is null
* @since 14.0
*/
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
checkNotNull(values);
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return closed(set.first(), set.last());
}
}
Iterator<C> valueIterator = values.iterator();
C min = checkNotNull(valueIterator.next());
C max = min;
while (valueIterator.hasNext()) {
C value = checkNotNull(valueIterator.next());
min = Ordering.natural().min(min, value);
max = Ordering.natural().max(max, value);
}
return closed(min, max);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: Nextdoor/bender
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.google.guava/guava-jdk5
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.sonatype.sisu/sisu-guava
/**
* Returns {@code true} if every element in {@code values} is {@linkplain
* #contains contained} in this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.diffplug.guava/guava-collect
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.hudsonci.lib.guava/guava
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/**
* Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in
* this range.
*/
public boolean containsAll(Iterable<? extends C> values) {
if (Iterables.isEmpty(values)) {
return true;
}
// this optimizes testing equality of two range-backed sets
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return contains(set.first()) && contains(set.last());
}
}
for (C value : values) {
if (!contains(value)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Returns the minimal range that {@linkplain Range#contains(Comparable) contains} all of the
* given values. The returned range is {@linkplain BoundType#CLOSED closed} on both ends.
*
* @throws ClassCastException if the parameters are not <i>mutually comparable</i>
* @throws NoSuchElementException if {@code values} is empty
* @throws NullPointerException if any of {@code values} is null
* @since 14.0
*/
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
checkNotNull(values);
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return closed(set.first(), set.last());
}
}
Iterator<C> valueIterator = values.iterator();
C min = checkNotNull(valueIterator.next());
C max = min;
while (valueIterator.hasNext()) {
C value = checkNotNull(valueIterator.next());
min = Ordering.natural().min(min, value);
max = Ordering.natural().max(max, value);
}
return closed(min, max);
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
/**
* Returns the minimal range that {@linkplain Range#contains(Comparable) contains} all of the
* given values. The returned range is {@linkplain BoundType#CLOSED closed} on both ends.
*
* @throws ClassCastException if the parameters are not <i>mutually comparable</i>
* @throws NoSuchElementException if {@code values} is empty
* @throws NullPointerException if any of {@code values} is null
* @since 14.0
*/
public static <C extends Comparable<?>> Range<C> encloseAll(Iterable<C> values) {
checkNotNull(values);
if (values instanceof SortedSet) {
SortedSet<? extends C> set = cast(values);
Comparator<?> comparator = set.comparator();
if (Ordering.natural().equals(comparator) || comparator == null) {
return closed(set.first(), set.last());
}
}
Iterator<C> valueIterator = values.iterator();
C min = checkNotNull(valueIterator.next());
C max = min;
while (valueIterator.hasNext()) {
C value = checkNotNull(valueIterator.next());
min = Ordering.natural().min(min, value);
max = Ordering.natural().max(max, value);
}
return closed(min, max);
}
内容来源于网络,如有侵权,请联系作者删除!