Comments (3)
没有 ToMap 这个方法吧?在mapx 下有一个。这里我是准备放过去 slice 包里面的。
另外顺序的话,因为考虑到有 Val 和没有 Val 两个版本,并且我希望 Key 和 Val 挨着,所以只能是 Ele 在最前,或者 Ele 在最后。
from ekit.
这里的Key是否该为comparable
改了一下函数泛型顺序,可以改成这样,然后repo内部已经存在ToMap函数了,可能函数名也得改改
// 如果 eles 是 nil,那么返回一个空的 map 而不是返回 nil
func ToMapWithE2KFunc[Key comparable, Ele any] (eles []Ele, E2KFunc func(ele Ele) Key) map[Key]Ele
// 命名无能,你可以搞一个更加牛逼的名字。
func ToMapWithE2KVFunc[Key comparable, Ele any, Val any] (eles []Ele, E2KVFunc func(ele Ele) (Key, Val)) map[Key]Val
from ekit.
没有 ToMap 这个方法吧?在mapx 下有一个。这里我是准备放过去 slice 包里面的。
另外顺序的话,因为考虑到有 Val 和没有 Val 两个版本,并且我希望 Key 和 Val 挨着,所以只能是 Ele 在最前,或者 Ele 在最后。
那我理解了,开搞
from ekit.
Related Issues (20)
- Tuple: 新增 Pair 和 Triple 两种类型 HOT 8
- retry: Strategy 接口设计与等间隔重试实现
- retry: 指数退避重试策略实现 HOT 1
- pool相关总issue
- sqlx:ScanRows 和 ScanAll方法 HOT 9
- mapx: MutipleTreeMap
- mapx: 为 MultipleMap 添加 PutVals 方法
- mapx: LinkedMap 特性 HOT 12
- copier: ReflectCopier 支持忽略字段 HOT 1
- copier: 支持类型转换 HOT 20
- randx: 随机验证码生成器 HOT 5
- ekit:AnyValue 支持类型转换 - String 转数字类型
- unsafe 转换 string 和 []byte HOT 1
- sqlx: sqlx.NewNullXXX 方法
- syncx: SegmentKeysLock HOT 3
- slice.ContainsFunc破坏性修改确认 HOT 3
- mapx: 支持 Len 方法
- 重构randx.RandCode以及传入的RandType数值 HOT 3
- 提供 Must 和 MustT 函数,简化错误处理 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ekit.