1 |
|
/* |
2 |
|
* %W% %E% |
3 |
|
* |
4 |
< |
* Copyright 2003 Sun Microsystems, Inc. All rights reserved. |
4 |
> |
* Copyright 2004 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
6 |
|
*/ |
7 |
|
|
15 |
|
* {@link java.util.Comparator}, depending on which constructor is |
16 |
|
* used. A priority queue does not permit <tt>null</tt> elements. |
17 |
|
* A priority queue relying on natural ordering also does not |
18 |
< |
* permit insertion of non-comparable objects (doing so results |
18 |
> |
* permit insertion of non-comparable objects (doing so may result |
19 |
|
* in <tt>ClassCastException</tt>). |
20 |
|
* |
21 |
|
* <p>The <em>head</em> of this queue is the <em>least</em> element |
59 |
|
* @since 1.5 |
60 |
|
* @version %I%, %G% |
61 |
|
* @author Josh Bloch |
62 |
+ |
* @param <E> the type of elements held in this collection |
63 |
|
*/ |
64 |
|
public class PriorityQueue<E> extends AbstractQueue<E> |
65 |
< |
implements Queue<E>, java.io.Serializable { |
65 |
> |
implements java.io.Serializable { |
66 |
|
|
67 |
|
private static final long serialVersionUID = -7720805057305804111L; |
68 |
|
|
199 |
|
public PriorityQueue(Collection<? extends E> c) { |
200 |
|
initializeArray(c); |
201 |
|
if (c instanceof SortedSet) { |
202 |
< |
// @fixme double-cast workaround for compiler |
202 |
< |
SortedSet<? extends E> s = (SortedSet<? extends E>) (SortedSet)c; |
202 |
> |
SortedSet<? extends E> s = (SortedSet<? extends E>)c; |
203 |
|
comparator = (Comparator<? super E>)s.comparator(); |
204 |
|
fillFromSorted(s); |
205 |
|
} else if (c instanceof PriorityQueue) { |