let swap heap i j =
       let ielt = get heap i in
       let jelt = get heap j in
         Array.set heap.arr i jelt;
         Array.set heap.arr j ielt;
         (match ielt with (ipos,_,_) ->
            IntPairHash.replace heap.hash ipos j);
         match jelt with (jpos,_,_) ->
           IntPairHash.replace heap.hash jpos i