You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple test proves that this functionality is broken. Add 10 numbers 0->9 and the heap will look like this:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Change heap[9] to 0 making the heap look like this:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 0]
Call heap.Fix(9) and the heap looks like this:
[0, 0, 2, 3, 1, 5, 6, 7, 8, 4]
The text was updated successfully, but these errors were encountered:
"Heap ordering" doesn't mean the slice (or other underlying heap.Interface implementation) is totally ordered. It means that it follows the heap invariant:
!h.Less(j, i) for 0 <= i < h.Len() and 2*i+1 <= j <= 2*i+2 and j < h.Len()
Documentation( http://golang.org/pkg/container/heap/#Fix ) states:
"Fix re-establishes the heap ordering after the element at index i has changed its value."
A simple test proves that this functionality is broken. Add 10 numbers 0->9 and the heap will look like this:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Change heap[9] to 0 making the heap look like this:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 0]
Call heap.Fix(9) and the heap looks like this:
[0, 0, 2, 3, 1, 5, 6, 7, 8, 4]
The text was updated successfully, but these errors were encountered: