class UnifiedQueues::Single::Driver::CPriorityQueueDriver
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.
Public Instance Methods
empty?()
click to toggle source
Indicates queue is empty. @param [Boolean] true
if it's, false
otherwise
# File lib/unified-queues/single/driver/priority_queue.rb, line 65 def empty? @native.empty? end
length()
click to toggle source
Returns length of the queue.
@return [Integer]
# File lib/unified-queues/single/driver/priority_queue.rb, line 75 def length @native.length 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/priority_queue.rb, line 56 def pop(blocking = false) @native.delete_min_return_key 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/priority_queue.rb, line 43 def push(value, key = value) key = (key.kind_of? Integer) ? key : 0 @native.push(value, key) end
type()
click to toggle source
Returs type of the queue. @return [:linear]
# File lib/unified-queues/single/driver/priority_queue.rb, line 84 def type :linear end