On Thu, Dec 14, 2023 at 4:56 AM Viktor Klang <viktor.kl...@oracle.com> 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? > Hmm... something is not adding up. Either (a) there is a precondition that the collection already be sorted or (b) there's no such precondition. In case (a): - Why isn't the new constructor invoking initElementsFromCollection() instead of initFromCollection()? - The precondition is not very obvious from the Javadoc description, and moreover what happens when the precondition is not met is not documented at all. In case (b): - The Javadoc is misleading because it (ambiguously) implies there is a precondition with the wording "collection that orders its elements according to the specified comparator" (the referent of "that" is ambiguous - does it refer to the collection or the PriorityQueue?) >From the PR description it seems clear that there is no such precondition. So maybe the Javadoc should say this instead: Creates a {@code PriorityQueue} containing the elements in the specified > collection. The {@code PriorityQueue} will order its elements according to > the specified comparator. > -Archie -- Archie L. Cobbs