Split methods to separate files, drop redundant intefaces Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
17 lines
342 B
Go
17 lines
342 B
Go
package collection
|
|
|
|
import "golang.org/x/exp/constraints"
|
|
|
|
// Max finds maximum value of items.
|
|
func Max[T constraints.Ordered](items ...T) T {
|
|
if len(items) == 0 {
|
|
panic("failed to get max value: empty slice")
|
|
}
|
|
result := items[0]
|
|
for i := 1; i < len(items); i++ {
|
|
if items[i] > result {
|
|
result = items[i]
|
|
}
|
|
}
|
|
return result
|
|
}
|