containsRange method
Returns whether this range contains the entire other range.
Implementation
bool containsRange(RangeBounds<C> range) {
final startMatches = switch (startBound) {
InclusiveBound(value: final thisStart) => switch (range.startBound) {
InclusiveBound(value: final otherStart) ||
ExclusiveBound(value: final otherStart) =>
thisStart.compareTo(otherStart) <= 0,
UnboundedBound() => false,
},
ExclusiveBound(value: final thisStart) => switch (range.startBound) {
InclusiveBound(value: final otherStart) =>
thisStart.compareTo(otherStart) < 0,
ExclusiveBound(value: final otherStart) =>
thisStart.compareTo(otherStart) <= 0,
UnboundedBound() => false,
},
UnboundedBound() => true,
};
final endMatches = switch (endBound) {
InclusiveBound(value: final thisEnd) => switch (range.endBound) {
InclusiveBound(value: final otherEnd) ||
ExclusiveBound(value: final otherEnd) =>
thisEnd.compareTo(otherEnd) >= 0,
UnboundedBound() => false,
},
ExclusiveBound(value: final thisEnd) => switch (range.endBound) {
InclusiveBound(value: final otherEnd) =>
thisEnd.compareTo(otherEnd) > 0,
ExclusiveBound(value: final otherEnd) =>
thisEnd.compareTo(otherEnd) >= 0,
UnboundedBound() => false,
},
UnboundedBound() => true,
};
return startMatches && endMatches;
}