Commit a9503e365ddd8d444759c908ea8d458a9d1b5e81
1 parent
b3e41947
Exists in
master
and in
1 other branch
feat✨:公共库
Showing
1 changed file
with
10 additions
and
0 deletions
Show diff stats
util/uttype/slice.go
| ... | ... | @@ -2,6 +2,16 @@ package uttype |
| 2 | 2 | |
| 3 | 3 | import "math/rand" |
| 4 | 4 | |
| 5 | +// Contains 切片内是否有 | |
| 6 | +func Contains[T comparable](values []T, value T) bool { | |
| 7 | + for _, v := range values { | |
| 8 | + if v == value { | |
| 9 | + return true | |
| 10 | + } | |
| 11 | + } | |
| 12 | + return false | |
| 13 | +} | |
| 14 | + | |
| 5 | 15 | // Min 最小值 |
| 6 | 16 | func Min[T Number](values ...T) T { |
| 7 | 17 | result := values[0] | ... | ... |