feat(Go-Tool): ArrayList添加深度复制方法以及单测类、添加Rand随机获取参数方法、RandByWeight根据权重随机获取奖励方法

This commit is contained in:
huangzj
2020-06-30 11:47:38 +08:00
parent e43051db30
commit d1d47051d6
7 changed files with 334 additions and 1 deletions
+15
View File
@@ -104,3 +104,18 @@ func Union(aList, bList []interface{}) []interface{} {
}
return result
}
func DeepCopyIntSlice(src []int) []int {
var clone = make([]int, len(src))
copy(clone, src)
return clone
}
func DeepCopyIntSlice2(src [][]int) [][]int {
var clone = make([][]int, len(src))
for i := 0; i < len(src); i++ {
clone[i] = DeepCopyIntSlice(src[i])
}
return clone
}