On Thu, 9 Jul 2026 01:54:56 GMT, Jason Mehrens <[email protected]> wrote:
>> Daisuke Yamazaki has updated the pull request incrementally with two
>> additional commits since the last revision:
>>
>> - Revert changes for initElementsFromCollection
>> - review
>
> src/java.base/share/classes/java/util/PriorityQueue.java line 356:
>
>> 354: @Override
>> 355: public boolean addAll(Collection<? extends E> c) {
>> 356: if (size == 0 && getClass() == PriorityQueue.class) {
>
> If policy is now going to be all-or-nothing for addAll, I think we can do
> some tricks to get rid of empty requirement.
>
> 1. Make grow() static and return an object array.
> 2. Copy element into the unpublished (grown or safe) copy.
> 3. Heapify that copy.
> 4. Assign to this.queue and increment this.size.
Thanks. I think that could work, but I'd prefer to keep this PR limited to
empty queues.
For a non-empty queue, rebuilding the whole heap could regress cases where only
a few elements are added to a large queue.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31701#discussion_r3756708216