Created
November 5, 2014 23:28
-
-
Save alieseparker/6ba769990b223d54bf31 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
class Queue | |
attr_accessor :data, :next, :head, :tail, :size | |
def enqueue (data) | |
@data = data | |
if head.nil? | |
@head = @data | |
@tail = @data | |
@size = 1 | |
else | |
@tail.next = @data | |
@tail = @data | |
size += 1 | |
end | |
end | |
def dequeue | |
@head = @head.next | |
size -= 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment