avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/util BinaryHeap.java
Date Thu, 15 Mar 2001 17:04:37 GMT
ramc        01/03/15 09:04:37

  Modified:    src/java/org/apache/avalon/util BinaryHeap.java
  Log:
  Minor bug fix. use the correct size while checking if the Heap is full. Also, removed the
reference of pop'ed objects.
  
  Revision  Changes    Path
  1.2       +7 -1      jakarta-avalon/src/java/org/apache/avalon/util/BinaryHeap.java
  
  Index: BinaryHeap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/util/BinaryHeap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BinaryHeap.java	2001/02/24 03:59:37	1.1
  +++ BinaryHeap.java	2001/03/15 17:04:32	1.2
  @@ -14,6 +14,7 @@
    * This interface does not dictate whether it is min or max heap.
    *
    * @author  <a href="mailto:donaldp@apache.org">Peter Donald</a> 
  + * @author  <a href="mailto:ram.chidambaram@telus.com">Ram Chidambaram</a>

    */
   public final class BinaryHeap 
       implements PriorityQueue
  @@ -72,7 +73,8 @@
        */
       public boolean isFull()
       {
  -        return ( m_elements.length == m_size );
  +        //+1 as element 0 is noop
  +        return ( m_elements.length == m_size+1 );
       }
   
       /**
  @@ -111,6 +113,10 @@
       {
           final Comparable result = peek();
           m_elements[ 1 ] = m_elements[ m_size-- ];
  +
  +        //set the unused element to 'null' so that the garbage collector 
  +        //can free the object if not used anywhere else.(remove reference)
  +        m_elements[ m_size + 1 ] = null;
   
           if( m_size != 0 )
           {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message