Class: QueueList

Inherits:
List show all
Defined in:
lib/queue_list.rb

Overview

QueueList class implementing a typical Queue data structure

Instance Method Summary collapse

Methods inherited from List

#push, #to_s

Constructor Details

#initialize(size = nil) ⇒ QueueList

Returns a new instance of QueueList.



7
8
9
# File 'lib/queue_list.rb', line 7

def initialize(size = nil)
  super(size)
end

Instance Method Details

#removeObject

This method implements remove functionality of a Queue (FIFO)

Example:

>> s = QueueList.new
>> s.push("else")
>> s.push("something")
>> s.remove()

> “else”



20
21
22
23
24
25
26
# File 'lib/queue_list.rb', line 20

def remove()
  if(@list.length == 0)
    raise CollectionError::QueueUnderflowError.new
  else
    @list.shift
  end
end