[stdlib] indexing model: Interval/Range merge

This is step 1; we still need to introduce ClosedRange.
This commit is contained in:
Dave Abrahams
2016-03-16 15:57:35 -07:00
parent 8c5cf9b4fc
commit f493b54e44
49 changed files with 431 additions and 633 deletions

View File

@@ -126,13 +126,13 @@ struct A<T> : MutableCollection {
subscript(r: Range<Int>) -> Array<T>.SubSequence {
get {
expectTrue(r.startIndex >= 0 && r.startIndex <= impl.count)
expectTrue(r.endIndex >= 0 && r.endIndex <= impl.count)
expectTrue(r.lowerBound >= 0 && r.lowerBound <= impl.count)
expectTrue(r.upperBound >= 0 && r.upperBound <= impl.count)
return impl[r]
}
set (x) {
expectTrue(r.startIndex >= 0 && r.startIndex <= impl.count)
expectTrue(r.endIndex >= 0 && r.endIndex <= impl.count)
expectTrue(r.lowerBound >= 0 && r.lowerBound <= impl.count)
expectTrue(r.upperBound >= 0 && r.upperBound <= impl.count)
impl[r] = x
}
}