class AtCoder::PriorityQueue(T)
- AtCoder::PriorityQueue(T)
 - Reference
 - Object
 
Overview
Implements standard priority queue like std::priority_queue.
q = AtCoder::PriorityQueue(Int64).new
q << 1_i64
q << 3_i64
q << 2_i64
q.pop # => 3
q.pop # => 2
q.pop # => 1
  Included Modules
- Enumerable(T)
 
Defined in:
priority_queue.crConstructors
- 
        .new(enumerable : Enumerable(T))
        
          
Initializes queue with the elements in enumerable.
 - .new
 - 
        .new(enumerable : Enumerable(T), &block : T, T -> Bool)
        
          
Initializes queue with the elements in enumerable and the custom comperator.
 - 
        .new(&block : T, T -> Bool)
        
          
Initializes queue with the custom comperator.
 
Class Method Summary
- 
        .max(enumerable : Enumerable(T))
        
          
Create a new queue in ascending order of priority with the elements in enumerable.
 - 
        .max
        
          
Create a new queue in ascending order of priority.
 - 
        .min(enumerable : Enumerable(T))
        
          
Create a new queue in descending order of priority with the elements in enumerable.
 - 
        .min
        
          
Create a new queue in descending order of priority.
 
Instance Method Summary
- 
        #<<(v : T) : self
        
          
Alias of
#push - 
        #each(&)
        
          
Yields each item in the queue in comparator's order.
 - 
        #empty?(*args, **options)
        
          
Returns
trueif the queue is empty. - 
        #empty?(*args, **options, &)
        
          
Returns
trueif the queue is empty. - 
        #first(&)
        
          
Returns, but does not remove, the head of the queue.
 - #heap : Array(T)
 - 
        #pop
        
          
Pops value from the queue.
 - 
        #pop!
        
          
Pops value from the queue.
 - 
        #push(v : T) : self
        
          
Pushes value into the queue.
 - 
        #size(*args, **options)
        
          
Returns size of the queue.
 - 
        #size(*args, **options, &)
        
          
Returns size of the queue.
 
Constructor Detail
Initializes queue with the elements in enumerable and the custom comperator.
If the second argument b should be popped earlier than
the first argument a, return true. Else, return false.
q = AtCoder::PriorityQueue.new([1, 3, 2]) { |a, b| a >= b }
q.pop # => 1
q.pop # => 2
q.pop # => 3
        Initializes queue with the custom comperator.
If the second argument b should be popped earlier than
the first argument a, return true. Else, return false.
q = AtCoder::PriorityQueue(Int64).new { |a, b| a >= b }
q << 1_i64
q << 3_i64
q << 2_i64
q.pop # => 1
q.pop # => 2
q.pop # => 3
        Class Method Detail
Create a new queue in ascending order of priority with the elements in enumerable.
Create a new queue in descending order of priority with the elements in enumerable.
Instance Method Detail
Pushes value into the queue. This method returns self, so several calls can be chained.