class Algorithmable::DataStructs::Queue

Public Class Methods

new(collection = []) click to toggle source
# File lib/algorithmable/data_structs/queue.rb, line 9
def initialize(collection = [])
  @imp = Deque.new collection
end

Public Instance Methods

dequeue() click to toggle source
# File lib/algorithmable/data_structs/queue.rb, line 23
def dequeue
  @imp.pop_front
end
enqueue(item) click to toggle source
# File lib/algorithmable/data_structs/queue.rb, line 19
def enqueue(item)
  @imp.push_back(item)
end
peek() click to toggle source
# File lib/algorithmable/data_structs/queue.rb, line 13
def peek
  peek_value = @imp.peek_front
  fail NoSuchElementError unless peek_value
  peek_value
end
to_s() click to toggle source
# File lib/algorithmable/data_structs/queue.rb, line 27
def to_s
  to_a.join('->')
end