Class: Dynflow::Utils::PriorityQueue
- Inherits:
 - 
      Object
      
        
- Object
 - Dynflow::Utils::PriorityQueue
 
 
- Defined in:
 - lib/dynflow/utils/priority_queue.rb
 
Overview
Heavily inspired by rubyworks/pqueue
Instance Method Summary collapse
- 
  
    
      #initialize(&block)  ⇒ PriorityQueue 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
:yields: a, b.
 - #pop ⇒ Object
 - #push(element) ⇒ Object
 - #size ⇒ Object
 - #to_a ⇒ Object
 - #top ⇒ Object
 
Constructor Details
#initialize(&block) ⇒ PriorityQueue
:yields: a, b
      7 8 9 10  | 
    
      # File 'lib/dynflow/utils/priority_queue.rb', line 7 def initialize(&block) # :yields: a, b @backing_store = [] @comparator = block || :<=>.to_proc end  | 
  
Instance Method Details
#pop ⇒ Object
      25 26 27  | 
    
      # File 'lib/dynflow/utils/priority_queue.rb', line 25 def pop @backing_store.pop end  | 
  
#push(element) ⇒ Object
      20 21 22 23  | 
    
      # File 'lib/dynflow/utils/priority_queue.rb', line 20 def push(element) @backing_store << element reposition_element(@backing_store.size - 1) end  | 
  
#size ⇒ Object
      12 13 14  | 
    
      # File 'lib/dynflow/utils/priority_queue.rb', line 12 def size @backing_store.size end  | 
  
#to_a ⇒ Object
      29 30 31  | 
    
      # File 'lib/dynflow/utils/priority_queue.rb', line 29 def to_a @backing_store end  | 
  
#top ⇒ Object
      16 17 18  | 
    
      # File 'lib/dynflow/utils/priority_queue.rb', line 16 def top @backing_store.last end  |