Skip to content

feat(hashset): add Intersection method with tests - #69

Open
mohitjoshi-hey wants to merge 1 commit into
zyedidia:masterfrom
mohitjoshi-hey:add-interesection-for-hashset-with-tests
Open

mohitjoshi-hey wants to merge 1 commit into
zyedidia:masterfrom
mohitjoshi-hey:add-interesection-for-hashset-with-tests

Conversation

@mohitjoshi-hey

Copy link
Copy Markdown
Contributor

Resolves #68

This PR adds a non-destructive Intersection method to the hashset package, allowing users to find common elements between two sets without mutating the originals.

Changes:

  • Added Intersection(other *Set[K]) *Set[K]: Returns a new set containing only elements present in both s and other.
  • Added comprehensive table-driven tests covering overlapping, disjoint, identical, and empty sets.
  • Verified that original sets are strictly immutable during the operation.
  • Safely handled nil pointers for both sets to prevent panics.
  • Integrated godoc examples.

All tests pass cleanly (go test ./hashset -v).
Formatted with: go fmt ./hashset

@mohitjoshi-hey

Copy link
Copy Markdown
Contributor Author

Hey, @zyedidia!! Please review this PR.

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.

Feature: Add an intersection method for hashmap.

1 participant