Skip to content

Commit 48d6e78

Browse files
authored
Merge branch 'master' into master
2 parents a76ac65 + 125dfbc commit 48d6e78

File tree

176 files changed

+2908
-1573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+2908
-1573
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ For the unit tests:
5454

5555
## Want to chat?
5656

57-
This isn't just a repo with a bunch of code... If you want to learn more about how an algorithm works or want to discuss better ways of solving problems, then open a [Github issue](https://github.com/raywenderlich/swift-algorithm-club/issues) and we'll talk!
57+
This isn't just a repo with a bunch of code... If you want to learn more about how an algorithm works or want to discuss better ways of solving problems, then open a [Github issue](https://github.com/raywenderlich/swift-algorithm-club/issues) and we'll talk!

AVL Tree/AVLTree.playground/Sources/AVLTree.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,11 @@ extension AVLTree {
341341
}
342342
} else {
343343
// Handle stem cases
344-
if let replacement = node.leftChild?.maximum() , replacement !== node {
344+
if let replacement = node.leftChild?.maximum(), replacement !== node {
345345
node.key = replacement.key
346346
node.payload = replacement.payload
347347
delete(node: replacement)
348-
} else if let replacement = node.rightChild?.minimum() , replacement !== node {
348+
} else if let replacement = node.rightChild?.minimum(), replacement !== node {
349349
node.key = replacement.key
350350
node.payload = replacement.payload
351351
delete(node: replacement)
@@ -354,7 +354,6 @@ extension AVLTree {
354354
}
355355
}
356356

357-
358357
// MARK: - Debugging
359358

360359
extension TreeNode: CustomDebugStringConvertible {

AVL Tree/AVLTree.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,11 @@ extension AVLTree {
341341
}
342342
} else {
343343
// Handle stem cases
344-
if let replacement = node.leftChild?.maximum() , replacement !== node {
344+
if let replacement = node.leftChild?.maximum(), replacement !== node {
345345
node.key = replacement.key
346346
node.payload = replacement.payload
347347
delete(node: replacement)
348-
} else if let replacement = node.rightChild?.minimum() , replacement !== node {
348+
} else if let replacement = node.rightChild?.minimum(), replacement !== node {
349349
node.key = replacement.key
350350
node.payload = replacement.payload
351351
delete(node: replacement)
@@ -354,7 +354,6 @@ extension AVLTree {
354354
}
355355
}
356356

357-
358357
// MARK: - Debugging
359358

360359
extension TreeNode: CustomDebugStringConvertible {

AVL Tree/Tests/TreeNodeTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class TreeNodeTests: XCTestCase {
2727
super.tearDown()
2828
}
2929

30-
3130
func testSingleNodeCreationNOPayload() {
3231
let treeNode = TreeNode<String, String>(key: "Building")
3332
XCTAssertNil(treeNode.payload, "Payload for this case should be nil")

All-Pairs Shortest Paths/APSP/APSP/FloydWarshall.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public struct FloydWarshallResult<T>: APSPResult where T: Hashable {
175175
public func path(fromVertex from: Vertex<T>, toVertex to: Vertex<T>, inGraph graph: AbstractGraph<T>) -> [T]? {
176176

177177
if let path = recursePathFrom(fromVertex: from, toVertex: to, path: [ to ], inGraph: graph) {
178-
let pathValues = path.map() { vertex in
178+
let pathValues = path.map { vertex in
179179
vertex.data
180180
}
181181
return pathValues

All-Pairs Shortest Paths/APSP/APSP/Helpers.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99

10-
1110
/**
1211
Print a matrix, optionally specifying only the cells to display with the triplet (i, j, k) -> matrix[i][j], matrix[i][k], matrix[k][j]
1312
*/

Array2D/Array2D.playground/Contents.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ public struct Array2D<T> {
77
public let columns: Int
88
public let rows: Int
99
fileprivate var array: [T]
10-
10+
1111
public init(columns: Int, rows: Int, initialValue: T) {
1212
self.columns = columns
1313
self.rows = rows
1414
array = .init(repeating: initialValue, count: rows*columns)
1515
}
16-
16+
1717
public subscript(column: Int, row: Int) -> T {
1818
get {
1919
precondition(column < columns, "Column \(column) Index is out of range. Array<T>(columns: \(columns), rows:\(rows))")
@@ -28,7 +28,6 @@ public struct Array2D<T> {
2828
}
2929
}
3030

31-
3231
// initialization
3332
var matrix = Array2D(columns: 3, rows: 5, initialValue: 0)
3433

Array2D/Array2D.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ public struct Array2D<T> {
77
public let columns: Int
88
public let rows: Int
99
fileprivate var array: [T]
10-
10+
1111
public init(columns: Int, rows: Int, initialValue: T) {
1212
self.columns = columns
1313
self.rows = rows
1414
array = .init(repeating: initialValue, count: rows*columns)
1515
}
16-
16+
1717
public subscript(column: Int, row: Int) -> T {
1818
get {
1919
precondition(column < columns, "Column \(column) Index is out of range. Array<T>(columns: \(columns), rows:\(rows))")

B-Tree/BTree.playground/Contents.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ bTree[3]
1414

1515
bTree.remove(2)
1616

17-
bTree.traverseKeysInOrder {
18-
key in
17+
bTree.traverseKeysInOrder { key in
1918
print(key)
2019
}
2120

0 commit comments

Comments
 (0)