Fixes for PriorityQueue
Andrew Haley
aph@redhat.com
Wed Sep 13 16:56:00 GMT 2006
Bugs found by the JSR 166 test suite.
2006-09-13 Andrew Haley <aph@redhat.com>
* java/util/PriorityQueue.java: Throw IllegalArgumentException for
capacity < 1.
(Iterator.remove()): Decrement index after removing element.
Index: PriorityQueue.java
===================================================================
--- PriorityQueue.java (revision 116678)
+++ PriorityQueue.java (working copy)
@@ -108,6 +108,8 @@
public PriorityQueue(int cap, Comparator<? super E> comp)
{
+ if (cap < 1)
+ throw new IllegalArgumentException();
this.used = 0;
this.storage = (E[]) new Object[cap];
this.comparator = comp;
@@ -169,6 +171,7 @@
public void remove()
{
PriorityQueue.this.remove(index);
+ index--;
}
};
}
More information about the Java-patches
mailing list