in Sources/SE0270_RangeSet/RangeSet.swift [110:132]
func _indicesOfRange(_ range: Range<Bound>) -> Range<Int> {
precondition(!range.isEmpty)
precondition(!_ranges.isEmpty)
precondition(range.lowerBound <= _ranges.last!.upperBound)
precondition(range.upperBound >= _ranges.first!.lowerBound)
// The beginning index for the position of `range` is the first range
// with an upper bound larger than `range`'s lower bound. The range
// at this position may or may not overlap `range`.
let beginningIndex = _ranges
._partitioningIndex { $0.upperBound >= range.lowerBound }
// The ending index for `range` is the first range with a lower bound
// greater than `range`'s upper bound. If this is the same as
// `beginningIndex`, than `range` doesn't overlap any of the existing
// ranges. If this is `ranges.endIndex`, then `range` overlaps the
// rest of the ranges. Otherwise, `range` overlaps one or
// more ranges in the set.
let endingIndex = _ranges[beginningIndex...]
._partitioningIndex { $0.lowerBound > range.upperBound }
return beginningIndex ..< endingIndex
}