Skip to content

Instantly share code, notes, and snippets.

@alieseparker
Created November 5, 2014 23:28
Show Gist options
  • Save alieseparker/6ba769990b223d54bf31 to your computer and use it in GitHub Desktop.
Save alieseparker/6ba769990b223d54bf31 to your computer and use it in GitHub Desktop.
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