intersects abstract method

  1. @useResult
bool intersects(
  1. Range<T> other
)

Returns true if a non-empty range exists between this and other.

See intersection for computing the intersection of two ranges.

This method is reflexive and symmetric.

Examples

final a = Interval.closed(1, 4);
final b = Interval.closed(1, 4);

a.intersects(b); // true, [1..4] intersects [1..4]
final a = Interval.closed(1, 4);
final b = Interval.closedOpen(2, 3);

a.intersects(b); // true, [1..4] intersects [2..3]
final a = Interval.openClosed(3, 6);
final b = Interval.openClosed(2, 8);

a.intersects(b); // true, (3..6] intersects (4..8]
final a = Interval.openClosed(3, 6);
final b = Interval.closedOpen(1, 2);

a.intersects(b); // false, (3..6] does not intersect (1..2]
final a = Interval.closedOpen(1, 3);
final b = Interval.closedOpen(3, 5);

a.besides(b); // false, [1..3) does not intersect [3..5)

Implementation

@useResult bool intersects(Range<T> other);