Documentation
¶
Index ¶
- func All[T any](list []T, f func(T) bool) bool
- func AllMatch[T any](list []T, matchFunc func(item T) bool) bool
- func And[T ~bool](list []T) bool
- func Any[T any](list []T, f func(T) bool) bool
- func AnyMatch[T any](list []T, matchFunc func(item T) bool) bool
- func Avg[T gvalue.Numeric](list []T) float64
- func AvgBy[T any, K gvalue.Numeric](list []T, f func(T) K) float64
- func Clone[T any](list []T) []T
- func Compact[T comparable](list []T) []T
- func Contains[T comparable](list []T, item T) bool
- func ContainsAll[T comparable](list []T, items ...T) bool
- func ContainsAny[T comparable](list []T, items ...T) bool
- func Count[T comparable](list []T, item T) int
- func CountBy[T any](list []T, f func(T) bool) int
- func CountValues[T comparable](list []T) map[T]int
- func CountValuesBy[T any, K comparable](list []T, f func(T) K) map[K]int
- func Diff[T comparable](s []T, against ...[]T) []T
- func Divide[T any](list []T, n int) [][]T
- func Duplicate[T comparable](list []T) []T
- func DuplicateBy[T any, K comparable](list []T, f func(T) K) []T
- func Equal[T comparable](a, b []T) bool
- func EqualBy[T any, K comparable](a, b []T, f func(T) K) bool
- func Filter[T any](list []T, filterFunc func(item T) bool) []T
- func FilterMap[T any, R any](list []T, filterFunc func(item T) (R, bool)) []R
- func Flatten[T any](list [][]T) []T
- func Fold[T, R any](list []T, f func(R, T) R, init R) R
- func ForEach[T any](list []T, eachFunc func(item T))
- func ForEachIndex[T any](items []T, f func(int, T))
- func GroupBy[T any, K comparable](list []T, groupFunc func(T) K) map[K][]T
- func Index[T comparable](list []T, item T) int
- func IndexBy[T any, K comparable](list []T, f func(T) bool) int
- func IndexByRev[T any, K comparable](list []T, f func(T) bool) int
- func IndexRev[T comparable](list []T, item T) int
- func IndirectOf[T any](list []*T) []T
- func Intersect[T comparable](ss ...[]T) []T
- func Map[T any, R any](list []T, mapFunc func(item T) R) []R
- func MapInplace[T any](list []T, mapFunc func(item T) T) []T
- func MapReduce[T, M, R any](list []T, mapFunc func(T) M, reduceFunc func() func(M) R) R
- func Of[T any](v ...T) []T
- func Or[T ~bool](list []T) bool
- func Partition[T any](list []T, f func(T) bool) ([]T, []T)
- func PtrOf[T any](list []T) []*T
- func Reject[T any](list []T, filterFunc func(item T) bool) []T
- func Remove[T comparable](list []T, item T) []T
- func Repeat[T any](item T, n int) []T
- func RepeatBy[T any](f func() T, n int) []T
- func Reverse[T any](list []T) []T
- func Slice[T any, I gvalue.Integer](list []T, start, end I) []T
- func SliceClone[T any, I gvalue.Integer](list []T, start, end I) []T
- func Sort[T any](items []T, lessFunc func(T, T) bool) []T
- func StableSort[T any](items []T, lessFunc func(T, T) bool) []T
- func Sum[T gvalue.Numeric](list []T) T
- func SumBy[T any, K gvalue.Numeric](list []T, f func(T) K) K
- func ToMap[T, V any, K comparable](list []T, f func(T) (K, V)) map[K]V
- func ToMapValues[T any, K comparable](list []T, f func(T) K) map[K]T
- func TryFilterMap[T any, R any](list []T, filterFunc func(item T) (R, bool)) ([]R, []T)
- func TryMap[T, R any](s []T, f func(T) (R, error)) ([]R, error)
- func Union[T comparable](ss ...[]T) []T
- func Uniq[T comparable](list []T) []T
- func UniqBy[T any, K comparable](list []T, f func(T) K) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
func Count[T comparable](list []T, item T) int
func CountValuesBy ¶
func CountValuesBy[T any, K comparable](list []T, f func(T) K) map[K]int
CountValuesBy 统计每个元素出现的次数
func Diff ¶
func Diff[T comparable](s []T, against ...[]T) []T
func DuplicateBy ¶
func DuplicateBy[T any, K comparable](list []T, f func(T) K) []T
DuplicateBy 找出重复的元素
func Equal ¶
func Equal[T comparable](a, b []T) bool
func EqualBy ¶
func EqualBy[T any, K comparable](a, b []T, f func(T) K) bool
func ForEachIndex ¶
func GroupBy ¶
func GroupBy[T any, K comparable](list []T, groupFunc func(T) K) map[K][]T
GroupBy 分组
func Index ¶
func Index[T comparable](list []T, item T) int
func IndexByRev ¶
func IndexByRev[T any, K comparable](list []T, f func(T) bool) int
func IndexRev ¶
func IndexRev[T comparable](list []T, item T) int
func IndirectOf ¶
func IndirectOf[T any](list []*T) []T
func Intersect ¶
func Intersect[T comparable](ss ...[]T) []T
func MapInplace ¶
func MapInplace[T any](list []T, mapFunc func(item T) T) []T
func MapReduce ¶
func MapReduce[T, M, R any](list []T, mapFunc func(T) M, reduceFunc func() func(M) R) R
MapReduce map后reduce
func SliceClone ¶
func StableSort ¶
func ToMap ¶
func ToMap[T, V any, K comparable](list []T, f func(T) (K, V)) map[K]V
func ToMapValues ¶
func ToMapValues[T any, K comparable](list []T, f func(T) K) map[K]T
func TryFilterMap ¶
TryFilterMap 循环遍历切片,对每个元素执行函数,如果函数返回true,则添加到新的切片中,如果函数返回false,则添加到notMatch切片中
func Union ¶
func Union[T comparable](ss ...[]T) []T
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.