Skip to content

Commit 52ec30f

Browse files
authored
Merge pull request kodecocodes#376 from JuIioCesar/Breadth-First-Search-Tests-Swift-3-Syntax
Migrate Breadth First Search tests to Swift 3 syntax
2 parents c1c1a55 + e0a3b63 commit 52ec30f

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Breadth-First Search/Tests/Graph.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class Node: CustomStringConvertible, Equatable {
3939
}
4040

4141
public func remove(edge: Edge) {
42-
neighbors.removeAtIndex(neighbors.indexOf { $0 === edge }!)
42+
neighbors.remove(at: neighbors.index { $0 === edge }!)
4343
}
4444
}
4545

@@ -56,13 +56,13 @@ public class Graph: CustomStringConvertible, Equatable {
5656
self.nodes = []
5757
}
5858

59-
public func addNode(label: String) -> Node {
59+
public func addNode(_ label: String) -> Node {
6060
let node = Node(label: label)
6161
nodes.append(node)
6262
return node
6363
}
6464

65-
public func addEdge(source: Node, neighbor: Node) {
65+
public func addEdge(_ source: Node, neighbor: Node) {
6666
let edge = Edge(neighbor: neighbor)
6767
source.neighbors.append(edge)
6868
}
@@ -78,15 +78,15 @@ public class Graph: CustomStringConvertible, Equatable {
7878
return description
7979
}
8080

81-
public func findNodeWithLabel(label: String) -> Node {
81+
public func findNodeWithLabel(_ label: String) -> Node {
8282
return nodes.filter { $0.label == label }.first!
8383
}
8484

8585
public func duplicate() -> Graph {
8686
let duplicated = Graph()
8787

8888
for node in nodes {
89-
duplicated.addNode(node.label)
89+
let _ = duplicated.addNode(node.label)
9090
}
9191

9292
for node in nodes {

Breadth-First Search/Tests/Queue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct Queue<T> {
1313
return array.count
1414
}
1515

16-
public mutating func enqueue(element: T) {
16+
public mutating func enqueue(_ element: T) {
1717
array.append(element)
1818
}
1919

Breadth-First Search/Tests/Tests.xcodeproj/project.pbxproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@
8989
isa = PBXProject;
9090
attributes = {
9191
LastSwiftUpdateCheck = 0720;
92-
LastUpgradeCheck = 0720;
92+
LastUpgradeCheck = 0820;
9393
ORGANIZATIONNAME = "Swift Algorithm Club";
9494
TargetAttributes = {
9595
7B2BBC7F1C779D720067B71D = {
9696
CreatedOnToolsVersion = 7.2;
97+
LastSwiftMigration = 0820;
9798
};
9899
};
99100
};
@@ -230,6 +231,7 @@
230231
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
231232
PRODUCT_NAME = "$(TARGET_NAME)";
232233
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
234+
SWIFT_VERSION = 3.0;
233235
};
234236
name = Debug;
235237
};
@@ -242,6 +244,7 @@
242244
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
243245
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
244246
PRODUCT_NAME = "$(TARGET_NAME)";
247+
SWIFT_VERSION = 3.0;
245248
};
246249
name = Release;
247250
};

Breadth-First Search/Tests/Tests.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0820"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

0 commit comments

Comments
 (0)