This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Fixes for PriorityQueue
- From: Andrew Haley <aph at redhat dot com>
- To: java-patches at gcc dot gnu dot org, classpath-patches at gnu dot org
- Date: Wed, 13 Sep 2006 17:56:04 +0100
- Subject: Fixes for PriorityQueue
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--;
}
};
}