function replace(compare, heap, item) {
  if (heap.length === 0)
    throw new Error('mnemonist/heap.replace: cannot pop an empty heap.');

  var popped = heap[0];
  heap[0] = item;
  siftUp(compare, heap, 0);

  return popped;
}
Function used to pop the heap then push a new value into it, thus "replacing"
it.

@param  {function} compare - Comparison function.
@param  {array}    heap    - Array storing the heap's data.
@param  {any}      item    - The item to push.
@return {any}