-
Notifications
You must be signed in to change notification settings - Fork 18k
maps: new package to provide generic map functions #47649
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
These look pretty good to me, I only really paused over the Keys and Values functions: how often are these used where you wouldn’t be better served by a for range loop? |
I think that func RemoveDuplicates(s []someType) []someType {
m := make(map[someType]bool)
for _, v := range s {
m[v] = true
}
return maps.Keys(m) |
Instead of Add have you considered that Copy may be clearer? Copy implies copying from a src to dst and overwriting values. |
|
It would be best if discussion about this proposal continues on the existing discussion at #47330. Decisions made there will be reflected here. I'm going to lock this issue temporarily. Thanks. |
Based on the discussion above, this proposal seems like a likely accept. |
This proposal has been added to the active column of the proposals project |
We've discussed and agreed to change DeleteIf to DeleteFunc to better match other APIs we have. |
Based on the discussion above, this proposal seems like a likely accept. |
Still some discussion on #47330 but it seems to be converging. |
Converged to using constraints.Map consistently. |
No change in consensus, so accepted. 🎉 |
Change https://golang.org/cl/364875 mentions this issue: |
This package is now available at golang.org/x/exp/maps. Per https://groups.google.com/g/golang-dev/c/iuB22_G9Kbo/m/7B1jd1I3BQAJ?utm_medium=email&utm_source=footer it will not be put into standard library until the 1.19 release. We may of course adjust it based on anything we learn about having it in x/exp. |
I've opened #57436 to propose moving x/exp/maps into the standard library. Closing this proposal as completed. |
Discussed in #47330
The text was updated successfully, but these errors were encountered: