PriorityQueue

优先级队列

1、无限的

2、不允许null

3、在构造queue或者元素需要实现comparable接口

4、数据结构是堆,而且是极小堆。存储是数组。

An unbounded priority queue based on a priority heap. The elements of the priority queue are ordered according to their natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used. A priority queue does not permit null elements. A priority queue relying on natural ordering also does not permit insertion of non-comparable objects (doing so may result in ClassCastException).

Implementation note: this implementation provides O(log(n)) time for the enqueing and dequeing methods (offerpollremove() and add); linear time for the remove(Object) and contains(Object) methods; and constant time for the retrieval methods (peekelement, and size).

"a".compareTo("b")=-1;

"a".compareTo("ab")=-1;

原文地址:https://www.cnblogs.com/YDDMAX/p/5644019.html