goldmansachs / gs-collections

GS Collections has been migrated to the Eclipse Foundation, re-branded as Eclipse Collections. https://www.eclipse.org/collections/
https://www.eclipse.org/collections/
1.81k stars 276 forks source link

IntArrayList (and friends)'s sortThis assume the collection is trimmed #16

Closed FauxFaux closed 9 years ago

FauxFaux commented 10 years ago
    @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;
    }
goldmansachs commented 10 years ago

Thanks for reporting this bug. We’ll include a fix for it in the next release.

phraktle commented 9 years ago

Any plans for releasing a fix?

goldmansachs commented 9 years ago

We're currently preparing the 6.0 release, which includes this fix.