本文整理了Java中org.apache.commons.lang3.Range.containsRange
方法的一些代码示例,展示了Range.containsRange
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.containsRange
方法的具体详情如下:
包路径:org.apache.commons.lang3.Range
类名称:Range
方法名:containsRange
[英]Checks whether this range contains all the elements of the specified range.
This method may fail if the ranges have two different comparators or element types.
[中]检查此范围是否包含指定范围的所有元素。
如果量程有两个不同的比较器或元件类型,此方法可能会失败。
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testContainsRange() {
// null handling
assertFalse(intRange.containsRange(null));
// easy inside range
assertTrue(intRange.containsRange(Range.between(12, 18)));
// outside range on each side
assertFalse(intRange.containsRange(Range.between(32, 45)));
assertFalse(intRange.containsRange(Range.between(2, 8)));
// equals range
assertTrue(intRange.containsRange(Range.between(10, 20)));
// overlaps
assertFalse(intRange.containsRange(Range.between(9, 14)));
assertFalse(intRange.containsRange(Range.between(16, 21)));
// touches lower boundary
assertTrue(intRange.containsRange(Range.between(10, 19)));
assertFalse(intRange.containsRange(Range.between(10, 21)));
// touches upper boundary
assertTrue(intRange.containsRange(Range.between(11, 20)));
assertFalse(intRange.containsRange(Range.between(9, 20)));
// negative
assertFalse(intRange.containsRange(Range.between(-11, -18)));
}
代码示例来源:origin: com.opencsv/opencsv
while(it.hasNext() && ! completelyContained) {
final Range<Integer> next = it.next();
if(next.containsRange(range)) {
completelyContained = true;
内容来源于网络,如有侵权,请联系作者删除!