Documentation
¶
Index ¶
- func Chunk[T any](s []T, size int) [][]T
- func Concat[T any](elems ...[]T) []T
- func Contains[T gotool.Number | string | bool](s []T, target T) bool
- func Difference[T comparable](s1, s2 []T) []T
- func Filter[T any](s []T, f func(T) bool) []T
- func GroupBy[T any, K comparable](s []T, iteratee func(item T) K) map[K][]T
- func Intersect[T comparable](elems ...[]T) []T
- func Join[T gotool.Number | string](elems []T, sep string) string
- func Map[T any, R any](s []T, iteratee func(item T) R) []R
- func Shuffle[T any](slice []T)
- func Unique[T comparable](elems ...[]T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Difference ¶
func Difference[T comparable](s1, s2 []T) []T
Difference 求差集 (s1 - s2),返回在 s1 中但不在 s2 中的元素
func GroupBy ¶
func GroupBy[T any, K comparable](s []T, iteratee func(item T) K) map[K][]T
GroupBy 将切片按指定的 Key 进行分组
Params: ¶
s: 待分组的切片 iteratee: 分组函数
func Intersect ¶
func Intersect[T comparable](elems ...[]T) []T
Intersect 求多个切片的交集,元素存在时会先去重
elems: 多个切片
Example: ¶
Intersect([]int{12, 22, 12}, []int{12, 22}) // [12 22]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.