let remove heap pos =
try
let idx = IntPairHash.find heap.hash pos in
swap heap idx (heap.last-1);
heap.last <- heap.last-1;
ignore (bubbleup heap idx);
ignore (bubbledown heap idx);
IntPairHash.remove heap.hash pos
with | _ -> ()