Skip to content

Commit 7d49b71

Browse files
committed
2 parents 5f40f33 + 85954b8 commit 7d49b71

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

README.md

+19-15
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,15 @@ The project features code-level examples for the following items:
4343

4444
The Book
4545
--------------------
46-
Now in its **3rd edition** and supporting **Swift 4.0**, the <a href="http://shop.waynewbishop.com" target="_blank">The Swift Algorithms Book</a> features code and color illustrations that benefits students and professionals. As a collaborative open-source effort, I also welcome <a href="https://twitter.com/waynewbishop" target="_blank">feedback</a> and contribution from others.
46+
Now in its **4th edition** and supporting **Swift 4.2**, the <a href="http://shop.waynewbishop.com" target="_blank">The Swift Algorithms Book</a> features code and color illustrations that benefits students and professionals. As a collaborative open-source effort, I also welcome <a href="https://twitter.com/waynewbishop" target="_blank">feedback</a> and contribution from others.
4747

4848

4949
Example
5050
--------------------
5151

5252
```swift
53-
/* graph traversal - breadth first search */
54-
55-
func traverse(_ startingv: Vertex, formula: (inout node: Vertex) -> ()) {
53+
//bfs traversal with inout closure function
54+
func traverse(_ startingv: Vertex, formula: (_ node: inout Vertex) -> ()) {
5655

5756

5857
//establish a new queue
@@ -65,35 +64,40 @@ Example
6564

6665
while !graphQueue.isEmpty() {
6766

68-
//traverse the next queued vertex
69-
var vitem: Vertex = graphQueue.deQueue() as Vertex!
7067

68+
//traverse the next queued vertex - Swift 4.0
69+
//var vitem: Vertex! = graphQueue.deQueue()
70+
71+
72+
//traverse the next queued vertex
73+
guard var vitem = graphQueue.deQueue() else {
74+
break
75+
}
7176

7277
//add unvisited vertices to the queue
7378
for e in vitem.neighbors {
7479
if e.neighbor.visited == false {
75-
print("adding vertex: \(e.neighbor.key!) to queue..")
80+
print("adding vertex: \(e.neighbor.key) to queue..")
7681
graphQueue.enQueue(e.neighbor)
7782
}
7883
}
79-
80-
//invoke with inout parameter
81-
formula(node: &vitem)
8284

85+
//invoke formula
86+
formula(&vitem)
87+
8388

8489
} //end while
8590

8691

87-
print("graph traversal complete..")
88-
92+
print("graph traversal complete..")
93+
8994
}
90-
9195
```
9296

9397
Getting Started
9498
--------------------
9599

96-
Swift Structures has been optimized for **Swift 4.0** (e.g., Xcode 9.0) or later. The directories are organized as follows:
100+
Swift Structures has been optimized for **Swift 4.2** (e.g., Xcode 10.0) or later. The directories are organized as follows:
97101
+ Source - Code for all Swift data structures, algorithms and source extensions
98102
+ Example - An empty iOS single-view application template
99103
+ SwiftTests - Unit tests with XCTest Framework
@@ -106,7 +110,7 @@ Individuals are welcome to use the code with commercial and open-source projects
106110
Branches
107111
--------------------
108112
+ master - The production branch. Clone or fork this repository for the latest copy
109-
+ develop - The active Swift 4.0 development branch. Swift 4.0 [pull requests](https://help.github.com/articles/creating-a-pull-request) should be directed to this branch
113+
+ develop - The active Swift 4.2 development branch. Swift 4.2 [pull requests](https://help.github.com/articles/creating-a-pull-request) should be directed to this branch
110114

111115

112116

0 commit comments

Comments
 (0)