com.google.common.collect.Range.greaterThan()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中com.google.common.collect.Range.greaterThan方法的一些代码示例,展示了Range.greaterThan的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.greaterThan方法的具体详情如下:
包路径:com.google.common.collect.Range
类名称:Range
方法名:greaterThan

Range.greaterThan介绍

[英]Returns a range that contains all values strictly greater than endpoint.
[中]返回一个包含严格大于端点的所有值的范围。

代码示例

代码示例来源: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 testCreate_noMax() {
 Range<Integer> range = Range.greaterThan(0);
 try {
  ContiguousSet.create(range, RangeTest.UNBOUNDED_DOMAIN);
  fail();
 } catch (IllegalArgumentException expected) {
 }
}

代码示例来源: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 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 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 testEquals() {
 new EqualsTester()
   .addEqualityGroup(Range.open(1, 5), Range.range(1, OPEN, 5, OPEN))
   .addEqualityGroup(Range.greaterThan(2), Range.greaterThan(2))
   .addEqualityGroup(Range.all(), Range.all())
   .addEqualityGroup("Phil")
   .testEquals();
}

代码示例来源: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 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 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 testGreaterThan() {
 Range<Integer> range = Range.greaterThan(5);
 assertFalse(range.contains(5));
 assertTrue(range.contains(6));
 assertTrue(range.contains(Integer.MAX_VALUE));
 assertTrue(range.hasLowerBound());
 assertEquals(5, (int) range.lowerEndpoint());
 assertEquals(OPEN, range.lowerBoundType());
 assertUnboundedAbove(range);
 assertFalse(range.isEmpty());
 assertEquals("(5..+\u221e)", range.toString());
 reserializeAndAssert(range);
}

代码示例来源:origin: google/guava

public void testEncloses_closed() {
 Range<Integer> range = Range.closed(2, 5);
 assertTrue(range.encloses(range));
 assertTrue(range.encloses(Range.open(2, 5)));
 assertTrue(range.encloses(Range.openClosed(2, 5)));
 assertTrue(range.encloses(Range.closedOpen(2, 5)));
 assertTrue(range.encloses(Range.closed(3, 5)));
 assertTrue(range.encloses(Range.closed(2, 4)));
 assertFalse(range.encloses(Range.open(1, 6)));
 assertFalse(range.encloses(Range.greaterThan(3)));
 assertFalse(range.encloses(Range.lessThan(3)));
 assertFalse(range.encloses(Range.atLeast(3)));
 assertFalse(range.encloses(Range.atMost(3)));
 assertFalse(range.encloses(Range.<Integer>all()));
}

代码示例来源: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 testEquivalentFactories() {
  new EqualsTester()
    .addEqualityGroup(Range.all())
    .addEqualityGroup(Range.atLeast(1), Range.downTo(1, CLOSED))
    .addEqualityGroup(Range.greaterThan(1), Range.downTo(1, OPEN))
    .addEqualityGroup(Range.atMost(7), Range.upTo(7, CLOSED))
    .addEqualityGroup(Range.lessThan(7), Range.upTo(7, OPEN))
    .addEqualityGroup(Range.open(1, 7), Range.range(1, OPEN, 7, OPEN))
    .addEqualityGroup(Range.openClosed(1, 7), Range.range(1, OPEN, 7, CLOSED))
    .addEqualityGroup(Range.closed(1, 7), Range.range(1, CLOSED, 7, CLOSED))
    .addEqualityGroup(Range.closedOpen(1, 7), Range.range(1, CLOSED, 7, OPEN))
    .testEquals();
 }
}

代码示例来源:origin: google/guava

public void testCanonical() {
 assertEquals(Range.closedOpen(1, 5), Range.closed(1, 4).canonical(integers()));
 assertEquals(Range.closedOpen(1, 5), Range.open(0, 5).canonical(integers()));
 assertEquals(Range.closedOpen(1, 5), Range.closedOpen(1, 5).canonical(integers()));
 assertEquals(Range.closedOpen(1, 5), Range.openClosed(0, 4).canonical(integers()));
 assertEquals(
   Range.closedOpen(Integer.MIN_VALUE, 0),
   Range.closedOpen(Integer.MIN_VALUE, 0).canonical(integers()));
 assertEquals(Range.closedOpen(Integer.MIN_VALUE, 0), Range.lessThan(0).canonical(integers()));
 assertEquals(Range.closedOpen(Integer.MIN_VALUE, 1), Range.atMost(0).canonical(integers()));
 assertEquals(Range.atLeast(0), Range.atLeast(0).canonical(integers()));
 assertEquals(Range.atLeast(1), Range.greaterThan(0).canonical(integers()));
 assertEquals(Range.atLeast(Integer.MIN_VALUE), Range.<Integer>all().canonical(integers()));
}

相关文章