You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by ot...@apache.org on 2002/06/05 03:46:39 UTC

cvs commit: jakarta-lucene/src/java/org/apache/lucene/util PriorityQueue.java

otis        2002/06/04 18:46:39

  Modified:    src/java/org/apache/lucene/util PriorityQueue.java
  Log:
  - Fixed clear() method that wasn't setting the very last heap element to null,
    as reported at http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9454.
  PR: 9454
  
  Revision  Changes    Path
  1.2       +7 -7      jakarta-lucene/src/java/org/apache/lucene/util/PriorityQueue.java
  
  Index: PriorityQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/util/PriorityQueue.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PriorityQueue.java	18 Sep 2001 16:30:00 -0000	1.1
  +++ PriorityQueue.java	5 Jun 2002 01:46:39 -0000	1.2
  @@ -72,9 +72,9 @@
       heap = new Object[heapSize];
     }
   
  -  /** Adds an Object to a PriorityQueue in log(size) time. */ 
  +  /** Adds an Object to a PriorityQueue in log(size) time. */
     public final void put(Object element) {
  -    size++;	
  +    size++;
       heap[size] = element;
       upHeap();
     }
  @@ -88,7 +88,7 @@
     }
   
     /** Removes and returns the least element of the PriorityQueue in log(size)
  -    time. */ 
  +    time. */
     public final Object pop() {
       if (size > 0) {
         Object result = heap[1];			  // save first value
  @@ -111,16 +111,16 @@
     public final void adjustTop() {
       downHeap();
     }
  -    
  +
   
     /** Returns the number of elements currently stored in the PriorityQueue. */
     public final int size() {
       return size;
     }
  -  
  +
     /** Removes all entries from the PriorityQueue. */
     public final void clear() {
  -    for (int i = 0; i < size; i++)
  +    for (int i = 0; i <= size; i++)
         heap[i] = null;
       size = 0;
     }
  @@ -136,7 +136,7 @@
       }
       heap[i] = node;				  // install saved node
     }
  -  
  +
     private final void downHeap() {
       int i = 1;
       Object node = heap[i];			  // save top node
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>