feat(Go-Tool): ArrayList添加深度复制方法以及单测类、添加Rand随机获取参数方法、RandByWeight根据权重随机获取奖励方法
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user