@Test public void overlapForKnownValues() { Assert.assertEquals(BigInteger.ONE, ZERO_ONE.overlap(ZERO_ONE)); Assert.assertEquals(BigInteger.ONE, ZERO_ONE.overlap(ZERO_TEN)); Assert.assertEquals(BigInteger.ONE, ZERO_TEN.overlap(ZERO_ONE)); Assert.assertEquals(BigInteger.ZERO, ZERO_ONE.overlap(ONE_TEN)); Assert.assertEquals(BigInteger.ZERO, ONE_TEN.overlap(ZERO_ONE)); Assert.assertEquals(BigInteger.valueOf(9), ZERO_TEN.overlap(ONE_TEN)); Assert.assertEquals(BigInteger.valueOf(9), ONE_TEN.overlap(ZERO_TEN)); }
static BigInteger overlap(List<BigIntegerRange> x, List<BigIntegerRange> y) { int n = x.size(); Preconditions.checkArgument(y.size() == n, "x and y must have the same number of values"); BigInteger overlap = BigInteger.ONE; for (int i = 0; i < n & overlap.signum() != 0; ++i) { BigIntegerRange xRange = x.get(i); BigIntegerRange yRange = y.get(i); overlap = overlap.multiply(xRange.overlap(yRange)); } return overlap; }
BigIntegerRange implements Range<BigInteger, BigIntegerContent> { static BigInteger overlap(List<BigIntegerRange> x, List<BigIntegerRange> y) { int n = x.size(); Preconditions.checkArgument(y.size() == n, "x and y must have the same number of values"); BigInteger overlap = BigInteger.ONE; for (int i = 0; i < n & overlap.signum() != 0; ++i) { BigIntegerRange xRange = x.get(i); BigIntegerRange yRange = y.get(i); overlap = overlap.multiply(xRange.overlap(yRange)); } return overlap; } }
BigIntegerRange implements Range<BigInteger, BigIntegerContent> { static BigInteger overlap(List<BigIntegerRange> x, List<BigIntegerRange> y) { int n = x.size(); Preconditions.checkArgument(y.size() == n, "x and y must have the same number of values"); BigInteger overlap = BigInteger.ONE; for (int i = 0; i < n & overlap.signum() != 0; ++i) { BigIntegerRange xRange = x.get(i); BigIntegerRange yRange = y.get(i); overlap = overlap.multiply(xRange.overlap(yRange)); } return overlap; } BigIntegerRange(BigInteger start, BigInteger end); }
BigIntegerRange implements Range<BigInteger, BigIntegerContent> { static BigInteger overlap(List<BigIntegerRange> x, List<BigIntegerRange> y) { int n = x.size(); Preconditions.checkArgument(y.size() == n, "x and y must have the same number of values"); BigInteger overlap = BigInteger.ONE; for (int i = 0; i < n & overlap.signum() != 0; ++i) { BigIntegerRange xRange = x.get(i); BigIntegerRange yRange = y.get(i); overlap = overlap.multiply(xRange.overlap(yRange)); } return overlap; } BigIntegerRange(BigInteger start, BigInteger end); @Override BigInteger getStart(); @Override BigInteger getEnd(); @Override BigIntegerContent length(); static BigIntegerRange of(long start, long end); static BigIntegerRange of(BigInteger start, BigInteger end); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override boolean contains(BigInteger point); }
BigIntegerRange implements Range<BigInteger, BigIntegerContent> { static BigInteger overlap(List<BigIntegerRange> x, List<BigIntegerRange> y) { int n = x.size(); Preconditions.checkArgument(y.size() == n, "x and y must have the same number of values"); BigInteger overlap = BigInteger.ONE; for (int i = 0; i < n & overlap.signum() != 0; ++i) { BigIntegerRange xRange = x.get(i); BigIntegerRange yRange = y.get(i); overlap = overlap.multiply(xRange.overlap(yRange)); } return overlap; } BigIntegerRange(BigInteger start, BigInteger end); @Override BigInteger getStart(); @Override BigInteger getEnd(); @Override BigIntegerContent length(); static BigIntegerRange of(long start, long end); static BigIntegerRange of(BigInteger start, BigInteger end); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override boolean contains(BigInteger point);  }