From ee688973dde20744d15e97f05bb2f7ffe08b56f9 Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Fri, 8 May 2009 21:50:17 +0000 Subject: [PATCH] Don't freak out if we were constructed with an initial capacity of zero (or a zero-length array) and we need to grow. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2555 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/ArrayIntSet.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/java/com/samskivert/util/ArrayIntSet.java b/src/java/com/samskivert/util/ArrayIntSet.java index b772ecd6..e6dcb04e 100644 --- a/src/java/com/samskivert/util/ArrayIntSet.java +++ b/src/java/com/samskivert/util/ArrayIntSet.java @@ -122,8 +122,7 @@ public class ArrayIntSet extends AbstractSet } // does not correctly return IllegalStateException if // remove() is called twice in a row... - System.arraycopy(_values, _pos, _values, _pos - 1, - _size - _pos); + System.arraycopy(_values, _pos, _values, _pos - 1, _size - _pos); _pos--; _values[--_size] = 0; } @@ -211,7 +210,7 @@ public class ArrayIntSet extends AbstractSet int valen = _values.length; int[] source = _values; if (valen == _size) { - _values = new int[valen*2]; + _values = new int[Math.max(DEFAULT_CAPACITY, valen*2)]; System.arraycopy(source, 0, _values, 0, index); }