On Thu, 4 Jan 2024 14:21:54 GMT, Valeh Hajiyev <d...@openjdk.org> wrote:
>>>I think this ticket should focus on adding the new constructor as part of >>>the API. >> >> Okay. I would think the code would avoid heapify when the caller does >> foolish things with this API such as: >> >> SortedSet ss = filledSortedSet(); >> PriorityQueue pq1 = new PriorityQueue(ss.comparator(), ss); >> >> PriorityQueue pq = filledPriorityQueue(); >> PriorityQueue pq2 = new PriorityQueue(pq.comparator(), pq); >> >> >> I assume this constructor is going to be added to TreeSet, >> PriorityBlockingQueue, and ConcurrentSkipListSet? > >> > I think this ticket should focus on adding the new constructor as part of >> > the API. >> >> Okay. I would think the code would avoid heapify when the caller does >> foolish things with this API such as: >> >> ``` >> SortedSet ss = filledSortedSet(); >> PriorityQueue pq1 = new PriorityQueue(ss.comparator(), ss); >> >> PriorityQueue pq = filledPriorityQueue(); >> PriorityQueue pq2 = new PriorityQueue(pq.comparator(), pq); >> ``` >> >> I assume this constructor is going to be added to TreeSet, >> PriorityBlockingQueue, and ConcurrentSkipListSet? > > why do you think the code would avoid heapify? `initFromCollection` method > will be called regardless of the type of the collection passed, which will > heapify the queue. > > regarding adding the constructor to the other types mentioned, I believe I > can be done, probably as part of a different ticket. I have created a CSR. @valeh feel free to come back and reopen this with `/reopen` command. ------------- PR Comment: https://git.openjdk.org/jdk/pull/17045#issuecomment-2234811170