81 |
|
/** |
82 |
|
* Creates a <tt>PriorityQueue</tt> with the default initial capacity |
83 |
|
* (11) that orders its elements according to their natural |
84 |
< |
* ordering (using <tt>Comparable</tt>.) |
84 |
> |
* ordering (using <tt>Comparable</tt>). |
85 |
|
*/ |
86 |
|
public PriorityQueue() { |
87 |
|
this(DEFAULT_INITIAL_CAPACITY, null); |
90 |
|
/** |
91 |
|
* Creates a <tt>PriorityQueue</tt> with the specified initial capacity |
92 |
|
* that orders its elements according to their natural ordering |
93 |
< |
* (using <tt>Comparable</tt>.) |
93 |
> |
* (using <tt>Comparable</tt>). |
94 |
|
* |
95 |
|
* @param initialCapacity the initial capacity for this priority queue. |
96 |
|
* @throws IllegalArgumentException if <tt>initialCapacity</tt> is less |
159 |
|
* specified collection. The priority queue has an initial |
160 |
|
* capacity of 110% of the size of the specified collection or 1 |
161 |
|
* if the collection is empty. If the specified collection is an |
162 |
< |
* instance of a {@link SortedSet} or is another |
162 |
> |
* instance of a {@link java.util.SortedSet} or is another |
163 |
|
* <tt>PriorityQueue</tt>, the priority queue will be sorted |
164 |
|
* according to the same comparator, or according to its elements' |
165 |
|
* natural order if the collection is sorted according to its |
176 |
|
*/ |
177 |
|
public PriorityQueue(Collection<? extends E> c) { |
178 |
|
initializeArray(c); |
179 |
< |
if (c instanceof SortedSet<? extends E>) { |
179 |
> |
if (c instanceof SortedSet) { |
180 |
|
SortedSet<? extends E> s = (SortedSet<? extends E>) c; |
181 |
|
comparator = (Comparator<? super E>)s.comparator(); |
182 |
|
fillFromSorted(s); |
183 |
< |
} |
184 |
< |
else if (c instanceof PriorityQueue<? extends E>) { |
183 |
> |
} else if (c instanceof PriorityQueue) { |
184 |
|
PriorityQueue<? extends E> s = (PriorityQueue<? extends E>) c; |
185 |
|
comparator = (Comparator<? super E>)s.comparator(); |
186 |
|
fillFromSorted(s); |
187 |
< |
} |
189 |
< |
else { |
187 |
> |
} else { |
188 |
|
comparator = null; |
189 |
|
fillFromUnsorted(c); |
190 |
|
} |
529 |
|
/** |
530 |
|
* Returns the comparator used to order this collection, or <tt>null</tt> |
531 |
|
* if this collection is sorted according to its elements natural ordering |
532 |
< |
* (using <tt>Comparable</tt>.) |
532 |
> |
* (using <tt>Comparable</tt>). |
533 |
|
* |
534 |
|
* @return the comparator used to order this collection, or <tt>null</tt> |
535 |
|
* if this collection is sorted according to its elements natural ordering. |