commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <>
Subject Re: [collections] BinaryHeap and PriorityQueue
Date Fri, 02 Jan 2004 02:51:05 GMT
Stephen Colebourne wrote:
> From: "Phil Steitz" <>
>>Stephen Colebourne wrote:
>> > Given a choice I would deprecate PQ altogether.
>>That would make things simpler.
> If no one else comments, I'll do this.
>>>I am +1 on renaming to PriorityBuffer.
> Done
> I was also looking at the heap impl and wondering if the compare method
> could check for ascendingOrder, then removing the need for near duplicate
> methods (one for minHeap, one for maxHeap) elsewhere. Would this be a good
> change?

That would simplify the code, but might cost something in overall 
performance (since compare is "hot"). Could be that's why the original 
author(s) set it up the way it is?  Should be trivial. Might be worth 
playing with.

Another solution would be to just have the constructor reverse the 
comparator for maxHeaps (using ComparatorUtils.reversedComparator). There 
the cost would be stack operations for each compare (calling through to 
the reversed comparator).

Another (small?) consideration is backward compatability for anyone who 
has subclassed BinaryHeap (assuming we are not going to deprecate), since 
all of the percolateXxx methods are protected, not private.

> Stephen
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message