Find element in priority queue

Dec 23, 2021 at 12:05pm
I was just wondering...How do you find an element in a priority queue if you only know its value with a time complexity of O(1)? Not wanting to bother anyone... plz inform me if it's currently not possible.
Dec 23, 2021 at 12:11pm
You can't - at least not with std::priority_queue.
A queue lets you read or remove the first element.
Dec 23, 2021 at 12:19pm
Thanks. Guess I'll just need to find another way of doing it.
Dec 23, 2021 at 12:55pm
What's the context in which you want to do this?
Jan 27, 2022 at 6:55am
@seeplus
It's just a problem on our online judge which I wanted to solve, but got loony with the desperation. And I've solved it now, so it doesn't matter.
Topic archived. No new replies allowed.