2

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

fbl
  • 2,800
  • 3
  • 31
  • 39

2 Answers2

6

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.

clstrfsck
  • 14,465
  • 4
  • 45
  • 58
  • 1
    I was confused with priority heap a bit. if u look at the source code, it uses heapify method so balance the heap. so yeah it s the heap structure. it would be interesting to see a skiplist implementation. – DarthVader Oct 20 '11 at 02:34
  • 1
    Thanks. Clearly I skipped the first line. – fbl Oct 20 '11 at 02:38
1

Use the Source Luke: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/PriorityQueue.java

Alse see this awesomely helpful answer explaining how to use the horrible web front end for Mercurial: Is it possible to browse the source of OpenJDK online?

Marc Bacvanski
  • 1,318
  • 3
  • 15
  • 32
MK.
  • 32,464
  • 18
  • 70
  • 108