Class: Raheui::Queue

Inherits:
Store
  • Object
show all
Defined in:
lib/raheui/queue.rb

Overview

Queue class for Aheui.

Instance Method Summary collapse

Methods inherited from Store

#initialize

Constructor Details

This class inherits a constructor from Raheui::Store

Instance Method Details

#popObject

Dequeue from the Queue.



10
11
12
# File 'lib/raheui/queue.rb', line 10

def pop
  @store.shift
end

#push_dupObject

Push the first element to Queue.



15
16
17
# File 'lib/raheui/queue.rb', line 15

def push_dup
  @store.unshift(@store.first) if size > 0
end

#swapObject

Swap the first two elements of Queue.



20
21
22
# File 'lib/raheui/queue.rb', line 20

def swap
  @store[0], @store[1] = @store[1], @store[0] if size > 1
end