[stdlib] De-gyb Sort (#17954)

* [stdlib] De-gyb Sort
This commit is contained in:
Ben Cohen
2018-07-15 14:23:06 -07:00
committed by GitHub
parent adf79f92bc
commit bd7171bedf
7 changed files with 621 additions and 696 deletions

View File

@@ -26,7 +26,7 @@ Algorithm.test("min,max") {
let a3 = MinimalComparableValue(0, identity: 3)
let b1 = MinimalComparableValue(1, identity: 4)
let b2 = MinimalComparableValue(1, identity: 5)
let b3 = MinimalComparableValue(1, identity: 6)
_ = MinimalComparableValue(1, identity: 6)
let c1 = MinimalComparableValue(2, identity: 7)
let c2 = MinimalComparableValue(2, identity: 8)
let c3 = MinimalComparableValue(2, identity: 9)
@@ -80,7 +80,7 @@ Algorithm.test("sorted/strings") {
["apple", "Banana", "cherry"].sorted())
let s = ["apple", "Banana", "cherry"].sorted() {
$0.characters.count > $1.characters.count
$0.count > $1.count
}
expectEqual(["Banana", "cherry", "apple"], s)
}
@@ -140,7 +140,7 @@ func randomArray() -> A<Int> {
Algorithm.test("invalidOrderings") {
withInvalidOrderings {
var a = randomArray()
let a = randomArray()
_blackHole(a.sorted(by: $0))
}
withInvalidOrderings {
@@ -218,7 +218,7 @@ Algorithm.test("sorted/complexity") {
}
Algorithm.test("sorted/return type") {
let x: Array = ([5, 4, 3, 2, 1] as ArraySlice).sorted()
let _: Array = ([5, 4, 3, 2, 1] as ArraySlice).sorted()
}
Algorithm.test("sort3/simple")
@@ -226,7 +226,7 @@ Algorithm.test("sort3/simple")
[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]
]) {
var input = $0
_sort3(&input, 0, 1, 2)
input.sort()
expectEqual([1, 2, 3], input)
}