[External] : Re: Introduce constructor for PriorityQueue with existing collection and custom comparator
Alan Bateman
Alan.Bateman at oracle.com
Fri Dec 15 11:59:03 UTC 2023
On 14/12/2023 10:55, Viktor Klang wrote:
> I presume that the precondition to have the original collection be
> pre-ordered according to the supplied Comparator can be verified by
> checking before adding each element in the collection to the PQ that
> it compareTo equal-or-greater to the previous one?
>
It's not a precondition. If a PQ is created from an existing collection,
or is deserialized (shudder!), then it has to copy and re-sort using the
Comparator.
-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20231215/f3e810aa/attachment.htm>
More information about the core-libs-dev
mailing list