Class: Vines::Services::PriorityQueue
- Inherits:
-
EM::Queue
- Object
- EM::Queue
- Vines::Services::PriorityQueue
- Defined in:
- lib/vines/services/priority_queue.rb
Overview
Behaves just like EM::Queue with the exception that items added to the queue are sorted and popped from the queue by their priority. The optional comparator block passed in the constructor determines element priority, with items sorted lowest to highest. If no block is provided, the elements’ natural ordering, via <=>, is used.
Defined Under Namespace
Classes: Heap
Instance Method Summary collapse
-
#initialize(&comparator) ⇒ PriorityQueue
constructor
A new instance of PriorityQueue.
Constructor Details
#initialize(&comparator) ⇒ PriorityQueue
Returns a new instance of PriorityQueue.
28 29 30 31 |
# File 'lib/vines/services/priority_queue.rb', line 28 def initialize(&comparator) super @items = Heap.new(&comparator) end |