Created
April 5, 2016 06:40
-
-
Save wokalski/4cdfcf9272c21d60916fc4e4146100c7 to your computer and use it in GitHub Desktop.
This file contains 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 Queue<T> { | |
private var elements: [T] = [] | |
mutating func enqueue(element: T) { | |
elements.append(element) | |
} | |
mutating func enqueue(elements: [T]) { | |
elements.forEach {self.elements.append($0)} | |
} | |
mutating func dequeue() -> T { | |
return elements.removeFirst() | |
} | |
func isEmpty() -> Bool { | |
return elements.count == 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment