Skip to content

Commit 85ff254

Browse files
committed
Migrated Playground and Test to Swift 4
1 parent 0e0ae64 commit 85ff254

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

Comb Sort/Comb Sort.playground/Contents.swift

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// 7-16-2016
44

55
import Cocoa
6+
// last checked with Xcode 9.0b4
7+
#if swift(>=4.0)
8+
print("Hello, Swift 4!")
9+
#endif
610

711
// Test Comb Sort with small array of ten values
812
let array = [2, 32, 9, -1, 89, 101, 55, -10, -12, 67]

Comb Sort/Comb Sort.playground/Sources/Comb Sort.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public func combSort<T: Comparable>(_ input: [T]) -> [T] {
2121
var index = 0
2222
while !(index + gap >= copy.count) {
2323
if copy[index] > copy[index + gap] {
24-
swap(&copy[index], &copy[index + gap])
24+
copy.swapAt(index, index + gap)
2525
}
2626
index += 1
2727
}

Comb Sort/Comb Sort.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ public func combSort<T: Comparable>(_ input: [T]) -> [T] {
1111
var copy: [T] = input
1212
var gap = copy.count
1313
let shrink = 1.3
14-
14+
1515
while gap > 1 {
1616
gap = (Int)(Double(gap) / shrink)
1717
if gap < 1 {
1818
gap = 1
1919
}
20-
20+
2121
var index = 0
2222
while !(index + gap >= copy.count) {
2323
if copy[index] > copy[index + gap] {
24-
swap(&copy[index], &copy[index + gap])
24+
copy.swapAt(index, index + gap)
2525
}
2626
index += 1
2727
}

Comb Sort/Tests/CombSortTests.swift

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class CombSortTests: XCTestCase {
1212
var sequence: [Int]!
1313
let expectedSequence: [Int] = [-12, -10, -1, 2, 9, 32, 55, 67, 89, 101]
1414

15+
func testSwift4(){
16+
#if swift(>=4.0)
17+
print("Hello, Swift 4!")
18+
#endif
19+
}
1520
override func setUp() {
1621
super.setUp()
1722
sequence = [2, 32, 9, -1, 89, 101, 55, -10, -12, 67]

Comb Sort/Tests/Tests.xcodeproj/project.pbxproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
SDKROOT = macosx;
180180
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
181181
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
182+
SWIFT_VERSION = 4.0;
182183
};
183184
name = Debug;
184185
};
@@ -220,6 +221,7 @@
220221
MTL_ENABLE_DEBUG_INFO = NO;
221222
SDKROOT = macosx;
222223
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
224+
SWIFT_VERSION = 4.0;
223225
};
224226
name = Release;
225227
};
@@ -233,7 +235,7 @@
233235
PRODUCT_BUNDLE_IDENTIFIER = "Swift-Algorithm-Club.Tests";
234236
PRODUCT_NAME = "$(TARGET_NAME)";
235237
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
236-
SWIFT_VERSION = 3.0;
238+
SWIFT_VERSION = 4.0;
237239
};
238240
name = Debug;
239241
};
@@ -246,7 +248,7 @@
246248
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
247249
PRODUCT_BUNDLE_IDENTIFIER = "Swift-Algorithm-Club.Tests";
248250
PRODUCT_NAME = "$(TARGET_NAME)";
249-
SWIFT_VERSION = 3.0;
251+
SWIFT_VERSION = 4.0;
250252
};
251253
name = Release;
252254
};

0 commit comments

Comments
 (0)