Documentation ¶
Index ¶
- func Combinations[T any](a []T) [][]T
- func CombinationsPari[T any](a, b []T, aCount, bCount int) [][]T
- func Contains[V comparable](slice []V, value V) bool
- func ContainsAny[V any](slice []V, values V) bool
- func Copy[V any](slice []V) []V
- func CopyMatrix[V any](slice [][]V) [][]V
- func Del[V any](slice *[]V, index int)
- func Distinct[V any](slice []V) []V
- func GetEndPart[V any](slice []V, n int) []V
- func GetIndex[V comparable](slice []V, value V) int
- func GetIndexAny[V any](slice []V, values V) int
- func GetPart[V any](slice []V, start, end int) []V
- func GetStartPart[V any](slice []V, n int) []V
- func Insert[V any](slice *[]V, index int, value V)
- func IsIntersect[T any](a, b []T) bool
- func IsIntersectWithCheck[T any](a, b []T, checkHandle func(a, b T) bool) bool
- func LimitedCombinations[T any](a []T, minSize, maxSize int) [][]T
- func Merge[V any](slices ...[]V) []V
- func Move[V any](slice *[]V, index, to int)
- func NextLoop[V any](slice []V, i int) (next int, value V)
- func PrevLoop[V any](slice []V, i int) (prev int, value V)
- func Reverse[V any](slice []V)
- func Shuffle[V any](slice []V)
- func SubWithCheck[T any](a, b []T, checkHandle func(a, b T) bool) []T
- func Swap[V any](slice []V, i, j int)
- func ToMap[K comparable, V any](slice []V, key func(V) K) map[K]V
- func ToSet[V comparable](slice []V) map[V]struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Combinations ¶ added in v0.0.20
func Combinations[T any](a []T) [][]T
Combinations 获取给定数组的所有组合,包括重复元素的组合
func CombinationsPari ¶ added in v0.0.21
CombinationsPari 从给定的两个数组中按照特定数量得到所有组合后,再将两个数组的组合进行组合
- 例如从数组 A 中得到所有数量为2的组合,从数组 B 中得到所有数量为3的组合,再将两个组合进行组合,得到所有数量为5的组合
func Contains ¶ added in v0.0.15
func Contains[V comparable](slice []V, value V) bool
Contains 判断数组是否包含某个元素
func ContainsAny ¶ added in v0.0.15
ContainsAny 判断数组是否包含某个元素
func GetEndPart ¶ added in v0.0.14
GetEndPart 获取数组的后 n 个元素
func GetIndex ¶ added in v0.0.20
func GetIndex[V comparable](slice []V, value V) int
GetIndex 判断数组是否包含某个元素,如果包含则返回索引
func GetIndexAny ¶ added in v0.0.20
GetIndexAny 判断数组是否包含某个元素,如果包含则返回索引
func GetStartPart ¶ added in v0.0.14
GetStartPart 获取数组的前 n 个元素
func IsIntersectWithCheck ¶ added in v0.0.20
IsIntersectWithCheck 判断两个切片是否有交集
func LimitedCombinations ¶ added in v0.0.20
LimitedCombinations 获取给定数组的所有组合,且每个组合的成员数量限制在指定范围内
func ToMap ¶ added in v0.0.5
func ToMap[K comparable, V any](slice []V, key func(V) K) map[K]V
ToMap 将数组转换为 map
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.