Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(container): Add NewXXXWithChecker function for gmap/gset/gtree#4610

Merged
hailaz merged 3 commits intogogf:masterfrom
LanceAdd:fix/isnil2
Jan 15, 2026
Merged

feat(container): Add NewXXXWithChecker function for gmap/gset/gtree#4610
hailaz merged 3 commits intogogf:masterfrom
LanceAdd:fix/isnil2

Conversation

@LanceAdd
Copy link
Member

为了解决开发者需要通过var在代码顶部创建gmap/gset/gtree时需要同时设置nilchecker的需求,为这几个容易增加带有checker入参的构造函数NewxxxxWithCheckerNewxxxWithCheckerFrom

- 为KVMap添加NewKVMapWithChecker和NewKVMapWithCheckerFrom方法
- 为ListKVMap添加NewListKVMapWithChecker和NewListKVMapWithCheckerFrom方法
- 为TSet添加NewTSetWithChecker和NewTSetWithCheckerFrom方法
- 为AVLKVTree添加NewAVLKVTreeWithChecker和NewAVLKVTreeWithCheckerFrom方法
- 为BKVTree添加NewBKVTreeWithChecker和NewBKVTreeWithCheckerFrom方法
- 为RedBlackKVTree添加NewRedBlackKVTreeWithChecker和NewRedBlackKVTreeWithCheckerFrom方法
- 修复RedBlackKVTree中GetOrSetFuncLock文档中的拼写错误
- 为TSet的Add方法添加正确的锁释放defer语句
- 添加相关单元测试验证带检查器的容器功能
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 NewXXXWithChecker constructors for creating containers with custom nil checkers
  • Added NewXXXWithCheckerFrom constructors for creating containers from existing data with custom nil checkers
  • Added comprehensive test coverage for the new constructors
  • Fixed defer placement in gset.TSet.Add method
  • 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.

@hailaz hailaz merged commit c600f3a into gogf:master Jan 15, 2026
18 checks passed
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.

2 participants