union method
The union of two ranges is the set of all elements that are in either range.
that
The other range to union with.
Returns a list of ranges that represent the union of the two ranges.
Implementation
List<Range<TYPE>> union(Range<TYPE> that) {
final List<Range<TYPE>> result = [];
if (isSupersetOf(that)) {
result.add(this);
} else if (isSubsetOf(that)) {
result.add(that);
} else if (_esOverlap(that) || _esAdjacent(that)) {
result.add(newInstance()
.._startInclusive = _startInclusive
.._start = _start
.._end = that._end
.._endInclusive = that._endInclusive);
} else if (_seOverlap(that) || _seAdjacent(that)) {
result.add(newInstance()
.._startInclusive = that._startInclusive
.._start = that._start
.._end = _end
.._endInclusive = _endInclusive);
} else {
result..add(this)..add(that);
}
return result;
}