Skip to content

Map builders do not expose methods to add elements without tupling #7

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

Open
NthPortal opened this issue Aug 27, 2020 · 1 comment
Open
Labels
bug Something isn't working library:collections

Comments

@NthPortal
Copy link
Contributor

NthPortal commented Aug 27, 2020

Scala 2.13.x

As noted by @smarter here, builders for Maps just use the regular Builder interface, and do not expose a way to add elements without creating tuples. However, several of the implementations (which are not publicly accessible) do have addOne methods taking key and value parameters.

@NthPortal NthPortal transferred this issue from scala/bug Oct 22, 2020
@NthPortal NthPortal mentioned this issue Oct 22, 2020
13 tasks
@NthPortal NthPortal added the bug Something isn't working label Nov 20, 2020
@neontorrent
Copy link

What's more concerning to me is how Map creates a Tuple2 for every MapNode iteration, like map, foreach etc. for most Map implementation.

In HashMap, MapKeyValueTupleIterator creates a Tuple2 for every pair during iteration. So if you do a map on a HashMap with 1000 elements, it creates additional 1000 Tuple2 (if there is no collision because that's a different node impl)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working library:collections
Projects
None yet
Development

No branches or pull requests

2 participants