Documentation
¶
Index ¶
- func AppendByteSlice[T any](dst, src []T) []T
- func Clone[T any](list []T) []T
- func Contain[T comparable](s []T, v T) bool
- func ContainFunc[T any](s []T, f func(T) bool) bool
- func DeduplicationSlice[T comparable](slice []T) []T
- func FindIndex[T comparable](s []T, v T) int
- func Insert[T any](s *[]T, index int, v T)
- func Max[T cmp.Ordered](list []T) T
- func MergeSlice[T any](xs ...[]T) []T
- func MergeSlices[T any](slices [][]T) []T
- func Min[T cmp.Ordered](list []T) T
- func Overwrite2FrontInPlace[T any](s []T, startPos int, length int)
- func Remove[T any](s *[]T, index int)
- func RemoveElem[T comparable](s *[]T, v T)
- func RemoveElems[T comparable](s *[]T, beRemoved []T)
- func Shuffle[T any](list []T) []T
- func Sum[T Number](list []T) T
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendByteSlice ¶ added in v1.2.9
func AppendByteSlice[T any](dst, src []T) []T
AppendByteSlice efficiently appends src to dst, automatically growing capacity if needed This replaces the manual capacity calculation and copy operations Returns the updated slice with src data appended
func ContainFunc ¶ added in v1.2.6
ContainFunc 是否包含指定元素
func DeduplicationSlice ¶ added in v1.2.9
func DeduplicationSlice[T comparable](slice []T) []T
DeduplicationSlice : deduplicate a slice of comparable
func FindIndex ¶
func FindIndex[T comparable](s []T, v T) int
FindIndex 查找第一个匹配的元素所在的index,返回-1代表没有找到
func MergeSlice ¶ added in v1.2.9
func MergeSlice[T any](xs ...[]T) []T
MergeSlice merges two slices into one slice. The order of elements in the merged slice is the same as the order of the input slices. If both input slices are nil or empty, it returns nil.
func MergeSlices ¶ added in v1.2.9
func MergeSlices[T any](slices [][]T) []T
MergeSlices merges multiple slices into one slice. The order of elements in the merged slice is the same as the order of the input slices. If all input slices are nil or empty, it returns nil.
func Overwrite2FrontInPlace ¶ added in v1.2.9
Overwrite2FrontInPlace overwrite(copy) the elements of the slice to the front in place. The front elements will be overwritten, the other elements will remain unchanged. s - the slice to overwrite elements in startPos - the starting position of the elements to move length - the number of elements to move, if length is -1, it means to the end of the slice Example: s := []int{1, 2, 3, 4, 5, 6} Move2FrontInPlace(s, 2, 3) fmt.Println(s) // Output: [3, 4, 5, 4, 5, 6]
func RemoveElems ¶ added in v1.1.7
func RemoveElems[T comparable](s *[]T, beRemoved []T)
RemoveElems 删除第一个匹配的元素