Documentation ¶
Index ¶
- func CheckInSlice[T constraints.Ordered](a T, s []T) bool
- func DelOneInSlice[T constraints.Ordered](a T, old []T) (new []T)
- func GetMinValue[T comparable](from []T, valueFunc func(T) *int32) *int32
- func GetSumValue[T any, V comparable](from []T, valueFunc func(T) V, accumulator func(V, V) V) V
- func Int32Sum(a, b int32) int32
- func Map[T, K comparable](from []T, keyFunc func(T) K) map[K]T
- func MapValues[T, K, V comparable](from []T, keyFunc func(T) K, valueFunc func(T) V) map[K]V
- func MapValuesMerge[T, K, V comparable](from []T, keyFunc func(T) K, valueFunc func(T) V, mergeFunc func(V, V) V) map[K]V
- func MultiMap[T, K comparable](from []T, keyFunc func(T) K) map[K][]T
- func SliceFiltrate[V any](collection []V, filtrate func(V, int) bool) []V
- func SliceGroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T
- func SliceUniq[T any, U comparable](collection []T, iteratee func(T) U) []T
- func SliceUpdateElement[T any, R any](collection []T, iteratee func(T, int) R) []R
- type MapBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckInSlice ¶
func CheckInSlice[T constraints.Ordered](a T, s []T) bool
CheckInSlice check value in slice
func DelOneInSlice ¶
func DelOneInSlice[T constraints.Ordered](a T, old []T) (new []T)
DelOneInSlice delete one element of slice left->right
func GetMinValue ¶
func GetMinValue[T comparable](from []T, valueFunc func(T) *int32) *int32
GetMinValue 比较大小 如果集合为空则返回nil
func GetSumValue ¶
func GetSumValue[T any, V comparable](from []T, valueFunc func(T) V, accumulator func(V, V) V) V
GetSumValue 是一个泛型函数,接收一个列表 from,一个映射函数 valueFunc 和一个累加器 accumulator。 valueFunc 用于将 T 类型的元素转换为 V 类型的元素,accumulator 用于将 V 类型的元素累加起来。
func MapValues ¶
func MapValues[T, K, V comparable](from []T, keyFunc func(T) K, valueFunc func(T) V) map[K]V
MapValues 从给定的切片、键提取函数和值提取函数构建映射。
func MapValuesMerge ¶
func MapValuesMerge[T, K, V comparable](from []T, keyFunc func(T) K, valueFunc func(T) V, mergeFunc func(V, V) V) map[K]V
MapValuesMerge 从给定的切片、键提取函数、值提取函数和合并函数构建映射。
func MultiMap ¶
func MultiMap[T, K comparable](from []T, keyFunc func(T) K) map[K][]T
func SliceFiltrate ¶
func SliceGroupBy ¶
func SliceGroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T
func SliceUniq ¶
func SliceUniq[T any, U comparable](collection []T, iteratee func(T) U) []T
func SliceUpdateElement ¶
Types ¶
type MapBuilder ¶
type MapBuilder[T, K, V comparable] struct { // contains filtered or unexported fields }
func (*MapBuilder[T, K, V]) Build ¶
func (builder *MapBuilder[T, K, V]) Build() map[K]V
Click to show internal directories.
Click to hide internal directories.