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 {
|
2022-02-18 20:09:52 +00:00
|
|
|
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
|
|
|
|
}
|