by moosingin3space · 10y ago · 0 comments
I was just browsing the apidocs of peek_mut. Can you share a motivating use case? It wasn't immediately obvious to me.
It's basically replacing the former (never stabilized) `push_pop` and `replace`, which Python folks can relate to similar methods in their `heapq`, for instance. With separate `push` and `pop` calls, the heap must be sifted twice, but with `peek_mut` you can update the head in-place and sift only once.
Looks like it's to do something with the top data without the overhead of pop()+push()
Edit: ninja'd