class UnifiedQueues::Single::Driver::DepqDriver
Implicit heap queue driver. Uses the Depq
class from depq
gem for queueing. Priority is supported.
Public Instance Methods
clear!()
click to toggle source
Clears the queue.
# File lib/unified-queues/single/driver/depq.rb, line 68 def clear! @native.clear end
empty?()
click to toggle source
Indicates queue is empty. @param [Boolean] true
if it's, false
otherwise
# File lib/unified-queues/single/driver/depq.rb, line 60 def empty? @native.empty? end
length()
click to toggle source
Returns length of the queue. @return [Integer]
# File lib/unified-queues/single/driver/depq.rb, line 77 def length @native.size end
pop(blocking = false)
click to toggle source
Pops value out of the queue. Note, value with minimal priority will be popped out. Blocking isn'ลง supported.
@param [Boolean|Integer] blocking true
or timeout if it should block, false
otherwise @return [Object] queued value
# File lib/unified-queues/single/driver/depq.rb, line 51 def pop(blocking = false) @native.delete_min end
push(value, key = value)
click to toggle source
Pushes the value into the queue. Priority is supported.
@param [Object] value value for push @param [Object] key key for priority queues
# File lib/unified-queues/single/driver/depq.rb, line 39 def push(value, key = value) @native.insert(value, key) end
type()
click to toggle source
Returs type of the queue. @return [:linear]
# File lib/unified-queues/single/driver/depq.rb, line 86 def type :linear end