coll

package
v0.0.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapCollect added in v0.0.37

func MapCollect[K, RK comparable, V, RV any](m map[K]V, mapFn func(K, V) (RK, RV)) map[RK]RV

MapCollect 将map转换成新的map

func MapFilterCollect added in v0.0.37

func MapFilterCollect[K, RK comparable, V, RV any](m map[K]V, mapFn func(K, V) (RK, RV, bool)) map[RK]RV

MapFilterCollect 将map过滤转换成新的map

func MapFilterToSlice added in v0.0.37

func MapFilterToSlice[K comparable, V, R any](m map[K]V, mapFn func(K, V) (R, bool)) []R

MapFilterToSlice 将map过滤转换成切片

func MapFirst

func MapFirst[K comparable, V any](m map[K]V) (K, V)

MapFirst 从map中抽取第一个元素

func MapForeach added in v0.0.38

func MapForeach[K comparable, V any](m map[K]V, fn func(k K, v V) bool)

MapForeach 遍历map return false时停止迭代

func MapForeachAll added in v0.0.38

func MapForeachAll[K comparable, V any](m map[K]V, fn func(k K, v V))

MapForeachAll 遍历map

func MapKeyToSlice added in v0.0.33

func MapKeyToSlice[K comparable, V any](m map[K]V) []K

MapKeyToSlice 将map的key转换为slice

func MapValueToSlice added in v0.0.35

func MapValueToSlice[K comparable, V any](m map[K]V) []V

MapValueToSlice 将map的value转换为slice

func SliceAnyContains added in v0.0.31

func SliceAnyContains[T comparable](slice []T, compare func(ele T) bool) bool

SliceAnyContains 检查指定的元素是否存在切片中,元素可以是任意类型

func SliceAnyIndexOf added in v0.0.37

func SliceAnyIndexOf[T comparable](slice []T, compare func(ele T) bool) int

SliceAnyIndexOf 获取指定元素在切片中的索引,如果元素不存在则返回-1

func SliceCollect added in v0.0.31

func SliceCollect[T, R any](input []T, mapFn func(T) R) []R

SliceCollect 将切片按照指定的采集映射方法处理为一个新的切片

func SliceComplement

func SliceComplement[T comparable](slicePart1, slicePart2 []T, compare ...func(part1, part2 T) bool) []T

SliceComplement 求两个切片的补集 全集中(slicePart1)不属于某个集合(slicePart2)的元素所组成的集合

func SliceContains

func SliceContains[T comparable](slice []T, target T, compare ...func(T, T) bool) bool

SliceContains 检查指定的元素是否存在切片中

func SliceDistinct added in v0.0.33

func SliceDistinct[T comparable](slice []T) []T

SliceDistinct 去除切片的重复元素

func SliceFilter

func SliceFilter[T any](slice []T, filter func(item T) bool) []T

SliceFilter 筛选切片 通过函数筛选出符合要求的元素

func SliceFilterCollect added in v0.0.37

func SliceFilterCollect[T, R any](input []T, mapFn func(T) (R, bool)) []R

SliceFilterCollect 将切片按照指定的过滤条件采集映射方法处理为一个新的切片

func SliceFilterFirstOne added in v0.0.37

func SliceFilterFirstOne[T any](slice []T, filter func(item T) bool) (T, bool)

SliceFilterFirstOne 筛选切片 通过函数筛选出符合要求的第一个元素

func SliceFilterToMap added in v0.0.32

func SliceFilterToMap[T any, K comparable, V any](slice []T, filter func(T) (K, V, bool)) map[K]V

SliceFilterToMap 将切片按照指定的过滤处理形成map

func SliceForeach added in v0.0.31

func SliceForeach[T any](slice []T, fn func(T) bool)

SliceForeach 遍历切片并执行指定的函数,如果返回false则停止遍历

func SliceForeachAll added in v0.0.37

func SliceForeachAll[T any](slice []T, fn func(T))

SliceForeachAll 遍历所有切片并执行指定的函数

func SliceIndexOf added in v0.0.37

func SliceIndexOf[T comparable](slice []T, target T, compare ...func(T, T) bool) int

SliceIndexOf 获取指定元素在切片中的索引,如果元素不存在则返回-1

func SliceIntersection

func SliceIntersection[T comparable](slicePart1, slicePart2 []T, compare ...func(part1, part2 T) bool) []T

SliceIntersection 求两个切片的交集 两个集合中共同的元素所组成的集合

func SliceSort added in v0.0.38

func SliceSort[T any](slice []T, less func(e T) int, desc ...bool)

SliceSort 对切片进行排序 less: 元素排序的权重值 desc: 是否降序 默认为升序

func SliceUnion

func SliceUnion[T comparable](slicePart1, slicePart2 []T, compare ...func(part1 T, part2 T) bool) []T

SliceUnion 求两个切片的并集 两个集合中所有元素(不重复)所组成的集合。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL