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

sets: add the Add() method #156

Merged
merged 2 commits into from
May 15, 2024
Merged

sets: add the Add() method #156

merged 2 commits into from
May 15, 2024

Conversation

marco-m-pix4d
Copy link
Contributor

Part of PCI-3790

@@ -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 {
Copy link
Contributor

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...

Copy link
Contributor Author

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.

Copy link
Contributor

@aliculPix4D aliculPix4D May 15, 2024

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...

@aliculPix4D
Copy link
Contributor

aliculPix4D commented May 15, 2024

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

@iAmoric
Copy link
Contributor

iAmoric commented May 15, 2024

Also, I think we should start thinking about moving some of this small pkgs to its own repo away from cogito..

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 ? 🤔 »

@marco-m-pix4d
Copy link
Contributor Author

marco-m-pix4d commented May 15, 2024

To be 100% clear:

we do not depend on a cogito release; we simply depend on a go get github.com/Pix4D/cogito@master, which is clear and 100% pinned (@master is mapped to the git SHA of when "go get" is run).

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...

@marco-m-pix4d marco-m-pix4d merged commit 9bc5442 into master May 15, 2024
1 check passed
@marco-m-pix4d marco-m-pix4d deleted the set-add branch May 15, 2024 12:42
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.

4 participants