Skip to content
Snippets Groups Projects
Commit 52800707 authored by pjs's avatar pjs
Browse files

tweaks to priority queue implementation

parent f19addae
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ class PriorityQueue ...@@ -22,7 +22,7 @@ class PriorityQueue
min = @elements[1] min = @elements[1]
# and make sure the tree is ordered again # and make sure the tree is ordered again
bubble_down(1) bubble_down(1) unless empty?
min min
end end
...@@ -62,7 +62,7 @@ class PriorityQueue ...@@ -62,7 +62,7 @@ class PriorityQueue
child_index = (index * 2) child_index = (index * 2)
# stop if we reach the bottom of the tree # stop if we reach the bottom of the tree
if child_index > @elements.size - 1 if child_index >= @elements.size
@elements[index] = target @elements[index] = target
return return
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment