Oracle神谕

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  284 随笔 :: 9 文章 :: 106 评论 :: 0 Trackbacks

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

posted on 2005-10-09 23:10 java世界畅谈 阅读(901) 评论(1)  编辑  收藏 所属分类: JAVA

评论

# re: PriorityQueue类API 翻译 2005-12-11 12:49 gramy
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来指定,这取决于使用哪种构造方法。优先级队列不允许null元素。依靠自然排序的优先级队列还不允许插入不可比较的对象(这样做可能导致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,element访问处于队列头的元素。  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: