javaperformancedata-structuresqueuepriority-queue

How is the java.util.priorityqueue implemented?


Does anyone know the implementation details for the standard java priority queue? heap? skiplist?


Solution

  • Javadoc says it's a heap: http://download.oracle.com/javase/6/docs/api/java/util/PriorityQueue.html

    First sentence, first paragraph:

    An unbounded priority queue based on a priority heap.


    I answered this a while ago— over 14 years ago.

    For stuff and giggles, I looked it up in the recently released Java 25, and it's still the same:

    https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/PriorityQueue.html