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

Primitive type equivalent of Map#forEach is missing #279

Open
markusheiden opened this issue Oct 15, 2022 · 5 comments
Open

Primitive type equivalent of Map#forEach is missing #279

markusheiden opened this issue Oct 15, 2022 · 5 comments

Comments

@markusheiden
Copy link

markusheiden commented Oct 15, 2022

I would like to iterate a map's entry set without the need for boxing. I found no equivalent for Map#forEach though.

One could achieve this via iterating over *2*EntrySet() but the code looks less readable then.

@vigna
Copy link
Owner

vigna commented Oct 15, 2022

Map#fastForEach

@vigna vigna closed this as completed Oct 15, 2022
@markusheiden
Copy link
Author

Sorry for bugging you again, but there is just a FastEntrySet#fastForEach(Consumer).

I opened this issue because I am missing the "syntactic sugar variant" using a BiConsumer. That allows for way better readable code like map.forEach((key, value) -> ...) instead of using the "clumsy" Entry#getKey and Entry#get*Value with the method mentioned above.

So it would be nice if you would reopen this issue.

@vigna vigna reopened this Oct 16, 2022
@vigna
Copy link
Owner

vigna commented Oct 16, 2022

I now see your point. The problem is that we do not have type-specific BiConsumers. Are there some provided by the JDK?

@incaseoftrouble
Copy link
Collaborator

if I recall correctly, there are none indeed! It would certainly be nice to have it, not only from code style but also performance (EntrySet#forEach allocates objects)

@Marcono1234
Copy link

It looks like this also came up when Java 8 support was discussed: #64 (comment)

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

4 participants