Method: Heap#pop

Defined in:
lib/mega/heap.rb

#popObject

Extract the first element from the heap. Will raise EmptyHeapException if there are no (more) elements on the heap.

Raises:



140
141
142
143
144
145
146
# File 'lib/mega/heap.rb', line 140

def pop
  raise EmptyHeapException if @heap_size < 1
  @heap_size -= 1
  top, @array[0] = @array[0], @array[@heap_size]
  heapify(0)
  top
end