Documentation ¶
Index ¶
- func All(arr []bool) bool
- func Any(arr []bool) bool
- func AsBoolMap[T comparable](vs []T) map[T]bool
- func AsCountMap[T comparable](arr []T) map[T]int
- func AsIndexMap[T comparable](arr []T) map[T]int
- func AsMap[K comparable, V any](arr []V, fn func(v V) K) map[K]V
- func Concat[T any](arrs ...[]T) []T
- func Contains[T comparable](arr []T, value T) bool
- func Count[T comparable](arr []T, value T) int
- func CountBy[T any](arr []T, fn func(v T, i int) bool) int
- func CountPages[T constraints.Integer](total, pageSize T) T
- func F[T any](arr []T, filter func(v T) bool) []T
- func Filter[T any](arr []T, filter func(v T, i int) bool) []T
- func GroupBy[T any, E comparable](arr []T, by func(v T) E) map[E][]T
- func GroupByOne[T any, E comparable](arr []T, keepFirst bool, by func(v T) E) map[E]T
- func Index[T comparable](arr []T, value T) int
- func IndexBy[T any](arr []T, fn func(v T, i int) bool) int
- func Int64s2Strs(arr []int64) []string
- func Intersection[T comparable](a, b []T) []T
- func M[T any, V any](arr []T, fn func(v T) V) []V
- func Map[T any, V any](arr []T, fn func(v T, i int) V) []V
- func Paging[T any](page []T, pageSize int) [][]T
- func Partition[T any](arr []T, n int) [][]T
- func R[T any, V any](arr []T, fn func(v T, result V) V, result V) V
- func Reduce[T any, V any](arr []T, fn func(v T, i int, result V) V, result V) V
- func Reindex[T any](arr []T, indexes []int)
- func Remove[T comparable](list []T, t T) []T
- func RemoveAll[T comparable](list []T, t T) []T
- func Sample[T any](arr []T, n int) []T
- func Shuffle[T any](arr []T) []T
- func Sort(arr any, less func(i, j int) []int)
- func Strs2Int64s(arr []string) ([]int64, error)
- func Subtract[T comparable](a []T, b []T) []T
- func Union[T comparable](vs ...[]T) []T
- func Unique[T comparable](vs []T) []T
- func Unzip[T any](a [][2]T) ([]T, []T)
- func Zip[T any](a []T, b []T) [][2]T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsMap ¶
func AsMap[K comparable, V any](arr []V, fn func(v V) K) map[K]V
AsMap arr -> [key]value
func Contains ¶
func Contains[T comparable](arr []T, value T) bool
func CountPages ¶
func CountPages[T constraints.Integer](total, pageSize T) T
func Filter ¶
Filter returns a new slice containing the results of applying fn to each, keep filter(v, i) == true
func GroupBy ¶
func GroupBy[T any, E comparable](arr []T, by func(v T) E) map[E][]T
func GroupByOne ¶
func GroupByOne[T any, E comparable](arr []T, keepFirst bool, by func(v T) E) map[E]T
GroupByOne group by one value
func Index ¶
func Index[T comparable](arr []T, value T) int
Index returns the index of the first instance of value in arr, or -1 if value is not present in arr.
func Int64s2Strs ¶
func Intersection ¶
func Intersection[T comparable](a, b []T) []T
func Remove ¶
func Remove[T comparable](list []T, t T) []T
Remove removes the first instance of t from list
func RemoveAll ¶
func RemoveAll[T comparable](list []T, t T) []T
RemoveAll removes all instances of t from list
func Sort ¶
Sort sorts the slice according to the fileds function. less: return comparion result of fields(like sql order by), order by id,name,age: [0,-1,1]
func Strs2Int64s ¶
func Subtract ¶
func Subtract[T comparable](a []T, b []T) []T
func Union ¶
func Union[T comparable](vs ...[]T) []T
func Unique ¶
func Unique[T comparable](vs []T) []T
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.