Class: DataStructures::PriorityQueue
- Inherits:
-
Object
- Object
- DataStructures::PriorityQueue
show all
- Extended by:
- Forwardable
- Defined in:
- lib/data_structures/priority_queue.rb
Defined Under Namespace
Classes: ObjectWithPriority
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ordering = DataStructures::BinaryHeap::HIGH_TO_LOW) ⇒ PriorityQueue
Returns a new instance of PriorityQueue.
Instance Method Details
#high_priority? ⇒ Boolean
15
16
17
|
# File 'lib/data_structures/priority_queue.rb', line 15
def high_priority?
@heap.max_heap?
end
|
#offer(object, priority) ⇒ Object
19
20
21
|
# File 'lib/data_structures/priority_queue.rb', line 19
def offer(object, priority)
@heap.insert(ObjectWithPriority.new(object, priority))
end
|
#poll ⇒ Object
23
24
25
|
# File 'lib/data_structures/priority_queue.rb', line 23
def poll
@heap.remove.object
end
|