PriorityQueue类API 翻译

PriorityQueue类API 翻译

public class PriorityQueue<E>extends AbstractQueue<E>implements Serializable
An unbounded priority queue based on a priority heap. This queue orders elements according to an order specified at construction time, which is specified either according to their natural order (see Comparable), or according to a Comparator, 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).
  一个极大的优先队列基于一个优先堆栈。这个队列按照一个限定在构造时间顺序排列元素,这是也是按照它们的自然的顺序(查看Comparable)限定的,或者按照一个Comparator,依靠使用的构造子。一个优先队列不允许为空元素。一个优先队列依靠自然顺序也不允许插入一个非comparable对象(这样做会产生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.
  这个队列头是最小的元素伴随期望限定的排序。如果多个元素为最小的值约束,头是这些元素中的一个---约束是任意打断的。队列获得操作poll(推),remove(移除),peek 和在队列头部的元素

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.
  一个优先队列是极大的,但是拥有一个内部的容量调节数组的大小用来存储在队列中的元素。它总是至少和队列大小是是一样大小的。作为元素被加入一个优先队列,它的容量是自动增加的。增加策略的细节是没有指定的。

This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces. The Iterator provided in method iterator() is not guaranteed to traverse the elements of the PriorityQueue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray()).
  这个类和它的枚举实现所有可选的集合和枚举接口的方法。这个枚举支持iterator()方法是不保证在任何特定的顺序遍历PriorityQueue的元素。如果你需要顺序的遍历,考虑使用Array.sort(pq.toArray()).

Note that this implementation is not synchronized. Multiple threads should not access a PriorityQueue instance concurrently if any of the threads modifies the list structurally. Instead, use the thread-safe PriorityBlockingQueue class.
  注意这个实现不是不同步的。多个线程不应当并发访问一个PriorityQueue实例,如果线程在结构上线程任一个被修改。作为替换,使用线程安全的PriorityBlockingQueue类。

Implementation note: this implementation provides O(log(n)) time for the insertion methods (offer, poll, remove() and add) methods; linear time for the remove(Object) and contains(Object) methods; and constant time for the retrieval methods (peek, element, and size).

This class is a member of the Java Collections Framework.

 

Since:
1.5
See Also:
Serialized Form

你可能感兴趣的:(PriorityQueue类API 翻译)