Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6799426

(coll) Add a constructor PriorityQueue(Comparator)

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P5
    • 8
    • 6u10
    • core-libs
    • b102
    • x86
    • windows_xp
    • Verified

    Description

      A DESCRIPTION OF THE REQUEST :
      The class java.util.PriorityQueue has no constructor with signature (Comparator). The constructor that comes closest to it requires an initial capacity and a comparator. However, the initial capacity is an implementation detail that should not be necessary in most cases.

      JUSTIFICATION :
      This enhancement is simple in the first place.

      It is hard to explain why a comparator should be tied to an initial capacity. Since the comparator cannot be changed afterwards, it has to be provided in the constructor for an empty PriorityQueue.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      new PriorityQueue(comparator) should be possible.
      ACTUAL -
      new PriorityQueue(11, comparator) is an ugly workaround.

      CUSTOMER SUBMITTED WORKAROUND :
      Use new PriorityQueue(11, comparator) instead (ugly).

      Attachments

        Issue Links

          Activity

            People

              mduigou Mike Duigou
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: