Looking at the implementation of container/heap. The first element is always the smallest.
Now, how come the Pop() function is supposed to take the last element in the slice, because the container/heap code first swaps the first element with the last, before calling Pop() ?
Does this not seem like a bit counter intuitive, plus doing an extra swap operation ?
func Pop(h Interface) interface{} {
n := h.Len() - 1
h.Swap(0, n)
down(h, 0, n)
return h.Pop()
}
Is there a legitimate reason for this decision ?