Method: DS::BinaryHeap#initialize
- Defined in:
- lib/ds/trees/binary_heap.rb
#initialize(*args, &block) ⇒ BinaryHeap
Create new Heap from args. Given block sets the heap relation. Default heap relation is Max Heap.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ds/trees/binary_heap.rb', line 7 def initialize(*args, &block) if block_given? @relation = block else @relation = Proc.new{|parent,child| parent >= child} end @data = args.to_a heapify! end |