Skip to content

Conversation

@J-Zeitler
Copy link

@J-Zeitler J-Zeitler commented Oct 27, 2025

considerations:

  • this implementation clashes a bit with slicez.Set()
  • current implementation follows rest of the convention in the lib, could instead/also expose methods on the generic Set type

condiderations:
- this implementation clashes a bit with
- current implementation follows rest of the convention in the lib, could instead/also expose methods on the generic Set type
@crholm
Copy link
Collaborator

crholm commented Oct 27, 2025

Not against it, slicez.Set() is map[E comparable]bool to have a map behave like a Set.

For performance reasons the setz package seems resonable, supporting mutations. But is the bool vs struct that much different or it the reason looking for eg effective Intersection, Difference and so on operations? If so, that might be a good reason to add them on a key level on in mapz instead?

}

func Union[A comparable](set1 Set[A], set2 Set[A]) Set[A] {
set := make(Set[A])
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably should guess a size here, at least max(len(set1), len(set2))

}

func Intersection[A comparable](set1 Set[A], set2 Set[A]) Set[A] {
set := make(Set[A])
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably should guess a size here, at least min(len(set1), len(set2))

}

func Difference[A comparable](set1 Set[A], set2 Set[A]) Set[A] {
set := make(Set[A])
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably should guess a size here, at least max(len(set1), len(set2))?

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