diff options
Diffstat (limited to 'src/sort/sort.go')
| -rw-r--r-- | src/sort/sort.go | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/sort/sort.go b/src/sort/sort.go index 081b700798..a7304af53d 100644 --- a/src/sort/sort.go +++ b/src/sort/sort.go @@ -8,8 +8,6 @@ // collections. package sort -import "reflect" - // A type, typically a collection, that satisfies sort.Interface can be // sorted by the routines in this package. The methods require that the // elements of the collection be enumerated by an integer index. @@ -238,43 +236,6 @@ type lessSwap struct { Swap func(i, j int) } -// Slice sorts the provided slice given the provided less function. -// -// The sort is not guaranteed to be stable. For a stable sort, use -// SliceStable. -// -// The function panics if the provided interface is not a slice. -func Slice(slice interface{}, less func(i, j int) bool) { - rv := reflect.ValueOf(slice) - swap := reflect.Swapper(slice) - length := rv.Len() - quickSort_func(lessSwap{less, swap}, 0, length, maxDepth(length)) -} - -// SliceStable sorts the provided slice given the provided less -// function while keeping the original order of equal elements. -// -// The function panics if the provided interface is not a slice. -func SliceStable(slice interface{}, less func(i, j int) bool) { - rv := reflect.ValueOf(slice) - swap := reflect.Swapper(slice) - stable_func(lessSwap{less, swap}, rv.Len()) -} - -// SliceIsSorted tests whether a slice is sorted. -// -// The function panics if the provided interface is not a slice. -func SliceIsSorted(slice interface{}, less func(i, j int) bool) bool { - rv := reflect.ValueOf(slice) - n := rv.Len() - for i := n - 1; i > 0; i-- { - if less(i, i-1) { - return false - } - } - return true -} - type reverse struct { // This embedded Interface permits Reverse to use the methods of // another Interface implementation. |
