feat(container/garray): Sorted T Array#4470
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds generic sorted array functionality with type parameters to the GoFrame library. It introduces a new SortedTArray type that provides type-safe sorted array operations.
- Adds new generic SortedTArray[T] type with comprehensive methods for sorted array operations
- Introduces new generic comparator functions in gutil package for type safety
- Updates existing generic helper functions to accept broader
anyconstraint instead ofcomparable
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| util/gutil/gutil_comparator.go | Adds generic comparators ComparatorT and ComparatorTStr for type-safe comparisons |
| container/garray/garray_sorted_t.go | Implements the main SortedTArray[T] type with all sorted array operations |
| container/garray/garray_z_unit_sorted_t_test.go | Comprehensive unit tests for the new SortedTArray functionality |
| container/garray/garray_z_example_sorted_t_test.go | Example usage tests demonstrating SortedTArray features |
| container/garray/garray_func.go | Updates generic helper functions to use any constraint for broader compatibility |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- 将 SortedArray / SortedIntArray / SortedStrArray 从值嵌入改为嵌入 *SortedTArray[T] - 为各类型增加 lazyInit 方法,在需要时懒初始化底层 SortedTArray(并为 int/str 设置默认 comparator 与 sorter) - 在大量方法入口增加 lazyInit 调用,避免未初始化指针导致的空引用 - 调整构造、Clone、DeepCopy、Marshal/Unmarshal 等实现以适配指针类型 - 修改测试用例中相关用法(例如将结构体字段改为 *SortedTArray[int],去除对按值数组的取值) - 清理 sorted_any.go 中未使用的导入 此改动使 Typed SortedArray 支持延迟初始化并减少复制开销,提升使用健壮性与一致性。
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Add the sorted T array