Method: Containers::MaxHeap#initialize

Defined in:
lib/containers/heap.rb

#initialize(ary = []) ⇒ MaxHeap

call-seq:

MaxHeap.new(ary) -> new_heap

Creates a new MaxHeap with an optional array parameter of items to insert into the heap. A MaxHeap is created by calling Heap.new { |x, y| (x <=> y) == 1 }, so this is a convenience class.

maxheap = MaxHeap.new([1, 2, 3, 4])
maxheap.pop #=> 4
maxheap.pop #=> 3


454
455
456
# File 'lib/containers/heap.rb', line 454

def initialize(ary=[])
  super(ary) { |x, y| (x <=> y) == 1 }
end