Skip to content

Commit 9ecfd88

Browse files
Revert "Migrate Stack to Swift 3"
This reverts commit 99c0072.
1 parent 99c0072 commit 9ecfd88

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

Stack/Stack.playground/Contents.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313

1414
public struct Stack<T> {
15-
fileprivate var array = [T]()
15+
private var array = [T]()
1616

1717
public var count: Int {
1818
return array.count
@@ -36,10 +36,10 @@ public struct Stack<T> {
3636
}
3737

3838
// Create a stack and put some elements on it already.
39-
var stackOfNames = Stack(array:["Carl", "Lisa", "Stephanie", "Jeff", "Wade"])
39+
var stackOfNames = Stack(array: ["Carl", "Lisa", "Stephanie", "Jeff", "Wade"])
4040

4141
// Add an element to the top of the stack.
42-
stackOfNames.push(element: "Mike")
42+
stackOfNames.push("Mike")
4343

4444
// The stack is now ["Carl", "Lisa", "Stephanie", "Jeff", "Wade", "Mike"]
4545
print(stackOfNames.array)

Stack/Stack.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Push and pop are O(1) operations.
55
*/
66
public struct Stack<T> {
7-
fileprivate var array = [T]()
7+
private var array = [T]()
88

99
public var isEmpty: Bool {
1010
return array.isEmpty
@@ -14,7 +14,7 @@ public struct Stack<T> {
1414
return array.count
1515
}
1616

17-
public mutating func push(_ element: T) {
17+
public mutating func push(element: T) {
1818
array.append(element)
1919
}
2020

@@ -27,10 +27,10 @@ public struct Stack<T> {
2727
}
2828
}
2929

30-
extension Stack: Sequence {
31-
public func makeIterator() -> AnyIterator<T> {
30+
extension Stack: SequenceType {
31+
public func generate() -> AnyGenerator<T> {
3232
var curr = self
33-
return AnyIterator {
33+
return AnyGenerator {
3434
_ -> T? in
3535
return curr.pop()
3636
}

Stack/Tests/Tests.xcodeproj/project.pbxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
TargetAttributes = {
8989
7B2BBC7F1C779D720067B71D = {
9090
CreatedOnToolsVersion = 7.2;
91-
LastSwiftMigration = 0800;
9291
};
9392
};
9493
};
@@ -221,7 +220,6 @@
221220
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
222221
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
223222
PRODUCT_NAME = "$(TARGET_NAME)";
224-
SWIFT_VERSION = 3.0;
225223
};
226224
name = Debug;
227225
};
@@ -233,7 +231,6 @@
233231
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
234232
PRODUCT_BUNDLE_IDENTIFIER = swift.algorithm.club.Tests;
235233
PRODUCT_NAME = "$(TARGET_NAME)";
236-
SWIFT_VERSION = 3.0;
237234
};
238235
name = Release;
239236
};

0 commit comments

Comments
 (0)