Documentation ¶
Index ¶
- func MapFirst[K comparable, V any](m map[K]V) (K, V)
- func SliceComplement[T comparable](sliceAll, slicePart []T, compare ...func(*T, *T) bool) []T
- func SliceContains[T comparable](slice []T, elem T, compare ...func(*T, *T) bool) bool
- func SliceFilter[T comparable](slice []T, filter func(item *T) bool) []T
- func SliceIntersection[T comparable](sliceA, sliceB []T, compare ...func(*T, *T) bool) []T
- func SliceToMap[T any, K comparable, V any](slice []T, filter func(*T) (*K, *V, bool)) map[K]V
- func SliceUnion[T comparable](sliceA, sliceB []T, compare ...func(*T, *T) bool) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapFirst ¶
func MapFirst[K comparable, V any](m map[K]V) (K, V)
MapFirst 从map中抽取第一个元素,由于map的无序性,所以这里返回的结果并不确定
func SliceComplement ¶
func SliceComplement[T comparable](sliceAll, slicePart []T, compare ...func(*T, *T) bool) []T
SliceComplement 求两个切片的补集 全集中(sliceAll)不属于某个集合(slicePart)的元素所组成的集合
func SliceContains ¶
func SliceContains[T comparable](slice []T, elem T, compare ...func(*T, *T) bool) bool
SliceContains 检查指定的元素是否存在切片中 compare 比较函数,如果为空 则直接使用值比较
func SliceFilter ¶
func SliceFilter[T comparable](slice []T, filter func(item *T) bool) []T
SliceFilter 筛选切片 通过函数筛选出符合要求的元素
func SliceIntersection ¶
func SliceIntersection[T comparable](sliceA, sliceB []T, compare ...func(*T, *T) bool) []T
SliceIntersection 求两个切片的交集 两个集合中共同的元素所组成的集合
func SliceToMap ¶
func SliceToMap[T any, K comparable, V any](slice []T, filter func(*T) (*K, *V, bool)) map[K]V
SliceToMap 将切片按照指定的过滤处理形成map
func SliceUnion ¶
func SliceUnion[T comparable](sliceA, sliceB []T, compare ...func(*T, *T) bool) []T
SliceUnion 求两个切片的并集 两个集合中所有元素(不重复)所组成的集合。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.