Last active
December 29, 2015 13:49
-
-
Save seanreed1111/7680150 to your computer and use it in GitHub Desktop.
implementation of class SimpleQueue
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
class SimpleQueue | |
def initialize | |
@queue = Array.new | |
end | |
#adds item to back of queue and returns the queue | |
def enqueue(item) | |
@queue.unshift(item) | |
end | |
#returns and removes item at the front of the queue | |
def dequeue | |
@queue.pop | |
end | |
def size | |
@queue.length | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment