SIGN IN SIGN UP
esimov / caire UNCLAIMED

Content aware image resize library

0 0 1 Go
package utils
2025-04-27 10:40:09 +03:00
import (
"slices"
"golang.org/x/exp/constraints"
)
2022-05-03 15:43:54 +03:00
// Min returns the slowest value of the provided parameters.
func Min[T constraints.Ordered](values ...T) T {
var acc T = values[0]
for _, v := range values {
if v < acc {
acc = v
}
}
2022-05-03 15:43:54 +03:00
return acc
}
2022-05-03 15:43:54 +03:00
// Max returns the biggest value of the provided parameters.
func Max[T constraints.Ordered](values ...T) T {
var acc T = values[0]
for _, v := range values {
if v > acc {
acc = v
}
}
2022-05-03 15:43:54 +03:00
return acc
}
// Abs returns the absolut value of x.
func Abs[T constraints.Signed | constraints.Float](x T) T {
if x < 0 {
return -x
}
return x
}
2022-10-22 07:53:20 +03:00
// Contains returns true if a value is available in the collection.
func Contains[T comparable](slice []T, value T) bool {
2025-04-27 10:40:09 +03:00
return slices.Contains(slice, value)
}