This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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--;
       }
     };
   }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]