Class: QueueList
- Inherits:
-
List
- Object
- Collection
- List
- QueueList
- Defined in:
- lib/queue_list.rb
Overview
QueueList class implementing a typical Queue data structure
Instance Method Summary collapse
-
#initialize(size = nil) ⇒ QueueList
constructor
A new instance of QueueList.
-
#remove ⇒ Object
This method implements remove functionality of a Queue (FIFO).
Methods inherited from List
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
#remove ⇒ Object
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 |