summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2012-04-03 12:31:42 +0100
committerAndrew John Hughes <ahughes@redhat.com>2012-04-03 12:31:42 +0100
commit7dbf9fc8c6b98137c4db3d8a6c63e5344746fefd (patch)
treea6bafff7b6ad6b434500dd389bc8d30ad083392a
parent8d06dfcad3d15670c0b14a447ff93821a8f6e369 (diff)
downloadclasspath-7dbf9fc8c6b98137c4db3d8a6c63e5344746fefd.tar.gz
Decrement index when removing elements from PriorityQueue. Catch capacity < 1.
2006-09-13 Andrew Haley <aph@redhat.com> * java/util/PriorityQueue.java: Throw IllegalArgumentException for capacity < 1. (Iterator.remove()): Decrement index after removing element. Signed-off-by: Andrew John Hughes <ahughes@redhat.com>
-rw-r--r--ChangeLog6
-rw-r--r--java/util/PriorityQueue.java3
2 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f8bfb9609..f935a450a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-13 Andrew Haley <aph@redhat.com>
+
+ * java/util/PriorityQueue.java: Throw IllegalArgumentException for
+ capacity < 1.
+ (Iterator.remove()): Decrement index after removing element.
+
2007-02-14 Jakub Jelinek <jakub@redhat.com>
Andrew Haley <aph@redhat.com>
diff --git a/java/util/PriorityQueue.java b/java/util/PriorityQueue.java
index 470041e9d..e421418b6 100644
--- a/java/util/PriorityQueue.java
+++ b/java/util/PriorityQueue.java
@@ -108,6 +108,8 @@ public class PriorityQueue<E> extends AbstractQueue<E> implements Serializable
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;
@@ -170,6 +172,7 @@ public class PriorityQueue<E> extends AbstractQueue<E> implements Serializable
public void remove()
{
PriorityQueue.this.remove(index);
+ index--;
}
};
}