Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Created May 12, 2017 00:50
Show Gist options
  • Save chriswebb09/2a0485b6286db0545d34a09fb6849e77 to your computer and use it in GitHub Desktop.
Save chriswebb09/2a0485b6286db0545d34a09fb6849e77 to your computer and use it in GitHub Desktop.
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