priority_queue_cxx icon indicating copy to clipboard operation
priority_queue_cxx copied to clipboard

Question: Method to set the priority of a queue element without having to pop and push with new priority again.

Open surenderk2009 opened this issue 1 year ago • 1 comments

So far the only way I see is popping the element and pushing it back again with new priority. This might be expensive if element is not the top. Is there a way to achieve this at the moment or if not, it'll be a good feature to have as priority change is very common for a queue element. So the trade off of not having this feature is again ending up making it expensive for the systems like mine where I absolutely need to update the priority of elements frequently. It'll be really useful feature for me or in fact for most of the users if it can be added.

Thanks.

surenderk2009 avatar Jan 31 '24 18:01 surenderk2009

Hi @surenderk2009, I am very aware of the issue, but as I mention in a a note of the README:

It is worth mentioning that, due to how priority queue are implemented by the C++ standard library, this implementation can't efficiently support priority changes. In any case, to support this feature would require important changes in the current API

To the best of my understanding, to accomodate for this change I would have to totally change the implementation and forego using the standard c++ queuing library. I have not the time right now. If you want to contribute to it, I can help you out with the development though.

boborbt avatar Jan 31 '24 18:01 boborbt

Yes. I saw that. I was wondering how much effort would it be to implement it but I understand now. For now, I was able to get through my situation using some other way. But I'll look into this and see if I can find some time to contribute. I'll close the issue for now and get in touch with you when I can collaborate with you on this. Thanks.

surenderk2009 avatar Feb 19 '24 15:02 surenderk2009