android/guava/src/com/google/common/collect/Range.java
public boolean isConnected(Range<C> other) {
    return lowerBound.compareTo(other.upperBound) <= 0
        && other.lowerBound.compareTo(upperBound) <= 0;
  }
public boolean isConnected(Range<C> other) {
    return lowerBound.compareTo(other.upperBound) <= 0
        && other.lowerBound.compareTo(upperBound) <= 0;
  }
Returns {@code true} if there exists a (possibly empty) range which is {@linkplain #encloses
enclosed} by both this range and {@code other}.

<p>For example,

<ul>
<li>{@code [2, 4)} and {@code [5, 7)} are not connected
<li>{@code [2, 4)} and {@code [3, 5)} are connected, because both enclose {@code [3, 4)}
<li>{@code [2, 4)} and {@code [4, 6)} are connected, because both enclose the empty range
{@code [4, 4)}
</ul>

<p>Note that this range and {@code other} have a well-defined {@linkplain #span union} and
{@linkplain #intersection intersection} (as a single, possibly-empty range) if and only if this
method returns {@code true}.

<p>The connectedness relation is both reflexive and symmetric, but does not form an {@linkplain
Equivalence equivalence relation} as it is not transitive.

<p>Note that certain discrete ranges are not considered connected, even though there are no
elements "between them." For example, {@code [3, 5]} is not considered connected to {@code [6,
10]}. In these cases, it may be desirable for both input ranges to be preprocessed with {@link
#canonical(DiscreteDomain)} before testing for connectedness.