Class: UnifiedQueues::Single::Driver::RubyPriorityQueueDriver

Inherits:
UnifiedQueues::Single::Driver show all
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

#native

Instance Method Summary collapse

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.

Parameters:

  • +true+ (Boolean)

    if it’s, false otherwise

Returns:

  • (Boolean)


191
192
193
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 191

def empty?
    @native.empty?
end

#lengthInteger

Returns length of the queue. Note, it isn’t implemented in this implementation.

Returns:

  • (Integer)


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.

Parameters:

  • blocking (Boolean|Integer) (defaults to: false)

    true or timeout if it should block, false otherwise

Returns:

  • (Object)

    queued value



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.

Parameters:

  • value (Object)

    value for push

  • key (Object) (defaults to: value)

    key for priority queues



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.

Returns:

  • (:linear)


211
212
213
# File 'lib/unified-queues/single/driver/priority_queue.rb', line 211

def type
    :linear
end