31 |
|
* @author Josh Bloch |
32 |
|
*/ |
33 |
|
public class PriorityQueue<E> extends AbstractQueue<E> |
34 |
< |
implements Queue<E> { |
34 |
> |
implements Queue<E>, |
35 |
> |
java.io.Serializable { |
36 |
|
private static final int DEFAULT_INITIAL_CAPACITY = 11; |
37 |
|
|
38 |
|
/** |
128 |
|
initialCapacity = 1; |
129 |
|
queue = new E[initialCapacity + 1]; |
130 |
|
|
130 |
– |
/* Commented out to compile with generics compiler |
131 |
|
|
132 |
|
if (initialElements instanceof Sorted) { |
133 |
|
comparator = ((Sorted)initialElements).comparator(); |
134 |
|
for (Iterator<E> i = initialElements.iterator(); i.hasNext(); ) |
135 |
|
queue[++size] = i.next(); |
136 |
|
} else { |
137 |
– |
*/ |
138 |
– |
{ |
137 |
|
comparator = null; |
138 |
|
for (Iterator<E> i = initialElements.iterator(); i.hasNext(); ) |
139 |
|
add(i.next()); |
412 |
|
* @return the comparator associated with this priority queue, or |
413 |
|
* <tt>null</tt> if it uses its elements' natural ordering. |
414 |
|
*/ |
415 |
< |
Comparator comparator() { |
415 |
> |
public Comparator comparator() { |
416 |
|
return comparator; |
417 |
|
} |
418 |
|
|