60 |
|
* the priority queue in any particular order. If you need ordered |
61 |
|
* traversal, consider using {@code Arrays.sort(pq.toArray())}. |
62 |
|
* |
63 |
< |
* <p> <strong>Note that this implementation is not synchronized.</strong> |
63 |
> |
* <p><strong>Note that this implementation is not synchronized.</strong> |
64 |
|
* Multiple threads should not access a {@code PriorityQueue} |
65 |
|
* instance concurrently if any of the threads modifies the queue. |
66 |
|
* Instead, use the thread-safe {@link |
451 |
|
* this queue |
452 |
|
* @throws NullPointerException if the specified array is null |
453 |
|
*/ |
454 |
+ |
@SuppressWarnings("unchecked") |
455 |
|
public <T> T[] toArray(T[] a) { |
456 |
+ |
final int size = this.size; |
457 |
|
if (a.length < size) |
458 |
|
// Make a new array of a's runtime type, but my contents: |
459 |
|
return (T[]) Arrays.copyOf(queue, size, a.getClass()); |
785 |
|
} |
786 |
|
|
787 |
|
// wrapping constructor in method avoids transient javac problems |
788 |
< |
final PriorityQueueSpliterator<E> spliterator(int origin, int fence, |
788 |
> |
final PriorityQueueSpliterator<E> spliterator(int origin, int fence, |
789 |
|
int expectedModCount) { |
790 |
< |
return new PriorityQueueSpliterator(this, origin, fence, |
791 |
< |
expectedModCount); |
790 |
> |
return new PriorityQueueSpliterator<E>(this, origin, fence, |
791 |
> |
expectedModCount); |
792 |
|
} |
793 |
|
|
794 |
|
public Stream<E> stream() { |