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
+17
View File
@@ -91,6 +91,11 @@ func TestJoin(t *testing.T) {
union(mm, mm2)
}
func TestEqual(t *testing.T) {
DeepCopyIntSlice()
DeepCopyIntSlice2()
}
func intersection(mm, nn []interface{}) {
i1 := array.Intersection(mm, nn)
for _, row := range i1 {
@@ -116,6 +121,18 @@ func union(mm, nn []interface{}) {
}
}
func DeepCopyIntSlice() {
src := []int{1, 2, 3, 4, 5, 6}
src1 := array.DeepCopyIntSlice(src)
fmt.Println(&src == &src1)
}
func DeepCopyIntSlice2() {
src := [][]int{{1, 2, 3}, {4, 5, 6}}
src1 := array.DeepCopyIntSlice2(src)
fmt.Println(&src == &src1)
}
func init() {
mm = make([]interface{}, 0)
mm1 = make([]interface{}, 0)