compareTo method

  1. @override
int compareTo(
  1. Interval other
)
override

Compares this interval to the other interval.

Two intervals are considered equal when their start and end points are equal. Otherwise, the one that starts first comes first, or if the start points are equal, the one that ends first.

Similarly to Comparator, returns:

  • a negative integer if this interval is less than the other interval,
  • a positive integer if this interval is greater than the other interval,
  • zero if this interval is equal to the other interval.

Implementation

@override
int compareTo(Interval other) {
  return start == other.start
      ? _cmp(end, other.end)
      : _cmp(start, other.start);
}