Created
May 12, 2017 00:50
-
-
Save chriswebb09/2a0485b6286db0545d34a09fb6849e77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Stack<T> { | |
var isEmpty: Bool { | |
return items.isEmpty | |
} | |
var count: Int { | |
return items.count | |
} | |
var items: [T] = [] | |
mutating func push(_ item: T) { | |
items.append(item) | |
} | |
mutating func pop() -> T? { | |
return items.popLast() | |
} | |
func peek() -> T? { | |
return items.first | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment