1 Star 0 Fork 0

余济舟/aid

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
any_array_attributer.go 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
余济舟 提交于 2025-09-04 14:14 +08:00 . [feature]anyDictV2增加HasKeyDefault方法
package anyArrayV2
type (
Attributer[T any] interface {
Register(anyArray *AnyArray[T])
}
AttrList[T any] struct{ list []T }
AttrItems[T any] struct{ items []T }
AttrLen[T any] struct{ length int }
AttrCap[T any] struct{ cap int }
AttrEmpty[T any] struct{}
)
func List[T any](list []T) Attributer[T] { return AttrList[T]{list: list} }
func (my AttrList[T]) Register(anyArray *AnyArray[T]) {
anyArray.data = my.list
}
func Items[T any](items ...T) Attributer[T] { return AttrItems[T]{items: items} }
func (my AttrItems[T]) Register(anyArray *AnyArray[T]) {
anyArray.data = my.items
}
func Len[T any](length int) Attributer[T] { return AttrLen[T]{length: length} }
func (my AttrLen[T]) Register(anyArray *AnyArray[T]) { anyArray.data = make([]T, my.length) }
func Cap[T any](cap int) Attributer[T] { return AttrCap[T]{cap: cap} }
func (my AttrCap[T]) Register(anyArray *AnyArray[T]) { anyArray.data = make([]T, 0, my.cap) }
func Empty[T any]() Attributer[T] { return AttrEmpty[T]{} }
func (my AttrEmpty[T]) Register(anyArray *AnyArray[T]) { anyArray.data = make([]T, 0) }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jericho-yu/aid.git
git@gitee.com:jericho-yu/aid.git
jericho-yu
aid
aid
v1.36.5

搜索帮助