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
This commit is contained in:
@@ -122,8 +122,7 @@ public class ArrayIntSet extends AbstractSet<Integer>
|
|||||||
}
|
}
|
||||||
// does not correctly return IllegalStateException if
|
// does not correctly return IllegalStateException if
|
||||||
// remove() is called twice in a row...
|
// remove() is called twice in a row...
|
||||||
System.arraycopy(_values, _pos, _values, _pos - 1,
|
System.arraycopy(_values, _pos, _values, _pos - 1, _size - _pos);
|
||||||
_size - _pos);
|
|
||||||
_pos--;
|
_pos--;
|
||||||
_values[--_size] = 0;
|
_values[--_size] = 0;
|
||||||
}
|
}
|
||||||
@@ -211,7 +210,7 @@ public class ArrayIntSet extends AbstractSet<Integer>
|
|||||||
int valen = _values.length;
|
int valen = _values.length;
|
||||||
int[] source = _values;
|
int[] source = _values;
|
||||||
if (valen == _size) {
|
if (valen == _size) {
|
||||||
_values = new int[valen*2];
|
_values = new int[Math.max(DEFAULT_CAPACITY, valen*2)];
|
||||||
System.arraycopy(source, 0, _values, 0, index);
|
System.arraycopy(source, 0, _values, 0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user