Heap.sol
implements heap for uint256
. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/Heap.sol
Is there an example of modifying it to work with custom struct? Is it sensible to do so?
I think the possible problem is that many operations from Array.sol
only supports uint256
. A hacky workaround I can think of is to decode the uint256
into 2 uint128
s. Maintain a MyStruct
array separately. And first uint128
stores the index of the array and the other uint128
stores the priority. Override the comparator functions to decode and read the 2nd uint128
. Could that work?