-
Notifications
You must be signed in to change notification settings - Fork 14
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
sets: add the Add() method #156
Conversation
@@ -60,6 +60,15 @@ func (s *Set[T]) Contains(item T) bool { | |||
return found | |||
} | |||
|
|||
// Add inserts item into s. Returns true if the item was present. | |||
func (s *Set[T]) Add(item T) bool { |
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.
exactly what I was missing..
I had to collect all the branches in a slice and then create a set from the slice...
I think with Add this will be much faster (computation wise...), unless really all branches are unique and slice of branches is basically a set...
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.
Yes, when I realized that Add() was missing, I realized that SkyGuide must be collecting a list and calling sets.From(), which doesn't make sense I think.
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.
Its not yet used in SkyGuide (I think?). I am using Skyguide Concourse pkg in my custom tool to inspect pipelines. There I required set, and there I was using sets.From() sadly...
Also, I think we should start thinking about moving some of this small pkgs to its own repo away from cogito.. e.g. sets, retry etc... It makes little sense to "depend" (not really but...) on cogito release |
Ah, I am tempted to agree with this. I was already confused in the last PR. « ok we use this in fly_helper but why it’s in Cogito ? 🤔 » |
To be 100% clear: we do not depend on a cogito release; we simply depend on a I agree that it seems that we are almost ready to take the utility functions into their own (public) repo; when we begun, we didn't know how much reuse we would have had... |
Part of PCI-3790