本文整理了Java中com.google.common.collect.Range.lessThan
方法的一些代码示例,展示了Range.lessThan
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.lessThan
方法的具体详情如下:
包路径:com.google.common.collect.Range
类名称:Range
方法名:lessThan
[英]Returns a range that contains all values strictly less than endpoint.
[中]返回一个包含严格小于端点的所有值的范围。
代码示例来源:origin: google/guava
public void testCreate_noMin() {
Range<Integer> range = Range.lessThan(0);
try {
ContiguousSet.create(range, RangeTest.UNBOUNDED_DOMAIN);
fail();
} catch (IllegalArgumentException expected) {
}
}
代码示例来源:origin: google/guava
public void testIgnoresSmallerSharingLowerBound() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 6));
rangeSet.add(Range.closed(1, 4));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testIgnoresSmallerSharingUpperBound() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 6));
rangeSet.add(Range.closed(3, 6));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testIgnoresEqual() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 6));
rangeSet.add(Range.closed(1, 6));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testExtendSameLowerBound() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 4));
rangeSet.add(Range.closed(1, 6));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testExtendSameUpperBound() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(3, 6));
rangeSet.add(Range.closed(1, 6));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testExtendBothDirections() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(3, 4));
rangeSet.add(Range.closed(1, 6));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testOrderingCuts() {
Cut<Integer> a = Range.lessThan(0).lowerBound;
Cut<Integer> b = Range.atLeast(0).lowerBound;
Cut<Integer> c = Range.greaterThan(0).lowerBound;
Cut<Integer> d = Range.atLeast(1).lowerBound;
Cut<Integer> e = Range.greaterThan(1).lowerBound;
Cut<Integer> f = Range.greaterThan(1).upperBound;
Helpers.testCompareToAndEquals(ImmutableList.of(a, b, c, d, e, f));
}
代码示例来源:origin: google/guava
public void testIgnoresSmallerSharingNoBound() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 6));
rangeSet.add(Range.open(2, 4));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testRemoveEmpty() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 6));
rangeSet.remove(Range.closedOpen(3, 3));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testCreate_empty() {
assertEquals(ImmutableSet.of(), ContiguousSet.create(Range.closedOpen(1, 1), integers()));
assertEquals(ImmutableSet.of(), ContiguousSet.closedOpen(1, 1));
assertEquals(ImmutableSet.of(), ContiguousSet.create(Range.openClosed(5, 5), integers()));
assertEquals(
ImmutableSet.of(), ContiguousSet.create(Range.lessThan(Integer.MIN_VALUE), integers()));
assertEquals(
ImmutableSet.of(), ContiguousSet.create(Range.greaterThan(Integer.MAX_VALUE), integers()));
}
代码示例来源:origin: google/guava
public void testCanonical_unboundedDomain() {
assertEquals(Range.lessThan(0), Range.lessThan(0).canonical(UNBOUNDED_DOMAIN));
assertEquals(Range.lessThan(1), Range.atMost(0).canonical(UNBOUNDED_DOMAIN));
assertEquals(Range.atLeast(0), Range.atLeast(0).canonical(UNBOUNDED_DOMAIN));
assertEquals(Range.atLeast(1), Range.greaterThan(0).canonical(UNBOUNDED_DOMAIN));
assertEquals(Range.all(), Range.<Integer>all().canonical(UNBOUNDED_DOMAIN));
}
代码示例来源:origin: google/guava
public void testRemovePartSharingLowerBound() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(3, 5));
rangeSet.remove(Range.closedOpen(3, 5));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.singleton(5));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(5), Range.greaterThan(5))
.inOrder();
}
代码示例来源:origin: google/guava
public void testRemovePartSharingUpperBound() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(3, 5));
rangeSet.remove(Range.openClosed(3, 5));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.singleton(3));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(3), Range.greaterThan(3))
.inOrder();
}
代码示例来源:origin: google/guava
public void testMergesConnectedWithOverlap() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 4));
rangeSet.add(Range.open(2, 6));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.atLeast(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testMergesConnectedDisjoint() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 4));
rangeSet.add(Range.open(4, 6));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.atLeast(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testRemoveMiddle() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.atMost(6));
rangeSet.remove(Range.closedOpen(3, 4));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges())
.containsExactly(Range.lessThan(3), Range.closed(4, 6))
.inOrder();
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.closedOpen(3, 4), Range.greaterThan(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testLessThan() {
Range<Integer> range = Range.lessThan(5);
assertTrue(range.contains(Integer.MIN_VALUE));
assertTrue(range.contains(4));
assertFalse(range.contains(5));
assertUnboundedBelow(range);
assertTrue(range.hasUpperBound());
assertEquals(5, (int) range.upperEndpoint());
assertEquals(OPEN, range.upperBoundType());
assertFalse(range.isEmpty());
assertEquals("(-\u221e..5)", range.toString());
reserializeAndAssert(range);
}
代码示例来源:origin: google/guava
public void testFillHoleExactly() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closedOpen(1, 3));
rangeSet.add(Range.closedOpen(4, 6));
rangeSet.add(Range.closedOpen(3, 4));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.atLeast(6))
.inOrder();
}
代码示例来源:origin: google/guava
public void testFillHoleWithOverlap() {
TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closedOpen(1, 3));
rangeSet.add(Range.closedOpen(4, 6));
rangeSet.add(Range.closedOpen(2, 5));
testInvariants(rangeSet);
assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
assertThat(rangeSet.complement().asRanges())
.containsExactly(Range.lessThan(1), Range.atLeast(6))
.inOrder();
}
内容来源于网络,如有侵权,请联系作者删除!