- 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
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149767 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2002-06-05 01:46:39 +00:00
parent abefb1b48e
commit a7bd647dd6
1 changed files with 7 additions and 7 deletions

View File

@ -72,9 +72,9 @@ public abstract class PriorityQueue {
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 @@ public abstract class PriorityQueue {
}
/** 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 abstract class PriorityQueue {
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 @@ public abstract class PriorityQueue {
}
heap[i] = node; // install saved node
}
private final void downHeap() {
int i = 1;
Object node = heap[i]; // save top node