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).
    基于优先堆的一个无界优先队列。优先级队列的元素按照它们的自然顺序,或者通过在队列构造期间提供的比较器来排列,这取决于哪个构造器被使用。一个优先队列不允许空值。基于自然顺序的优先队列不允许插入不可比较的对象(这么做可能会导致ClassCastException

    The head of this queue is the least element with respect to the specified ordering. If multiple elements are tied for least value, the head is one of those elements — ties are broken arbitrarily. The queue retrieval operations poll, remove, peek, and element access the element at the head of the queue.
    这个队列的头是最小的元素。
    A priority queue is unbounded, but has an internal capacity governing the size of an array used to store the elements on the queue. It is always at least as large as the queue size. As elements are added to a priority queue, its capacity grows automatically. The details of the growth policy are not specified.
    优先队列是没有限制的,但是它有一个内部容量来控制用于存储队列中的元素的数组的大小。它总是至少和队列大小一样大。随着元素被添加到优先队列,其容量会自动增长。没有指定增长策略的细节。

    Note that this implementation is not synchronized
    **
    Implementation note: this implementation provides O(log(n)) time for the enqueuing and dequeuing methods (offer, poll, remove() and add); linear time for the remove(Object) and contains(Object) methods; and constant time for the retrieval methods (peek, element, and size).
    提示:这种实现为入队和出队方法提供O(log(n))的时间复杂度;remove和contains方法是线性的时间复杂度;对于(peek,element,size)这些检索方法是常量时间

    PriorityQueue通过二叉小根堆实现