Last active
October 26, 2022 17:46
-
-
Save dnovais/4e5d478b8a821647655b4d37aca78292 to your computer and use it in GitHub Desktop.
fila
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
class Queue | |
def initialize() | |
@queue = [] | |
end | |
def enqueue(value) | |
@queue.push(value) | |
end | |
def dequeue() | |
@queue.delete_at(0) | |
end | |
def display() | |
print @queue.to_s + "\n" | |
end | |
end | |
q = Queue.new() | |
q.enqueue(1) | |
q.enqueue(2) | |
q.enqueue(3) | |
q.enqueue(4) | |
q.display() | |
q.dequeue() | |
q.dequeue() | |
q.display() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment