Skip to content

Commit 3620b28

Browse files
committed
Xcode 8.0 / beta6 code updates..
- minor changes to cast initializers, infix operators and inout parameter declaration. - continued work quicksort algorithm unit tests.
1 parent 676b86f commit 3620b28

File tree

10 files changed

+35
-41
lines changed

10 files changed

+35
-41
lines changed

Example/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
17+
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

Source/Extensions/Array.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ extension Array where Element: Comparable {
5252
//evaluate chosen number..
5353
let n = self[mid]
5454

55-
print(String(n) + " value attempted..")
55+
56+
print(String(describing: n) + "value attempted..")
5657

5758

5859
if n > key {
@@ -256,13 +257,10 @@ extension Array where Element: Comparable {
256257

257258
/*
258259
quicksort algorithm - Ranks numbers through a series of swaps.
259-
Based on "conceptually" partioning a series through the application of a "wall" and "pivot".
260+
Based on "conceptually" sorting a collection subset based on a "wall" and "pivot".
260261
Best case performance of O(n log(n)). Worst case performance of O(n2).
261262
*/
262263

263-
264-
265-
//determines sorting range - performance: O(n log(n))
266264
mutating func quickSort() -> Array<Element> {
267265

268266

@@ -283,7 +281,7 @@ extension Array where Element: Comparable {
283281

284282

285283

286-
//sorts collection range based on pivot
284+
//sorts collection-range based on pivot
287285
mutating func qPartition(start startIndex: Int, _ pivot: Int) -> Int {
288286

289287
var wallIndex: Int = startIndex

Source/Factories/Graph.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public class SwiftGraph {
308308

309309

310310
//bfs traversal with inout closure function
311-
func traverse(_ startingv: Vertex, formula: (inout node: Vertex) -> ()) {
311+
func traverse(_ startingv: Vertex, formula: (_ node: inout Vertex) -> ()) {
312312

313313

314314
//establish a new queue
@@ -340,7 +340,7 @@ public class SwiftGraph {
340340
*/
341341

342342
//invoke formula
343-
formula(node: &vitem)
343+
formula(&vitem)
344344

345345

346346
} //end while

Source/Factories/HashList.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ class HashList<T> {
142142

143143
//string type
144144
case is String:
145-
return String(element)
145+
return String(describing: element)
146146

147147

148148

149149
//int type
150150
case is Int:
151-
let stringElement = String(element)
151+
let stringElement = String(describing: element)
152152
return stringElement
153153

154154

Source/Structures/AVLTree.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class AVLTree<T: Comparable> {
5050

5151

5252
//check left side
53-
if key < self.key {
53+
if key < self.key! {
5454

5555

5656
if self.left != nil {
@@ -78,7 +78,7 @@ public class AVLTree<T: Comparable> {
7878

7979

8080
//check right side
81-
if key > self.key {
81+
if key > self.key! {
8282

8383

8484
if self.right != nil {

SwiftStructures.xcodeproj/xcuserdata/waynebishop.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,22 @@
22
<Bucket
33
type = "1"
44
version = "2.0">
5+
<Breakpoints>
6+
<BreakpointProxy
7+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
8+
<BreakpointContent
9+
shouldBeEnabled = "No"
10+
ignoreCount = "0"
11+
continueAfterRunningActions = "No"
12+
filePath = "SwiftTests/QuickTest.swift"
13+
timestampString = "494093734.019686"
14+
startingColumnNumber = "9223372036854775807"
15+
endingColumnNumber = "9223372036854775807"
16+
startingLineNumber = "45"
17+
endingLineNumber = "45"
18+
landmarkName = "testDecendingQSort()"
19+
landmarkType = "7">
20+
</BreakpointContent>
21+
</BreakpointProxy>
22+
</Breakpoints>
523
</Bucket>

SwiftTests/ClosureTest.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,6 @@ import XCTest
1212
@testable import SwiftStructures
1313

1414

15-
//MARK: custom operator
16-
17-
18-
/*
19-
notes: infix class operator to represent exponent operation
20-
single carat symbol reserved for XOR bit manipulation
21-
*/
22-
23-
24-
infix operator ^^ {}
25-
26-
func ^^(base: Int, power: Int) -> Int {
27-
28-
//rounded to nearest int
29-
let results: Double = round(pow(Double(base), Double(power)))
30-
return Int(results)
31-
}
32-
33-
34-
3515
class ClosureTest: XCTestCase {
3616

3717
var numberList: Array<Int>!

SwiftTests/LinkedTest.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ import XCTest
1414

1515
//struct for testing indicies
1616
struct keyIndex {
17-
private var key: Int
18-
private var index: Int
17+
public var key: Int
18+
public var index: Int
1919
}
2020

2121

2222

2323
class LinkedTest: XCTestCase {
24-
2524

2625
var numberList : Array<Int>!
2726

SwiftTests/QuickTest.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class QuickTest: XCTestCase, Sortable {
3434

3535

3636
//evaluate results
37-
buildQuickResults(with: results)
37+
processQuickResults(with: results)
3838
}
3939

4040

@@ -47,7 +47,7 @@ class QuickTest: XCTestCase, Sortable {
4747

4848

4949
//evaluate results
50-
buildQuickResults(with: results)
50+
processQuickResults(with: results)
5151

5252
}
5353

@@ -56,10 +56,9 @@ class QuickTest: XCTestCase, Sortable {
5656

5757
//MARK: Helper function
5858

59-
func buildQuickResults(with sequence: Array<Int>) {
60-
59+
func processQuickResults(with sequence: Array<Int>) {
6160
print("quick sort results: \(sequence)")
62-
XCTAssertTrue(isSorted(sequence), "test failed: sequence not sorted: " + String(sequence))
61+
XCTAssertTrue(isSorted(sequence), "test failed: sequence not sorted: " + String(describing: sequence))
6362
}
6463

6564
}

0 commit comments

Comments
 (0)