go(report): add PlotPics type (+sort.Interface)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
6692a4e778
commit
2284f35e6d
@ -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{}
|
||||
|
Loading…
Reference in New Issue
Block a user