max

package
v0.0.0-...-a56dbdc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2018 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ByField = generic.DefineFunc("MaxByField(vals T) E").
	Param("T", "array type").
	Param("E", "array element type", func(argMap generic.ArgMap) interface{} {
		return argMap["T"].(reflect.Type).Elem()
	}).
	Param("F", "the field to compare").
	ImportFunc(compare.ByField).
	Source(`
{{ $compare := expand "CompareByField" "T" .E "F" .F }}
currentMax := vals[0]
for i := 1; i < len(vals); i++ {
	if {{$compare}}(vals[i], currentMax) > 0 {
		currentMax = vals[i]
	}
}
return currentMax`)
View Source
var ByFieldForPlz = generic.DefineFunc("MaxByFieldForPlz(vals []interface{}) interface{}").
	Param("T", "array element type").
	Param("F", "the field to compare").
	ImportFunc(compare.ByField).
	Source(`
{{ $compare := expand "CompareByField" "T" .T "F" .F }}
currentMax := vals[0].({{.T|name}})
for i := 1; i < len(vals); i++ {
	typedVal := vals[i].({{.T|name}})
	if {{$compare}}(typedVal, currentMax) > 0 {
		currentMax = typedVal
	}
}
return currentMax`)
View Source
var ByItself = generic.DefineFunc("MaxByItself(vals T) E").
	Param("T", "array type").
	Param("E", "array element type", func(argMap generic.ArgMap) interface{} {
		return argMap["T"].(reflect.Type).Elem()
	}).
	ImportFunc(compare.ByItself).
	Source(`
{{ $compare := expand "CompareByItself" "T" .E }}
currentMax := vals[0]
for i := 1; i < len(vals); i++ {
	if {{$compare}}(vals[i], currentMax) > 0 {
		currentMax = vals[i]
	}
}
return currentMax`)
View Source
var ByItselfForPlz = generic.DefineFunc("MaxByItselfForPlz(vals []interface{}) interface{}").
	Param("T", "array element type").
	ImportFunc(compare.ByItself).
	Source(`
{{ $compare := expand "CompareByItself" "T" .T }}
currentMax := vals[0].({{.T|name}})
for i := 1; i < len(vals); i++ {
	typedVal := vals[i].({{.T|name}})
	if {{$compare}}(typedVal, currentMax) > 0 {
		currentMax = typedVal
	}
}
return currentMax`)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL