feat: 新增大量 slice 包和 hash 包的辅助函数

This commit is contained in:
kercylan98
2023-09-08 13:13:01 +08:00
parent 5ab990246d
commit d7724094d1
14 changed files with 493 additions and 13 deletions
-9
View File
@@ -1,7 +1,6 @@
package slice
import (
"math/rand"
"reflect"
)
@@ -111,14 +110,6 @@ func Reverse[V any](slice []V) {
}
}
// Shuffle 随机打乱数组
func Shuffle[V any](slice []V) {
for i := 0; i < len(slice); i++ {
j := rand.Intn(len(slice))
slice[i], slice[j] = slice[j], slice[i]
}
}
// Distinct 去重
func Distinct[V any](slice []V) []V {
var result []V