Documentation
¶
Index ¶
- func Chunk[T any](slice []T, size int) [][]T
- func Contains[T comparable](slice []T, target T) bool
- func Filter[T any](slice []T, predicate func(T) bool) []T
- func Find[T any](slice []T, predicate func(T) bool) (T, bool)
- func GroupBy[T any, K comparable](slice []T, keyFunc func(T) K) map[K][]T
- func Map[T, U any](slice []T, mapper func(T) U) []U
- func Reduce[T, U any](slice []T, initialValue U, reducer func(U, T) U) U
- func Reverse[T any](slice []T)
- func SortBy[T any, K cmp.Ordered](slice []T, keyFunc func(T) K)
- func Unique[T comparable](slice []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](slice []T, target T) bool
Contains 检查切片是否包含指定元素(适用于可比较类型)
func GroupBy ¶
func GroupBy[T any, K comparable](slice []T, keyFunc func(T) K) map[K][]T
GroupBy 按指定键对切片元素进行分组
func Reduce ¶
func Reduce[T, U any](slice []T, initialValue U, reducer func(U, T) U) U
Reduce 使用泛型对切片进行归约操作
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.