let remove_min cmp ({heap=heap; indices=indices} as s) = let x = Vec.get heap 0 in Vec.set heap 0 (Vec.last heap); (*heap.last()*) Vec.set indices (Vec.get heap 0) 0; Vec.set indices x (-1); Vec.pop s.heap; if Vec.size s.heap > 1 then percolate_down cmp s 0; x