On Mon, 19 Nov 2001 23:03, Gerhard Froehlich wrote: > Hi, > how about this backwards compatibility issue of the PriorityQueue. > Is there any solution?
not really - at least no elegant one. ABout the only choice would be to create new package names or interface names - PriorityQueue2 anyone? ;) > I have to change my Store Implementation in Cocoon2, because you > changed the Interface. correct. ;) > > Cheers > Gerhard > ------------------------------------------- > black holes are when GOD is dividing by zero > 23 49 43 51 3A 20 31 32 33 35 33 34 38 31 31 > -------------------------------------------- > -----Original Message----- > From: Chad Stansbury [mailto:[EMAIL PROTECTED] > Sent: Monday, November 19, 2001 4:24 AM > To: Avalon Developers List > Subject: Re: [Excalibur] PriorityQueue & BinaryHeap proposal > > > Peter - > > I've made a few changes to the code, the diffs of which are below... In > short, I've change the private modifier on the two comparators to public > (from private) so that they can be used in the constructor, I've changed > the > 'isMinHeap' constructor to use the comparable constructor to eliminate > duplication of code, I've added a size() accessor, and I've added > comments to the stuff I've added. > > Attached is the latest & greatest BinaryHeap.java + a TestBinaryHeap.java > that contains some of the code I used to test my previous n-ary heap. > Note > that I wrote the n-ary heap quite a while ago using my own unit test > harness, > and I've done little work with JUnit... perhaps you have the time to put > it in > an format acceptable to JUnit. You'll notice also that I commented out > the code > that tests inserting a null element - because the current BinaryHeap does > not > prevent inserting null elements - something that I think you might want > to change... > > Below you'll find the diff of the BinaryHeap.java file from that in CVS. > > Thanks, Chad > > > > D:\dev\cvs\cvs.exe diff -r HEAD BinaryHeap.java > Index: BinaryHeap.java > =================================================================== > RCS file: > /home/cvspublic/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalib >u r/collections/BinaryHeap.java,v > retrieving revision 1.4 > diff -r1.4 BinaryHeap.java > 45,46c45,56 > < private static final Comparator MIN_COMPARATOR = new > MinComparator(); > < private static final Comparator MAX_COMPARATOR = new > MaxComparator(); > --- > > > /** > > * Comparator used to instantiate a min heap - assumes contents > > implement > > > * the Comparable interface. > > */ > > public static final Comparator MIN_COMPARATOR = new > > MinComparator(); > > > /** > > * Comparator used to instantiate a max heap - assumes contents > > implement > > > * the Comparable interface. > > */ > > public static final Comparator MAX_COMPARATOR = new > > MaxComparator(); > > 62a73,74 > > > * > > * @param capacity the size of the heap > > 71a84,85 > > > * > > * @param comparator to order the contents of the heap > > 80a95,97 > > > * > > * @param capacity the size of the heap > > * @param comparator to order the contents of the heap > > 110,114c127 > < //+1 as 0 is noop > < m_elements = new Object[ capacity + 1 ]; > < > < if( isMinHeap ) m_comparator = MIN_COMPARATOR; > < else m_comparator = MAX_COMPARATOR; > --- > > > this( capacity, isMinHeap ? MIN_COMPARATOR : MAX_COMPARATOR ); > > 143a157,166 > > > } > > > > /** > > * Returns the number of elements currently on the heap. > > * > > * @return the size of the heap. > > */ > > public int size() > > { > > return m_size; > > CVS command finished execution -- Cheers, Pete ----------------------------------------------------------------------- | I thought there was a knob on the TV to turn up the intelligence. | | There's a knob called "brightness", but it doesn't work. | ----------------------------------------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>