IntArrayList (and friends)'s sortThis assume the collection is trimmed
FauxFaux opened this issue · 3 comments
FauxFaux commented
@Test
public void testArrayListSortThis() {
final IntArrayList list = new IntArrayList();
list.add(6);
list.add(5);
list.sortThis();
assertEquals(5, list.get(0));
}
Expected :5
Actual :0
The internal array in IntArrayList, after this set of operations, is:
new int[] { 0,0,0,0,0,0,0,0,5,6 }
Fix?
public IntArrayList sortThis()
{
Arrays.sort(this.items, 0, this.size);
return this;
}
Deleted user commented
Thanks for reporting this bug. We’ll include a fix for it in the next release.
phraktle commented
Any plans for releasing a fix?
Deleted user commented
We're currently preparing the 6.0 release, which includes this fix.