Rejiggering.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2658 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -196,23 +196,23 @@ public class ArrayIntSet extends AbstractIntSet
|
|||||||
public boolean remove (int value)
|
public boolean remove (int value)
|
||||||
{
|
{
|
||||||
int index = binarySearch(value);
|
int index = binarySearch(value);
|
||||||
if (index >= 0) {
|
if (index < 0) {
|
||||||
_size--;
|
return false;
|
||||||
if ((_values.length > DEFAULT_CAPACITY) && (_size < _values.length/8)) {
|
|
||||||
// if we're using less than 1/8 of our capacity, shrink by half
|
|
||||||
int[] newVals = new int[_values.length/2];
|
|
||||||
System.arraycopy(_values, 0, newVals, 0, index);
|
|
||||||
System.arraycopy(_values, index+1, newVals, index, _size-index);
|
|
||||||
_values = newVals;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// shift entries past the removed one downwards
|
|
||||||
System.arraycopy(_values, index+1, _values, index, _size-index);
|
|
||||||
_values[_size] = 0;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
_size--;
|
||||||
|
if ((_values.length > DEFAULT_CAPACITY) && (_size < _values.length/8)) {
|
||||||
|
// if we're using less than 1/8 of our capacity, shrink by half
|
||||||
|
int[] newVals = new int[_values.length/2];
|
||||||
|
System.arraycopy(_values, 0, newVals, 0, index);
|
||||||
|
System.arraycopy(_values, index+1, newVals, index, _size-index);
|
||||||
|
_values = newVals;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// shift entries past the removed one downwards
|
||||||
|
System.arraycopy(_values, index+1, _values, index, _size-index);
|
||||||
|
//_values[_size] = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from interface IntSet
|
// from interface IntSet
|
||||||
@@ -239,7 +239,7 @@ public class ArrayIntSet extends AbstractIntSet
|
|||||||
// remove() is called twice in a row...
|
// 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--;
|
_pos--;
|
||||||
_values[--_size] = 0;
|
_size--; //_values[--_size] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int _pos;
|
protected int _pos;
|
||||||
|
|||||||
Reference in New Issue
Block a user