feat(set): add hash set collections - #18
Merged
Merged
Conversation
guiPython
commented
Jul 22, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
set.Readonly[T]andset.Set[T]contracts while keeping the root package limited to the sharedCollectionandMapcapabilities.HashSet[T comparable]andKeyedHashSet[T, K]implementations, including typed factories, readonly views, iteration, JSON marshaling, singular/batch mutations, tests, and local benchmarks.Issue: N/A
Type Of Change
API And Behavior
Details:
set.Readonly[T]embedsgollections.Collection[T]and adds identity-aware membership checks without introducing a global set interface.set.Set[T]addsAdd/Adds,Remove/Removes, andClear; singular mutations report whether membership changed and batch mutations report how many memberships changed.HashSetOf[T]constructs reusable factories forHashSet[T], which uses Go equality and has a usable zero value.KeyedHashSet[T, K]accepts arbitrary values and derives comparable identity keys throughHashSetBy; the first value inserted for a key remains its representative, and construction through the factory is required.Testing
go test ./...go test ./internal/set ./setinternal/sethas 100.0% statement coverage.make lint, if public APIs/docs/broad behavior changed:Paste relevant output or explain why a check was not run:
Risk
HashSetvalues must have comparable dynamic types; the public docs explain both constraints and direct callers toHashSetBywhen canonical identity is required.Clearusesclear, so removed representatives are no longer retained by the set.Checklist
CONTRIBUTING.mdand checked the relevant project standards when applicable.Notes For Reviewers
HashSetOf) and derived identity (HashSetBy), including the first-representative rule.