Skip to content

Commit

Permalink
Xcode 8.0 / beta6 code updates..
Browse files Browse the repository at this point in the history
- minor changes to cast initializers, infix operators and inout parameter declaration.
- continued work quicksort algorithm unit tests.
  • Loading branch information
waynewbishop committed Aug 31, 2016
1 parent 676b86f commit 3620b28
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
10 changes: 4 additions & 6 deletions Source/Extensions/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ extension Array where Element: Comparable {
//evaluate chosen number..
let n = self[mid]

print(String(n) + " value attempted..")

print(String(describing: n) + "value attempted..")


if n > key {
Expand Down Expand Up @@ -256,13 +257,10 @@ extension Array where Element: Comparable {

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



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


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



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

var wallIndex: Int = startIndex
Expand Down
4 changes: 2 additions & 2 deletions Source/Factories/Graph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public class SwiftGraph {


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


//establish a new queue
Expand Down Expand Up @@ -340,7 +340,7 @@ public class SwiftGraph {
*/

//invoke formula
formula(node: &vitem)
formula(&vitem)


} //end while
Expand Down
4 changes: 2 additions & 2 deletions Source/Factories/HashList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ class HashList<T> {

//string type
case is String:
return String(element)
return String(describing: element)



//int type
case is Int:
let stringElement = String(element)
let stringElement = String(describing: element)
return stringElement


Expand Down
4 changes: 2 additions & 2 deletions Source/Structures/AVLTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class AVLTree<T: Comparable> {


//check left side
if key < self.key {
if key < self.key! {


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


//check right side
if key > self.key {
if key > self.key! {


if self.right != nil {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,22 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftTests/QuickTest.swift"
timestampString = "494093734.019686"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "45"
endingLineNumber = "45"
landmarkName = "testDecendingQSort()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
20 changes: 0 additions & 20 deletions SwiftTests/ClosureTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@ import XCTest
@testable import SwiftStructures


//MARK: custom operator


/*
notes: infix class operator to represent exponent operation
single carat symbol reserved for XOR bit manipulation
*/


infix operator ^^ {}

func ^^(base: Int, power: Int) -> Int {

//rounded to nearest int
let results: Double = round(pow(Double(base), Double(power)))
return Int(results)
}



class ClosureTest: XCTestCase {

var numberList: Array<Int>!
Expand Down
5 changes: 2 additions & 3 deletions SwiftTests/LinkedTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import XCTest

//struct for testing indicies
struct keyIndex {
private var key: Int
private var index: Int
public var key: Int
public var index: Int
}



class LinkedTest: XCTestCase {


var numberList : Array<Int>!

Expand Down
9 changes: 4 additions & 5 deletions SwiftTests/QuickTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QuickTest: XCTestCase, Sortable {


//evaluate results
buildQuickResults(with: results)
processQuickResults(with: results)
}


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


//evaluate results
buildQuickResults(with: results)
processQuickResults(with: results)

}

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

//MARK: Helper function

func buildQuickResults(with sequence: Array<Int>) {

func processQuickResults(with sequence: Array<Int>) {
print("quick sort results: \(sequence)")
XCTAssertTrue(isSorted(sequence), "test failed: sequence not sorted: " + String(sequence))
XCTAssertTrue(isSorted(sequence), "test failed: sequence not sorted: " + String(describing: sequence))
}

}

0 comments on commit 3620b28

Please sign in to comment.