~rbn/fit

ref: 257085b3f4eff0bdc980dac54db6d92a71c24621 fit/item.go -rw-r--r-- 399 bytes
257085b3Ruben Schuller go.mod whoops 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
package fit

//Item interface has to be implemented by the items which should be packed.
type Item interface {
	Size() int64
}

//ItemsBySize implements sort.Interface
type ItemsBySize []Item

func (x ItemsBySize) Len() int           { return len(x) }
func (x ItemsBySize) Less(i, j int) bool { return x[i].Size() < x[j].Size() }
func (x ItemsBySize) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }