mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
bdd6171231
Signed-off-by: longjiquan <jiquan.long@zilliz.com> Signed-off-by: longjiquan <jiquan.long@zilliz.com>
57 lines
829 B
Go
57 lines
829 B
Go
package funcutil
|
|
|
|
/*
|
|
type aggFunc[T constraints.Ordered] func(t1, t2 T) T
|
|
|
|
func agg[T constraints.Ordered](op aggFunc[T], s ...T) T {
|
|
l := len(s)
|
|
if l <= 0 {
|
|
var zero T
|
|
return zero
|
|
}
|
|
m := s[0]
|
|
for i := 1; i < l; i++ {
|
|
m = op(s[i], m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
func getMin[T constraints.Ordered](t1, t2 T) T {
|
|
if t1 < t2 {
|
|
return t1
|
|
}
|
|
return t2
|
|
}
|
|
|
|
func getMax[T constraints.Ordered](t1, t2 T) T {
|
|
if t1 < t2 {
|
|
return t2
|
|
}
|
|
return t1
|
|
}
|
|
|
|
func getSum[T constraints.Ordered](t1, t2 T) T {
|
|
return t1 + t2
|
|
}
|
|
|
|
func Min[T constraints.Ordered](s ...T) T {
|
|
return agg[T](getMin[T], s...)
|
|
}
|
|
|
|
func Max[T constraints.Ordered](s ...T) T {
|
|
return agg[T](getMax[T], s...)
|
|
}
|
|
|
|
func Sum[T constraints.Ordered](s ...T) T {
|
|
return agg[T](getSum[T], s...)
|
|
}
|
|
|
|
*/
|
|
|
|
func Min(t1, t2 uint64) uint64 {
|
|
if t1 < t2 {
|
|
return t1
|
|
}
|
|
return t2
|
|
}
|