gtq/uintslice.go

23 lines
485 B
Go
Raw Normal View History

2019-04-11 14:21:27 +00:00
package gtq
// UIntSlice just subtypes []uint to fulfill sort.Interface, as demonstrated
// for other types in the sort package.
type UIntSlice []uint
// Len helps fulfill sort.Interface.
func (list UIntSlice) Len() int {
return len(list)
}
// Less helps fulfill sort.Interface.
func (list UIntSlice) Less(i, j int) bool {
return list[i] <= list[j]
2019-04-11 14:21:27 +00:00
}
// Swap helps fulfill sort.Interface
func (list UIntSlice) Swap(i, j int) {
tmp := list[i]
list[i] = list[j]
list[j] = tmp
}