Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
FauxFaux opened this issue Aug 22, 2014 · 3 comments
Closed

Comments

@FauxFaux
Copy link

    @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
Copy link
Collaborator

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

@phraktle
Copy link

Any plans for releasing a fix?

@goldmansachs
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants