I have a set of objects with two kinds of priorities. I can create two PriorityQueues ordered by each of them. The problem is that when I dequeue element from one of them it will obviously not disappear from the other one.
Is it possible to create 2 queues "in sync", so that when element is removed from one then it will be removed from the other?
This warrants a special kind of a data structure. The standard "binary heap under the hood" priority queue available in the standard library cannot do the trick, because it doesn't know "where" in the other binary heap the required element is.
A similar problem happens when you try to implement Dijkstra's algorithm or A*. The trick that works there is to use 2 ordered trees as if they were queues - you can pop the first element, and you can then search for it in the other tree.