Class: DeadEnd::PriorityEngulfQueue
- Inherits:
-
Object
- Object
- DeadEnd::PriorityEngulfQueue
- Defined in:
- lib/dead_end/priority_engulf_queue.rb
Overview
Keeps track of what elements are in the queue in priority and also ensures that when one element engulfs/covers/eats another that the larger element evicts the smaller element
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize ⇒ PriorityEngulfQueue
constructor
A new instance of PriorityEngulfQueue.
- #length ⇒ Object
- #peek ⇒ Object
- #pop ⇒ Object
- #push(block) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ PriorityEngulfQueue
Returns a new instance of PriorityEngulfQueue.
9 10 11 |
# File 'lib/dead_end/priority_engulf_queue.rb', line 9 def initialize @queue = PriorityQueue.new end |
Instance Method Details
#empty? ⇒ Boolean
17 18 19 |
# File 'lib/dead_end/priority_engulf_queue.rb', line 17 def empty? @queue.empty? end |
#length ⇒ Object
21 22 23 |
# File 'lib/dead_end/priority_engulf_queue.rb', line 21 def length @queue.length end |
#peek ⇒ Object
25 26 27 |
# File 'lib/dead_end/priority_engulf_queue.rb', line 25 def peek @queue.peek end |
#pop ⇒ Object
29 30 31 |
# File 'lib/dead_end/priority_engulf_queue.rb', line 29 def pop @queue.pop end |
#push(block) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/dead_end/priority_engulf_queue.rb', line 33 def push(block) prune_engulf(block) @queue << block flush_deleted self end |
#to_a ⇒ Object
13 14 15 |
# File 'lib/dead_end/priority_engulf_queue.rb', line 13 def to_a @queue.to_a end |