go(report): add PlotPics type (+sort.Interface)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-07-27 23:19:02 +02:00
parent 6692a4e778
commit 2284f35e6d
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

View File

@ -23,16 +23,34 @@ type Pic struct {
Bench string // optionally set.
}
type PlotPics []Pic
// PicList is a structure holding a slice of pics and {bench,algo} metadata.
type PicList struct {
Algo string
Bench string
Pics []Pic
Pics PlotPics
}
//go:embed pics.tmpl
var tmplPicsFile []byte
// Len implements the sort.Interface.
func (p PlotPics) Len() int {
return len(p)
}
// Less implements the sort.Interface.
// note: sorting based on filename
func (p PlotPics) Less(i, j int) bool {
return p[i].FilePath < p[j].FilePath
}
// Swap implements the sort.Interface.
func (p PlotPics) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
// NewPic returns a new copy of Pic.
func NewPic() *Pic {
return &Pic{}