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

{"",remove}{Last,First}$TYPE for Lists? #338

Open
rionda opened this issue Nov 28, 2024 · 3 comments
Open

{"",remove}{Last,First}$TYPE for Lists? #338

rionda opened this issue Nov 28, 2024 · 3 comments

Comments

@rionda
Copy link

rionda commented Nov 28, 2024

Ciao Seba,

The *LinkedOpenHashMap* classes have methods such as first$TYPE, last$TYPE, removeFirst$TYPE, removeLast$TYPE which return a primitive. Would it please be possible to have the same methods also for the List types (and possibly others), to avoid boxing/unboxing ?

My use case is removing a random element from an $TYPEArrayList by overwriting it with the last element of the list, as in list.set(randomIndex, list.removeLast()), and I would like to use removeLast$TYPE() at the end (I understand that I could use list.remove$TYPE(list.size() - 1), but I assume removeLast() wouldn't incur in the cost of range-checking, maybe?)

Thanks,
Matteo

@vigna
Copy link
Owner

vigna commented Nov 28, 2024

Mmmhh if you need something like that quickly the easier thing is subclassing (the class code is really easy). It is of course possible to write all those methods but unfortunately I have zero bandwith to work on this now. You're welcome to try a PR, of course. :)

@rionda
Copy link
Author

rionda commented Nov 28, 2024

I'll see what I can do, thank you for the quick answer. I had some hope that it would have been just a quick fix for someone who knew the code, but it seems that's not the case, from your answer =)

@vigna
Copy link
Owner

vigna commented Nov 28, 2024

It's not difficult. But then you have to write the tests. Check that everything works. It takes some time. I have paper deadline and two people graduating within a week...

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