优化代码规范

This commit is contained in:
duanhf2012
2024-09-20 17:25:08 +08:00
parent 1cf071a444
commit 39116c4402
63 changed files with 1971 additions and 2043 deletions

View File

@@ -39,12 +39,13 @@ func RandN[E ~[]T, T any](arr E, num int) []T {
}
Shuffle(index)
if len(index) > num {
index = index
index = index[:num]
}
ret := make([]T, 0, len(index))
for i := range index {
ret = append(ret, arr[index[i]])
}
return ret
}
@@ -104,4 +105,4 @@ func GetPointerFunc[E ~[]T, T any](arr E, f func(T) bool) *T {
}
return &arr[index]
}
}