Class: UnifiedQueues::Single::Driver::RubyPriorityQueueDriver
- Inherits:
-
UnifiedQueues::Single::Driver
- Object
- UnifiedQueues::Single::Driver
- UnifiedQueues::Single::Driver::RubyPriorityQueueDriver
- Defined in:
- lib/unified-queues/single/driver/priority_queue.rb
Overview
Ruby fibonacci heap priority queue driver. Uses the RubyPriorityQueue
class from PriorityQueue
gem. Priority is supported.
It isn’t implement equivalent of the #clear
method, so it falls backs to naive “popping” style clearing.
Instance Attribute Summary
Attributes inherited from UnifiedQueues::Single::Driver
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Indicates queue is empty.
-
#length ⇒ Integer
Returns length of the queue.
-
#pop(blocking = false) ⇒ Object
Pops value out of the queue.
-
#push(value, key = value) ⇒ Object
Pushes the value into the queue.
-
#type ⇒ :linear
Returs type of the queue.
Methods inherited from UnifiedQueues::Single::Driver
#clear!, #evented?, #initialize, #linear?
Constructor Details
This class inherits a constructor from UnifiedQueues::Single::Driver
Instance Method Details
#empty? ⇒ Boolean
Indicates queue is empty. Note, it isn’t implemented in this implementation.
191 192 193 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 191 def empty? @native.empty? end |
#length ⇒ Integer
Returns length of the queue. Note, it isn’t implemented in this implementation.
202 203 204 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 202 def length @native.length end |
#pop(blocking = false) ⇒ Object
Pops value out of the queue. Note, value with minimal priority will be popped out. Blocking isn’t supported.
180 181 182 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 180 def pop(blocking = false) @native.delete_min_return_key end |
#push(value, key = value) ⇒ Object
Pushes the value into the queue. Priority is supported.
168 169 170 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 168 def push(value, key = value) @native.push(value, key) end |
#type ⇒ :linear
Returs type of the queue.
211 212 213 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 211 def type :linear end |