[stdlib] swapAt method (#9119)

* Add swapAt method

* Migrate sorting to swapAt

* Migrate further stdlib usage
This commit is contained in:
Ben Cohen
2017-04-29 11:55:00 -07:00
committed by GitHub
parent 0f24c5c34e
commit 1163ea7c7a
8 changed files with 36 additions and 20 deletions

View File

@@ -165,7 +165,7 @@ extension MutableCollection {
var i = index(after: pivot)
while i < endIndex {
if try !belongsInSecondPartition(self[i]) {
swap(&self[i], &self[pivot])
swapAt(i, pivot)
formIndex(after: &pivot)
}
formIndex(after: &i)
@@ -217,7 +217,7 @@ extension MutableCollection where Self : BidirectionalCollection {
break Loop
} while false
swap(&self[lo], &self[hi])
swapAt(lo, hi)
formIndex(after: &lo)
}