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

slices: add Difference function #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cuishuang
Copy link
Contributor

@cuishuang cuishuang commented Feb 25, 2023

There are many scenarios where it is necessary to obtain the difference of two slices. At present, the more common method is to create a new utils package in the project and write the method implementation in it. Now that the Go standard library has a new slices package, it is recommended to add an API:

Update golang/go#58730

@gopherbot
Copy link
Contributor

This PR (HEAD: 33ca1be) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/exp/+/471277 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

if s2len == 0 {
return s1
}
s2Map := make(map[E]bool, s2len)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use map[E]struct{}?

Suggested change
s2Map := make(map[E]bool, s2len)
s2Map := make(map[E]struct{}, s2len)

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.

3 participants