mirror of
https://github.com/tiny-craft/tiny-rdm.git
synced 2025-10-23 23:23:09 +08:00
perf: use build-in min/max function instead
This commit is contained in:
@@ -20,11 +20,6 @@ func MaxWithIndex[T Hashable](items ...T) (T, int) {
|
||||
return items[selIndex], selIndex
|
||||
}
|
||||
|
||||
func Max[T Hashable](items ...T) T {
|
||||
val, _ := MaxWithIndex(items...)
|
||||
return val
|
||||
}
|
||||
|
||||
// MinWithIndex 查找所有元素中的最小值
|
||||
func MinWithIndex[T Hashable](items ...T) (T, int) {
|
||||
selIndex := -1
|
||||
@@ -40,11 +35,6 @@ func MinWithIndex[T Hashable](items ...T) (T, int) {
|
||||
return items[selIndex], selIndex
|
||||
}
|
||||
|
||||
func Min[T Hashable](items ...T) T {
|
||||
val, _ := MinWithIndex(items...)
|
||||
return val
|
||||
}
|
||||
|
||||
// Clamp 返回限制在minVal和maxVal范围内的value
|
||||
func Clamp[T Hashable](value T, minVal T, maxVal T) T {
|
||||
if minVal > maxVal {
|
||||
|
Reference in New Issue
Block a user