PriorityQueue

Brett Bernstein brett.bernstein at gmail.com
Thu May 14 16:49:24 UTC 2015


Thank you for the encouragement.  I wanted to make sure I wasn't missing
something silly before learning how the submission process works, how to
build the JDK on my machine, signed agreements, etc.  I will hopefully be
able to start down that road soon assuming my schedule accomodates.

-Brett

On Thu, May 14, 2015 at 12:01 PM, Ben Evans <benjamin.john.evans at gmail.com>
wrote:

> That sounds entirely plausible & will be of interest.
>
> Do you have a patch the community can review & contribute to?
>
> Thanks,
>
> Ben
>
>
> On Fri, May 15, 2015 at 12:52 AM, Brett Bernstein
> <brett.bernstein at gmail.com> wrote:
> > My motivation is essentially what you stated.  If someone needs to make a
> > heap and their data is Comparable, the corresponding constructor gives a
> > O(n) runtime.  If their data uses a Comparator, the corresponding runtime
> > (using addAll) is O(n*log(n)).  It is true they will need to copy the
> data
> > into an array to use it (as initElementsFromCollection does), but that is
> > unavoidable.
> >
> > On Thu, May 14, 2015 at 11:35 AM, Vitaly Davidovich <vitalyd at gmail.com>
> > wrote:
> >
> >> What I mean is what could the PQ do more efficiently with your
> Collection
> >> vs you manually add()'ing each method? Are you looking to exploit the
> same
> >> behavior in its PriorityQueue(Collection), i.e. add and then heapify in
> >> bulk? initElementsFromCollection() doesn't seem all that efficient in
> the
> >> first place if one were to invoke this on fast paths.
> >>
> >> On Thu, May 14, 2015 at 11:27 AM, Brett Bernstein <
> >> brett.bernstein at gmail.com> wrote:
> >>
> >>> I may not understand what static method you are suggesting.  If you
> have
> >>> a collection containing data and you wish to make it into a
> PriorityQueue
> >>> using a Comparator, there is no efficient method at the moment (addAll
> >>> doesn't work).
> >>>
> >>>
> >>> On Thu, May 14, 2015 at 10:11 AM, Vitaly Davidovich <vitalyd at gmail.com
> >
> >>> wrote:
> >>>
> >>>> What would be the intrinsic advantage of such a constructor? Why not a
> >>>> simple static util method in your own code that emulates this?
> >>>>
> >>>> sent from my phone
> >>>> On May 14, 2015 1:17 AM, "Brett Bernstein" <brett.bernstein at gmail.com
> >
> >>>> wrote:
> >>>>
> >>>>> To whom this may concern:
> >>>>> I believe the list of PriorityQueue constructors has a glaring
> omission
> >>>>> that could be easily rectified.  That is, there is no constructor
> that
> >>>>> takes a Collection and a Comparator.  What steps should I go through
> to
> >>>>> get
> >>>>> this suggested to be added to the class?
> >>>>>
> >>>>> Thanks,
> >>>>> Brett Bernstein
> >>>>>
> >>>>
> >>>
> >>
>


More information about the jdk9-dev mailing list