Class: DeadEnd::PriorityEngulfQueue

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializePriorityEngulfQueue

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/dead_end/priority_engulf_queue.rb', line 17

def empty?
  @queue.empty?
end

#lengthObject



21
22
23
# File 'lib/dead_end/priority_engulf_queue.rb', line 21

def length
  @queue.length
end

#peekObject



25
26
27
# File 'lib/dead_end/priority_engulf_queue.rb', line 25

def peek
  @queue.peek
end

#popObject



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_aObject



13
14
15
# File 'lib/dead_end/priority_engulf_queue.rb', line 13

def to_a
  @queue.to_a
end