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

Use Java's least common denominator for random access lists #134

Closed
wants to merge 1 commit into from

Conversation

karypid
Copy link
Contributor

@karypid karypid commented Mar 8, 2018

Hi,

Could you accept this minor change so that we can do unordered removals using AbstractList instead of ArrayList? Seems a pity/inconsistent to not be able to use this on org.agrona.collections.IntArrayList and org.agrona.collections.LongArrayList.

An alternative would be to have the latter extend ArrayList instead of AbstactList.

This would of course cause boxing in the "list.set(index, list.remove(lastIndex));" line so maybe it's even better to just add a "removeUnordered" in IntArrayList / LongArrayList themselves?

@karypid
Copy link
Contributor Author

karypid commented Mar 8, 2018

Are you referring to the name of the org.agrona.collections.ArrayListUtil class that I modified? It was already named as such, I did not want to change it because it might break API with client code (e.g. Aeron) that uses it.

I think the name of this class was meant to point out that it is supposed to be used on direct-access lists (array based) otherwise "fastUnorderedRemove" is not really fast. Right now it picks the last item and uses it to overwrite the item being removed (reducing the collection size by 1).

Like I said, I wanted to use it in combination with org.agrona.collections.IntArrayList and org.agrona.collections.LongArrayList but these extend java.util.AbstractList.

I actually changed my mind now; I think it's better to just implement these as methods in IntArrayList/LongArrayList to make sure there is no boxing of the primitives possible so I am closing this. I will submit a request to add fast unordered remove in those 2 instead.

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

Successfully merging this pull request may close these issues.

1 participant