title: Heapify in C++ STL?
body: <p>I am looking for a function that does Heapify but seems that there is no efficient function directly from C++ STL. </p>
  
  <p>A heapify function as defined in CLRS text book will take in an element location i, assuming the left and right sub trees of i are both heaps, and make the tree rooted at i become a heap, and complexity is log(n).</p>
  
  <p>Given a heap in [first, last), I would like to remove the first element, replace it with another element, and maintain the heap property. To achieve this, we only need to call heapify(first) once, traverse down the heap once, with log(n) complexity. </p>
  
  <p>STL has pop_heap and push_heap functions, and it could achieve the goal by first call pop_heap and push_heap, but pop_heap maintains heap property, and push_heap also maintains heap property, this infers two traverse in the heap. Even though the overall complexity is still log(n), it is not efficient. We do not need to maintain the heap property after removing the first element.</p>
  
  <p>Any good idea besides writing my own heapify function?</p>