Class: UnifiedQueues::Single::Driver::DepqDriver
- Inherits:
-
UnifiedQueues::Single::Driver
- Object
- UnifiedQueues::Single::Driver
- UnifiedQueues::Single::Driver::DepqDriver
- Defined in:
- lib/unified-queues/single/driver/depq.rb
Overview
Implicit heap queue driver. Uses the Depq
class from depq
gem for queueing. Priority is supported.
Instance Attribute Summary
Attributes inherited from UnifiedQueues::Single::Driver
Instance Method Summary collapse
-
#clear! ⇒ Object
Clears the queue.
-
#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
#evented?, #initialize, #linear?
Constructor Details
This class inherits a constructor from UnifiedQueues::Single::Driver
Instance Method Details
#clear! ⇒ Object
Clears the queue.
68 69 70 |
# File 'lib/unified-queues/single/driver/depq.rb', line 68 def clear! @native.clear end |
#empty? ⇒ Boolean
Indicates queue is empty.
60 61 62 |
# File 'lib/unified-queues/single/driver/depq.rb', line 60 def empty? @native.empty? end |
#length ⇒ Integer
Returns length of the queue.
77 78 79 |
# File 'lib/unified-queues/single/driver/depq.rb', line 77 def length @native.size end |
#pop(blocking = false) ⇒ Object
Pops value out of the queue. Note, value with minimal priority will be popped out. Blocking isn’ŧ supported.
51 52 53 |
# File 'lib/unified-queues/single/driver/depq.rb', line 51 def pop(blocking = false) @native.delete_min end |
#push(value, key = value) ⇒ Object
Pushes the value into the queue. Priority is supported.
39 40 41 |
# File 'lib/unified-queues/single/driver/depq.rb', line 39 def push(value, key = value) @native.insert(value, key) end |
#type ⇒ :linear
Returs type of the queue.
86 87 88 |
# File 'lib/unified-queues/single/driver/depq.rb', line 86 def type :linear end |