...
Source file src/sort/slice.go
1
2
3
4
5 package sort
6
7
8
9
10
11
12
13 func Slice(slice interface{}, less func(i, j int) bool) {
14 rv := reflectValueOf(slice)
15 swap := reflectSwapper(slice)
16 length := rv.Len()
17 quickSort_func(lessSwap{less, swap}, 0, length, maxDepth(length))
18 }
19
20
21
22
23
24 func SliceStable(slice interface{}, less func(i, j int) bool) {
25 rv := reflectValueOf(slice)
26 swap := reflectSwapper(slice)
27 stable_func(lessSwap{less, swap}, rv.Len())
28 }
29
30
31
32
33 func SliceIsSorted(slice interface{}, less func(i, j int) bool) bool {
34 rv := reflectValueOf(slice)
35 n := rv.Len()
36 for i := n - 1; i > 0; i-- {
37 if less(i, i-1) {
38 return false
39 }
40 }
41 return true
42 }
43
View as plain text