How do I find the index of an item in a PriorityQueue? (Java)

java, priority-queue

Solution

There is an index priority queue written by Princeton.

algs4.cs.princeton.edu/24pq/IndexMinPQ.java.html

The key idea is to build two index maps between the item and its position in priority queue.

When you are updating the priority queue, you also need to update those two index maps.

Hope this solves your problem :-)

Problem

I was wondering if it was possible for me to find the index of a value in a PriorityQueue . Just to see what number it is "in line". Does anyone know?

Original source