2

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

fbl
  • 2,840
  • 3
  • 33
  • 41

2 Answers2

5

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,715
  • 4
  • 44
  • 59
  • 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,458
  • 4
  • 17
  • 33
MK.
  • 33,605
  • 18
  • 74
  • 111