gtq/uintslice.go

26 lines
514 B
Go

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 {
if list[i] <= list[j] {
return true
}
return false
}
// Swap helps fulfill sort.Interface
func (list UIntSlice) Swap(i, j int) {
tmp := list[i]
list[i] = list[j]
list[j] = tmp
}