Documentation
¶
Index ¶
- func Assert[T any](a any) T
- func CanditionVar[T any](fn ...func() (T, bool)) T
- func Contains[T any](ts []T, fn func(T) bool) bool
- func Difference[T comparable](a, b []T) []T
- func EqualIfNotZero[T comparable](a, b T) bool
- func Filter[T any, R any](ts []T, fn func(int, T) (R, bool)) []R
- func ForEach[T any](ts []T, fn func(int, T))
- func From[A, B any](a A, f Fromer[A, B]) B
- func GetN[T any](ts []T, i int) T
- func GroupBy[T any, K comparable, V any](collection []T, fn func(item T) (K, V)) map[K][]V
- func Intersection[T comparable](a, b []T) []T
- func Iter[T any, R any](ts []T, fn func(int, T) R) []R
- func IterToMap[T any, K comparable, V any](ts []T, fn func(int, T) (K, V)) map[K]V
- func MapToList[K comparable, V any, R any](m map[K]V, fn func(K, V) R) []R
- func NilWithDefault[T any](t, def *T) *T
- func NilWithZero[T any, R any](t *T, fn func(*T) R) R
- func RangeByStep[T any](ts []T, step int, fn func([]T))
- func SumBy[K comparable, T any](ts []T, fn func(item T) K) map[K]int64
- func TopN[T Identifier](ts []T, n int) []T
- func Union[T comparable](a, b []T) []T
- func Unique[T comparable](ts []T) []T
- func UniqueFn[T any, K comparable](ts []T, fn func(T) K) []T
- func Zero[T any]() *T
- func ZeroWithDefault[T comparable](t T, def T) T
- type Fromer
- type Identifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GroupBy ¶
func GroupBy[T any, K comparable, V any](collection []T, fn func(item T) (K, V)) map[K][]V
GroupBy 分组
func IterToMap ¶
func IterToMap[T any, K comparable, V any](ts []T, fn func(int, T) (K, V)) map[K]V
IterToMap 迭代类型T的列表, 然后转换成一个 map[K]V. K: 可以是任何可比较的值 V: 是任务类型
func MapToList ¶
func MapToList[K comparable, V any, R any](m map[K]V, fn func(K, V) R) []R
MapToList map 转成 slice
func NilWithZero ¶
NilWithZero t不为nil则执行fn. 否则返回类型为R的空值
Types ¶
type Identifier ¶
type Identifier interface {
GetID() string
}
Click to show internal directories.
Click to hide internal directories.