feat(container): Add NewXXXWithChecker function for gmap/gset/gtree#4610
Merged
hailaz merged 3 commits intogogf:masterfrom Jan 15, 2026
Merged
feat(container): Add NewXXXWithChecker function for gmap/gset/gtree#4610hailaz merged 3 commits intogogf:masterfrom
hailaz merged 3 commits intogogf:masterfrom
Conversation
- 为KVMap添加NewKVMapWithChecker和NewKVMapWithCheckerFrom方法 - 为ListKVMap添加NewListKVMapWithChecker和NewListKVMapWithCheckerFrom方法 - 为TSet添加NewTSetWithChecker和NewTSetWithCheckerFrom方法 - 为AVLKVTree添加NewAVLKVTreeWithChecker和NewAVLKVTreeWithCheckerFrom方法 - 为BKVTree添加NewBKVTreeWithChecker和NewBKVTreeWithCheckerFrom方法 - 为RedBlackKVTree添加NewRedBlackKVTreeWithChecker和NewRedBlackKVTreeWithCheckerFrom方法 - 修复RedBlackKVTree中GetOrSetFuncLock文档中的拼写错误 - 为TSet的Add方法添加正确的锁释放defer语句 - 添加相关单元测试验证带检查器的容器功能
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds new constructor functions NewXXXWithChecker and NewXXXWithCheckerFrom for container types (gmap, gset, gtree) to allow developers to initialize these containers with a custom nil checker function at construction time, rather than requiring a two-step process of creation followed by calling RegisterNilChecker.
Changes:
- Added
NewXXXWithCheckerconstructors for creating containers with custom nil checkers - Added
NewXXXWithCheckerFromconstructors for creating containers from existing data with custom nil checkers - Added comprehensive test coverage for the new constructors
- Fixed defer placement in
gset.TSet.Addmethod - Fixed minor spacing issue in documentation comment
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| container/gtree/gtree_k_v_avltree.go | Added NewAVLKVTreeWithChecker and NewAVLKVTreeWithCheckerFrom constructors for AVL trees |
| container/gtree/gtree_k_v_btree.go | Added NewBKVTreeWithChecker and NewBKVTreeWithCheckerFrom constructors for B-trees |
| container/gtree/gtree_k_v_redblacktree.go | Added NewRedBlackKVTreeWithChecker and NewRedBlackKVTreeWithCheckerFrom constructors for Red-Black trees, plus spacing fix in comment |
| container/gmap/gmap_hash_k_v_map.go | Added NewKVMapWithChecker and NewKVMapWithCheckerFrom constructors for hash maps, plus comment formatting improvement |
| container/gmap/gmap_list_k_v_map.go | Added NewListKVMapWithChecker and NewListKVMapWithCheckerFrom constructors for list maps |
| container/gset/gset_t_set.go | Added NewTSetWithChecker and NewTSetWithCheckerFrom constructors for sets, plus defer statement placement fix |
| container/gtree/gtree_z_k_v_tree_test.go | Added test cases for new tree constructors with nil checkers |
| container/gmap/gmap_z_unit_k_v_map_test.go | Added test cases for new hash map constructors with nil checkers |
| container/gmap/gmap_z_unit_list_k_v_map_test.go | Added test cases for new list map constructors with nil checkers |
| container/gset/gset_z_unit_t_set_test.go | Added test cases for new set constructors with nil checkers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
hailaz
approved these changes
Jan 15, 2026
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.
为了解决开发者需要通过
var在代码顶部创建gmap/gset/gtree时需要同时设置nilchecker的需求,为这几个容易增加带有checker入参的构造函数NewxxxxWithChecker和NewxxxWithCheckerFrom