mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-31 09:21:18 -05:00
Bumps [github.com/gookit/config/v2](https://github.com/gookit/config) from 2.2.3 to 2.2.4. - [Release notes](https://github.com/gookit/config/releases) - [Commits](https://github.com/gookit/config/compare/v2.2.3...v2.2.4) --- updated-dependencies: - dependency-name: github.com/gookit/config/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
77 lines
1.2 KiB
Go
77 lines
1.2 KiB
Go
package mathutil
|
|
|
|
import (
|
|
"math"
|
|
|
|
"github.com/gookit/goutil/comdef"
|
|
)
|
|
|
|
// Min compare two value and return max value
|
|
func Min[T comdef.XintOrFloat](x, y T) T {
|
|
if x < y {
|
|
return x
|
|
}
|
|
return y
|
|
}
|
|
|
|
// Max compare two value and return max value
|
|
func Max[T comdef.XintOrFloat](x, y T) T {
|
|
if x > y {
|
|
return x
|
|
}
|
|
return y
|
|
}
|
|
|
|
// SwapMin compare and always return [min, max] value
|
|
func SwapMin[T comdef.XintOrFloat](x, y T) (T, T) {
|
|
if x < y {
|
|
return x, y
|
|
}
|
|
return y, x
|
|
}
|
|
|
|
// SwapMax compare and always return [max, min] value
|
|
func SwapMax[T comdef.XintOrFloat](x, y T) (T, T) {
|
|
if x > y {
|
|
return x, y
|
|
}
|
|
return y, x
|
|
}
|
|
|
|
// MaxInt compare and return max value
|
|
func MaxInt(x, y int) int {
|
|
if x > y {
|
|
return x
|
|
}
|
|
return y
|
|
}
|
|
|
|
// SwapMaxInt compare and return max, min value
|
|
func SwapMaxInt(x, y int) (int, int) {
|
|
if x > y {
|
|
return x, y
|
|
}
|
|
return y, x
|
|
}
|
|
|
|
// MaxI64 compare and return max value
|
|
func MaxI64(x, y int64) int64 {
|
|
if x > y {
|
|
return x
|
|
}
|
|
return y
|
|
}
|
|
|
|
// SwapMaxI64 compare and return max, min value
|
|
func SwapMaxI64(x, y int64) (int64, int64) {
|
|
if x > y {
|
|
return x, y
|
|
}
|
|
return y, x
|
|
}
|
|
|
|
// MaxFloat compare and return max value
|
|
func MaxFloat(x, y float64) float64 {
|
|
return math.Max(x, y)
|
|
}
|