Does java have an indexed minimum priority queue?

2019-03-26 20:54发布

I need it for an implementation of Dijkstra's algorithm, and I do have my own implementation but documenting my code would be easier with java's own classes.

2条回答
Lonely孤独者°
2楼-- · 2019-03-26 21:14

What do you mean 'indexed'? Priority queue doesn't support indexing, unless it won't be queue any more.

Java supports standard Priority Queue like C++ STL. It can be found in java.util namespace as PriorityQueue.

查看更多
闹够了就滚
3楼-- · 2019-03-26 21:35

No, Java standard library has no such data structure. I think most people use this: http://algs4.cs.princeton.edu/24pq/IndexMinPQ.java.html

查看更多
登录 后发表回答