Skip to content

Commit

Permalink
Merge branch 'master' into MinimumEditDistance-Swift4
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinlauKL committed Aug 18, 2017
2 parents 99d955a + 23d2c4f commit 628acf4
Show file tree
Hide file tree
Showing 113 changed files with 1,801 additions and 876 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.3
osx_image: xcode9
# sudo: false

install:
Expand Down
5 changes: 5 additions & 0 deletions AVL Tree/AVLTree.playground/Contents.swift
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

let tree = AVLTree<Int, String>()

tree.insert(key: 5, payload: "five")
Expand Down
8 changes: 6 additions & 2 deletions AVL Tree/Tests/AVLTreeTests.swift
Expand Up @@ -7,11 +7,15 @@
//

import XCTest

class AVLTreeTests: XCTestCase {

var tree: AVLTree<Int, String>?

func testSwift4() {
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
}
override func setUp() {
super.setUp()

Expand Down
6 changes: 4 additions & 2 deletions AVL Tree/Tests/Tests.xcodeproj/project.pbxproj
Expand Up @@ -180,6 +180,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -219,6 +220,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -230,7 +232,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -242,7 +244,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
9 changes: 7 additions & 2 deletions AVL Tree/Tests/TreeNodeTests.swift
Expand Up @@ -9,11 +9,16 @@
import XCTest

class TreeNodeTests: XCTestCase {

var root: TreeNode<String, String>?
var left: TreeNode<String, String>?
var right: TreeNode<String, String>?

func testSwift4() {
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
}
override func setUp() {
super.setUp()

Expand Down
5 changes: 5 additions & 0 deletions All-Pairs Shortest Paths/APSP/APSP.playground/Contents.swift
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

import Graph
import APSP

Expand Down
Expand Up @@ -3,12 +3,12 @@
version = "3.0">
<TimelineItems>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=888&amp;EndingColumnNumber=44&amp;EndingLineNumber=29&amp;StartingColumnNumber=3&amp;StartingLineNumber=28&amp;Timestamp=486844329.035763"
documentLocation = "file:///Users/kachen/src/swift-algorithm-club/All-Pairs%20Shortest%20Paths/APSP/APSP.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=971&amp;EndingColumnNumber=68&amp;EndingLineNumber=34&amp;StartingColumnNumber=68&amp;StartingLineNumber=34&amp;Timestamp=523221730.015692"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=4&amp;CharacterRangeLoc=825&amp;EndingColumnNumber=9&amp;EndingLineNumber=29&amp;StartingColumnNumber=5&amp;StartingLineNumber=29&amp;Timestamp=486844329.036018"
documentLocation = "file:///Users/kachen/src/swift-algorithm-club/All-Pairs%20Shortest%20Paths/APSP/APSP.playground#CharacterRangeLen=4&amp;CharacterRangeLoc=908&amp;EndingColumnNumber=9&amp;EndingLineNumber=34&amp;StartingColumnNumber=5&amp;StartingLineNumber=34&amp;Timestamp=523221730.015887"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
Expand Down
4 changes: 2 additions & 2 deletions All-Pairs Shortest Paths/APSP/APSP.xcodeproj/project.pbxproj
Expand Up @@ -388,7 +388,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.swift-algorithm-club.APSPTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -400,7 +400,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.swift-algorithm-club.APSPTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
7 changes: 7 additions & 0 deletions All-Pairs Shortest Paths/APSP/APSPTests/APSPTests.swift
Expand Up @@ -20,6 +20,13 @@ struct TestCase<T> where T: Hashable {

class APSPTests: XCTestCase {

func testSwift4() {
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
}

/**
See Figure 25.1 of “Introduction to Algorithms” by Cormen et al, 3rd ed., pg 690
*/
Expand Down
5 changes: 5 additions & 0 deletions Array2D/Array2D.playground/Contents.swift
@@ -1,3 +1,8 @@
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

/*
Two-dimensional array with a fixed number of rows and columns.
This is mostly handy for games that are played on a grid, such as chess.
Expand Down
7 changes: 6 additions & 1 deletion B-Tree/BTree.playground/Contents.swift
Expand Up @@ -2,6 +2,11 @@

import Foundation

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

let bTree = BTree<Int, Int>(order: 1)!

bTree.insert(1, for: 1)
Expand All @@ -15,7 +20,7 @@ bTree[3]
bTree.remove(2)

bTree.traverseKeysInOrder { key in
print(key)
print(key)
}

bTree.numberOfKeys
Expand Down
6 changes: 4 additions & 2 deletions B-Tree/Tests/Tests.xcodeproj/project.pbxproj
Expand Up @@ -179,6 +179,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -219,6 +220,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -232,7 +234,7 @@
PRODUCT_BUNDLE_IDENTIFIER = viktorsimko.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -245,7 +247,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = viktorsimko.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
87 changes: 46 additions & 41 deletions B-Tree/Tests/Tests/BTreeNodeTests.swift
Expand Up @@ -9,45 +9,50 @@
import XCTest

class BTreeNodeTests: XCTestCase {

let owner = BTree<Int, Int>(order: 2)!
var root: BTreeNode<Int, Int>!
var leftChild: BTreeNode<Int, Int>!
var rightChild: BTreeNode<Int, Int>!

override func setUp() {
super.setUp()

root = BTreeNode(owner: owner)
leftChild = BTreeNode(owner: owner)
rightChild = BTreeNode(owner: owner)

root.insert(1, for: 1)
root.children = [leftChild, rightChild]
}

func testIsLeafRoot() {
XCTAssertFalse(root.isLeaf)
}

func testIsLeafLeaf() {
XCTAssertTrue(leftChild.isLeaf)
XCTAssertTrue(rightChild.isLeaf)
}

func testOwner() {
XCTAssert(root.owner === owner)
XCTAssert(leftChild.owner === owner)
XCTAssert(rightChild.owner === owner)
}

func testNumberOfKeys() {
XCTAssertEqual(root.numberOfKeys, 1)
XCTAssertEqual(leftChild.numberOfKeys, 0)
XCTAssertEqual(rightChild.numberOfKeys, 0)
}

func testChildren() {
XCTAssertEqual(root.children!.count, 2)
}

let owner = BTree<Int, Int>(order: 2)!
var root: BTreeNode<Int, Int>!
var leftChild: BTreeNode<Int, Int>!
var rightChild: BTreeNode<Int, Int>!
func testSwift4() {
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
}
override func setUp() {
super.setUp()

root = BTreeNode(owner: owner)
leftChild = BTreeNode(owner: owner)
rightChild = BTreeNode(owner: owner)

root.insert(1, for: 1)
root.children = [leftChild, rightChild]
}

func testIsLeafRoot() {
XCTAssertFalse(root.isLeaf)
}

func testIsLeafLeaf() {
XCTAssertTrue(leftChild.isLeaf)
XCTAssertTrue(rightChild.isLeaf)
}

func testOwner() {
XCTAssert(root.owner === owner)
XCTAssert(leftChild.owner === owner)
XCTAssert(rightChild.owner === owner)
}

func testNumberOfKeys() {
XCTAssertEqual(root.numberOfKeys, 1)
XCTAssertEqual(leftChild.numberOfKeys, 0)
XCTAssertEqual(rightChild.numberOfKeys, 0)
}

func testChildren() {
XCTAssertEqual(root.children!.count, 2)
}
}
7 changes: 7 additions & 0 deletions B-Tree/Tests/Tests/BTreeTests.swift
Expand Up @@ -11,6 +11,13 @@ import XCTest
class BTreeTests: XCTestCase {
var bTree: BTree<Int, Int>!

func testSwift4() {
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
}

override func setUp() {
super.setUp()
bTree = BTree<Int, Int>(order: 3)!
Expand Down
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

let tree = BinarySearchTree<Int>(value: 7)
tree.insert(value: 2)
tree.insert(value: 5)
Expand Down

This file was deleted.

@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

// Each time you insert something, you get back a completely new tree.
var tree = BinarySearchTree.leaf(7)
tree = tree.insert(newValue: 2)
Expand Down

This file was deleted.

5 changes: 5 additions & 0 deletions Binary Search/BinarySearch.playground/Contents.swift
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

// An unsorted array of numbers
let numbers = [11, 59, 3, 2, 53, 17, 31, 7, 19, 67, 47, 13, 37, 61, 29, 43, 5, 41, 23]

Expand Down
6 changes: 0 additions & 6 deletions Binary Search/BinarySearch.playground/timeline.xctimeline

This file was deleted.

5 changes: 5 additions & 0 deletions Binary Tree/BinaryTree.playground/Contents.swift
@@ -1,5 +1,10 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

public indirect enum BinaryTree<T> {
case node(BinaryTree<T>, T, BinaryTree<T>)
case empty
Expand Down
5 changes: 4 additions & 1 deletion Bloom Filter/BloomFilter.playground/Contents.swift
@@ -1,5 +1,8 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
public class BloomFilter<T> {
fileprivate var array: [Bool]
private var hashFunctions: [(T) -> Int]
Expand Down

0 comments on commit 628acf4

Please sign in to comment.