Class: VCAP::PrioritySet
- Inherits:
-
PriorityQueueFIFO
- Object
- PriorityQueueFIFO
- VCAP::PrioritySet
- Defined in:
- lib/vcap/priority_queue.rb
Instance Attribute Summary
Attributes inherited from PriorityQueueFIFO
Instance Method Summary collapse
-
#initialize ⇒ PrioritySet
constructor
A new instance of PrioritySet.
- #insert(elem, priority = 0, key = nil) ⇒ Object
- #remove ⇒ Object
Methods inherited from PriorityQueueFIFO
Constructor Details
#initialize ⇒ PrioritySet
Returns a new instance of PrioritySet.
149 150 151 152 |
# File 'lib/vcap/priority_queue.rb', line 149 def initialize super @set = Set.new #the set is used to check for duplicates end |
Instance Method Details
#insert(elem, priority = 0, key = nil) ⇒ Object
154 155 156 |
# File 'lib/vcap/priority_queue.rb', line 154 def insert(elem, priority = 0, key = nil) super([elem,key], priority) if @set.add?(key || elem) end |
#remove ⇒ Object
158 159 160 161 162 |
# File 'lib/vcap/priority_queue.rb', line 158 def remove elem, key = super @set.delete(key || elem) elem end |