array

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntContains

func IntContains(array []int, val int) (index int)

func IntIn

func IntIn(val int, array []int) bool

func IsEmptyStringsArray

func IsEmptyStringsArray(array []string) bool

func RemoveDuplicateElementInt

func RemoveDuplicateElementInt(sourceArray []int) []int

给[]int 去重。 该函数总共初始化两个变量,一个长度为0的slice,一个空map。由于slice传参是按引用传递,没有创建额外的变量。 只是用了一个for循环,代码更简洁易懂。 利用了map的多返回值特性。 空struct不占内存空间,可谓巧妙。

func RemoveDuplicateElementString

func RemoveDuplicateElementString(sourceArray []string) []string

给[]string去重,原理同上

func RemoveDuplicateElementUint

func RemoveDuplicateElementUint(sourceArray []uint) []uint

给[]uin去重,原理同上

func RemoveElementInt

func RemoveElementInt(sourceArray *[]int, toBeRemoved int) (removed bool)

删除Array中的某个int(如果该array中有多个相同的元素,每次只能删除1个)

func RemoveElementUint

func RemoveElementUint(sourceArray *[]uint, toBeRemoved uint) (removed bool)

删除Array中的某个uint(如果该array中有多个相同的元素,每次只能删除1个)

func RemoveElementsInt

func RemoveElementsInt(sourceArray *[]int, toBeRemoved *[]int) (newArray []int)

如果sourceArray中有 toBeRemoved array中的元素,则从sourceArray中删除,最终返回新的array https://stackoverflow.com/questions/5020958/go-what-is-the-fastest-cleanest-way-to-remove-multiple-entries-from-a-slice/5022696

func SplitStringArrayTo

func SplitStringArrayTo(stringArray *[]string, length int) (splitArray [][]string, groups int)

将一个string array 分成最大数量 length个的若干个string array,分成了groups组 当stringArray为空array时,groups == 0

func StringArrayToIntArray

func StringArrayToIntArray(strArray []string) (intArray []int)

将字符串list转换为int list,如果字符串list中的某元素不可转换为int,则 int list中不会有此项。

func StringsContains

func StringsContains(array []string, val string) (index int)

func UintIn

func UintIn(val uint, array []uint) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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