Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • top() should actually return elems.front(). Commented May 3, 2018 at 11:49
  • I was referencing the first snippet, not the second one. You effectively pop_back(), but the element you pop is actually the element that was at the front() of the vector before pop_heap because pop_heap first swap front() and back(), and then move the old back() at the correct position in the vector. Commented May 3, 2018 at 12:16