Method: CompSci::Heap#pop
- Defined in:
- lib/compsci/heap.rb
#pop ⇒ Object
-
remove from the front of the array
-
move last node to root
-
sift_down – O(log n) on heap size
48 49 50 51 52 53 54 |
# File 'lib/compsci/heap.rb', line 48 def pop node = @array.shift replacement = @array.pop @array.unshift replacement if replacement self.sift_down(0) node end |