let insert heap elt =
(if heap.last >= Array.length heap.arr
then (let arr' = heap.arr in
heap.arr <- Array.make (heap.last*2) elt;
Array.blit arr' 0 heap.arr 0 heap.last));
Array.set heap.arr heap.last elt;
(match elt with (pos,_,_) ->
IntPairHash.replace heap.hash pos heap.last);
heap.last <- heap.last+1;
bubbleup heap (heap.last-1)