I have a 2D matrix of 2 rows and n columns.
The first row represents a distance (type : Float > 0).
The second row represents an ID (type : Integer > 0) corresponding to the distance above.
First question : it is possible to maintain a min-heap from DataStructures.jl with the first row (distances), while sorting the bottom row accordingly ; I basically need a sortperm function for min-Heaps. Does it exist ? I haven’t found it in the doc Heaps · DataStructures.jl.
Second question : I also need to be able to delete an entry in my heap based on the ID, while of course keeping the min-heap property. Any idea on how to do so ?
Initially, we could have such a matrix (distance in top row, ID in bottom row)
5 | 1 | 3
1 | 2 | 3
Sorting with respect to row1 could lead to :
1 | 5 | 3
2 | 1 | 3
Then deleting the entry with ID “2” would lead to : (note how min-heap property is eventually satisfied)
3 | 5
3 | 1
Hope this is clear !
Does anyone have any suggestions ? maybe I’m thinking the wrong way, there might be a workaround
Thank you very much in advance.