slicex

package
v0.0.0-...-418145e Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByLen

func ByLen(s []string)

ByLen sort by length

func ChunkSlice

func ChunkSlice[SV any](input []SV, chunkSize int) [][]SV

将一个切片分割成指定数量的切片,每个子切片的长度都是chunkSize

func Distinct

func Distinct[K comparable](s []K, predicateFunc func(item K) bool) []K

对一个slice去重,并且将不符合条件的项移除

func Except

func Except[K any](s []K, exceptFunc func(item K) bool) []K

排除一个项目中符合条件的成员,并返回一个新的slice

func Filter

func Filter[SV any](list []SV, filter func(item SV) bool) []SV

filter slice

func FindIndex

func FindIndex[V any](s []V, equalsFunc func(item V) bool) int

查找在slice中的索引

func In

func In[K comparable](s []K, item K) bool

查找slice中是否在切片中

func InWithFunc

func InWithFunc[V any](s []V, equalsFunc func(item V) bool) bool

查找slice中是否在切片中,通过传入的回调来进行比较

func MapFromInterface

func MapFromInterface[DV any](list []interface{}) ([]DV, error)

convert []interface{} to []DV if any array element cannot convert to DV,then return error

func PartitionSlice

func PartitionSlice[SV any](input []SV, partitionCount int) [][]SV

将一个切片均匀地分配到多个子切片中,子切片的数量由参数 partitionCount 决定 如果原始切片的长度小于 partitionCount,则每个子切片只包含一个元素

func RemoveByIndex

func RemoveByIndex[V any](slice []V, s int) []V

删除slice中的元素并且返回新的元素

func ToInterfaceSlice

func ToInterfaceSlice[T any](list []T) []interface{}

conver []T to []interface{}

func ToSliceV

func ToSliceV[SV any, DV any](list []SV, valueSelectFunc func(item SV) DV) []DV

Types

This section is empty.

Jump to

Keyboard shortcuts

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