Class: UnifiedQueues::Single::Driver::CPriorityQueueDriver
- Inherits:
-
UnifiedQueues::Single::Driver
- Object
- UnifiedQueues::Single::Driver
- UnifiedQueues::Single::Driver::CPriorityQueueDriver
- Defined in:
- lib/unified-queues/single/driver/priority_queue.rb
Overview
Fibonacci heap queue driver. Uses the CPriorityQueue
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.
65 66 67 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 65 def empty? @native.empty? end |
#length ⇒ Integer
Returns length of the queue.
75 76 77 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 75 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’ŧ supported.
56 57 58 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 56 def pop(blocking = false) @native.delete_min_return_key end |
#push(value, key = value) ⇒ Object
Pushes the value into the queue. Priority is supported.
43 44 45 46 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 43 def push(value, key = value) key = (key.kind_of? Integer) ? key : 0 @native.push(value, key) end |
#type ⇒ :linear
Returs type of the queue.
84 85 86 |
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 84 def type :linear end |