On Thu, 8 Nov 2001 01:04, Chad Stansbury wrote:
> Okay - here's the problem.  The current BinaryHeap interface expects a
> Comparable for it's public interface.  In order to maintain backwards
> compatibility I must either:
>
> 1. Add new public methods to the BinaryHeap class (e.g., insertObject,
> peekObject, popObject) and change the insert, peek, and pop methods to
> invoke these new methods, or
> 2. I can create a new BinaryObjectHeap class and have the BinaryHeap class
> act as a wrapper class.
>
> I am also wondering how I would modify the PriorityQueue interface w/o
> breaking backwards compatibility...
>
> Any suggestions would be appreciated.

I am not sure we need to maintain 100% backwards compatability in this case. 
peek() and pop() methods in al cases that I use them and have seen them used 
will actually need to be cast to something else anyways. Retrieving a 
Comparable from heap is rarely the aim and come to think of it I think it was 
probably a mistake to return Comparables rather than Objects ;)

For insert there will need to be backwards compatability because people will 
use that to pass in comparables. However you should be ab;le to get backwards 
compatability with this by just checking the type passed in (if Comparable do 
X, else do Y) and converting parameter to Object.

-- 
Cheers,

Pete

--------------------------------------------------------------
"Science is like sex: sometimes something useful comes out, 
but that is not the reason we are doing it" -- Richard Feynman
--------------------------------------------------------------

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to