<div dir="ltr">Hi Pavel,<div><br></div><div>Thanks for the reply. If I understand correctly, I need this change to be discussed in one of the mailing lists there, so that someone would sponsor me to create a tracking issue in JBS. Do you know which mailing list is the most relevant for me to propose the change?</div><div><br></div><div>Thanks,</div><div>Valeh</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 14, 2023 at 12:26 AM Pavel Rappo <<a href="mailto:pavel.rappo@oracle.com">pavel.rappo@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Sorry, there's a necessary process that a PR must follow. You seem to have signed OCA already. For the rest, see this resource: <a href="https://openjdk.org/guide/" rel="noreferrer" target="_blank">https://openjdk.org/guide/</a>. In particular, this part: <a href="https://openjdk.org/guide/#contributing-to-an-openjdk-project" rel="noreferrer" target="_blank">https://openjdk.org/guide/#contributing-to-an-openjdk-project</a>.<br>
<br>
-Pavel<br>
<br>
> On 13 Dec 2023, at 23:09, Valeh Hajiyev <<a href="mailto:valeh.hajiyev@gmail.com" target="_blank">valeh.hajiyev@gmail.com</a>> wrote:<br>
> <br>
> Hi all,<br>
> <br>
> I have raised the following PR, could someone please help me to get it merged?<br>
> <br>
> <a href="https://github.com/openjdk/jdk/pull/17045" rel="noreferrer" target="_blank">https://github.com/openjdk/jdk/pull/17045</a><br>
> <br>
> More details:<br>
> <br>
> This commit addresses the current limitation in the `PriorityQueue` implementation, which lacks a constructor to efficiently create a priority queue with a custom comparator and an existing collection. In order to create such a queue, we currently need to initialize a new queue with custom comparator, and after that populate the queue using `addAll()` method, which in the background calls `add()` method (which takes `O(logn)` time) for each element of the collection (`n` times).  This is resulting in an overall time complexity of `O(nlogn)`. <br>
> <br>
> ```<br>
> PriorityQueue<String> pq = new PriorityQueue<>(customComparator);<br>
> pq.addAll(existingCollection);<br>
> ```<br>
> <br>
> The pull request introduces a new constructor to streamline this process and reduce the time complexity to `O(n)`.  If you create the queue above using the new constructor, the contents of the collection will be copied (which takes `O(n)` time) and then later  `heapify()` operation (Floyd's algorithm) will be called once (another `O(n)` time). Overall the operation will be reduced from `O(nlogn)` to `O(2n)` -> `O(n)` time.<br>
> <br>
> ```<br>
> PriorityQueue<String> pq = new PriorityQueue<>(existingCollection, customComparator);<br>
> ```<br>
> <br>
> Best regards,<br>
> Valeh Hajiyev<br>
> <br>
<br>
</blockquote></div>