Skip to content

Commit

Permalink
Merge pull request kodecocodes#207 from nemanjavlahovic/selection-sor…
Browse files Browse the repository at this point in the history
…t-nemanja

Update Selection Sort to Swift 3
  • Loading branch information
kelvinlauKL authored Sep 10, 2016
2 parents 3945383 + 19a2eb9 commit 86c4314
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ script:
# - xcodebuild test -project ./Quicksort/Tests/Tests.xcodeproj -scheme Tests
# - xcodebuild test -project ./Run-Length\ Encoding/Tests/Tests.xcodeproj -scheme Tests
# - xcodebuild test -project ./Select\ Minimum\ Maximum/Tests/Tests.xcodeproj -scheme Tests
# - xcodebuild test -project ./Selection\ Sort/Tests/Tests.xcodeproj -scheme Tests
- xcodebuild test -project ./Selection\ Sort/Tests/Tests.xcodeproj -scheme Tests
# - xcodebuild test -project ./Shell\ Sort/Tests/Tests.xcodeproj -scheme Tests
# - xcodebuild test -project ./Shortest\ Path\ \(Unweighted\)/Tests/Tests.xcodeproj -scheme Tests
# - xcodebuild test -project ./Single-Source\ Shortest\ Paths\ \(Weighted\)/SSSP.xcodeproj -scheme SSSPTests
Expand Down
2 changes: 1 addition & 1 deletion Selection Sort/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ As you can see, selection sort is an *in-place* sort because everything happens
Here is an implementation of selection sort in Swift:

```swift
func selectionSort(array: [Int]) -> [Int] {
func selectionSort(_ array: [Int]) -> [Int] {
guard array.count > 1 else { return array } // 1

var a = array // 2
Expand Down
2 changes: 1 addition & 1 deletion Selection Sort/SelectionSort.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//: Playground - noun: a place where people can play

func selectionSort<T>(array: [T], _ isOrderedBefore: (T, T) -> Bool) -> [T] {
func selectionSort<T>(_ array: [T], _ isOrderedBefore: (T, T) -> Bool) -> [T] {
guard array.count > 1 else { return array }
var a = array
for x in 0 ..< a.count - 1 {
Expand Down
2 changes: 1 addition & 1 deletion Selection Sort/SelectionSort.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
func selectionSort<T>(array: [T], _ isOrderedBefore: (T, T) -> Bool) -> [T] {
func selectionSort<T>(_ array: [T], _ isOrderedBefore: (T, T) -> Bool) -> [T] {
guard array.count > 1 else { return array }

var a = array
Expand Down
10 changes: 9 additions & 1 deletion Selection Sort/Tests/Tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Swift Algorithm Club";
TargetAttributes = {
7B2BBC7F1C779D720067B71D = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -149,8 +150,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand Down Expand Up @@ -193,8 +196,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -213,6 +218,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand All @@ -224,6 +230,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -235,6 +242,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit 86c4314

Please sign in to comment.