From a0f67d5721fd1f2c5c226d30afa773f2fbfd2b4e Mon Sep 17 00:00:00 2001 From: "samskivert@gmail.com" Date: Thu, 25 Aug 2005 20:35:41 +0000 Subject: [PATCH] Made remove() work in our Interator. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1706 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/ArrayIntSet.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java b/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java index 279e24d8..60bf6f4f 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java +++ b/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java @@ -117,7 +117,15 @@ public class ArrayIntSet extends AbstractSet } public void remove () { - throw new UnsupportedOperationException(); + if (_pos == 0) { + throw new IllegalStateException(); + } + // does not correctly return IllegalStateException if + // remove() is called twice in a row... + System.arraycopy(_values, _pos, _values, _pos - 1, + _size - _pos); + _pos--; + _values[--_size] = 0; } protected int _pos;