except method
The difference between two ranges is the set of all elements that are in this range but not in the other range.
that
The other range to subtract.
Returns a list of ranges that represent the difference between the two ranges.
Implementation
List<Range<TYPE>> except(Range<TYPE> that) {
final List<Range<TYPE>> result = [];
//if (this.start < that.start && this.end > that.end) {
if (isSupersetOf(that)) {
if (_startL(that)) {
result.add(newInstance()
.._startInclusive = _startInclusive
.._start = _start
.._end = that._start
.._endInclusive = !that._startInclusive);
}
if (_endG(that)) {
result.add(newInstance()
.._startInclusive = !that._endInclusive
.._start = that._end
.._end = _end
.._endInclusive = _endInclusive);
}
} else if (isSubsetOf(that)) {
// empty
} else if (_esOverlap(that) || _esAdjacent(that)) {
result.add(newInstance()
.._startInclusive = _startInclusive
.._start = _start
.._end = that._start
.._endInclusive = !that._startInclusive);
} else if (_seOverlap(that) || _seAdjacent(that)) {
result.add(newInstance()
.._startInclusive = !that._endInclusive
.._start = that._end
.._end = _end
.._endInclusive = _endInclusive);
} else {
result.add(this);
}
return result;
}