-
Notifications
You must be signed in to change notification settings - Fork 741
Add function to initialize set from elements #1808
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks correct to me. Only questions are:
- In this PR, should we use this in more places? i.e. in addition to occurrences where we do
: struct{}{}
- Should we name this
SetOf
in anticipation of adding functionsShortSetOf
/NodeIDSetOf
?
Hm yeah we definitely can. I did a deeper scan and found some spots we can replace usages where we're also creating an empty set then calling
Hmm personally I dislike repeating package names as I think |
Ah totally forgot we no longer have the |
nit: I wonder if we should call this |
I went with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the unnecessary type annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nits
Co-authored-by: Stephen Buttolph <stephen@avalabs.org> Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org> Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
Why this should be merged
Add a way for us to initialize a set with a pre-defined list of items. This avoids the one-liner we currently have to do of:
and now we can just do:
This PR adds this new function to the
set
package and replaces usages in avalanchego.How this works
Calls
Add
for each element passed intoOf
How this was tested
Added a UT