Source File
sort.go
Belonging Package
sort
package sort
Len() int
Swap(i, j int)
}
for := ( - 1) / 2; >= 0; -- {
siftDown(, , , )
}
if .Less(, ) {
:= ( - ) / 8
medianOfThree(, , +, +2*)
medianOfThree(, , -, +)
medianOfThree(, -1, -1-, -1-2*)
}
medianOfThree(, , , -1)
.Swap(, -1)
++
--
:= - < 5
= > 1
}
.Swap(, -1)
++
--
}
if - < - {
(, , , )
= // i.e., quickSort(data, mhi, b)
} else {
(, , , )
= // i.e., quickSort(data, a, mlo)
}
}
for := + 6; < ; ++ {
if .Less(, -6) {
.Swap(, -6)
}
}
insertionSort(, , )
}
}
type Float64Slice []float64
func ( Float64Slice) () int { return len() }
func ( Float64Slice) (, int) bool { return [] < [] || (isNaN([]) && !isNaN([])) }
func ( Float64Slice) (, int) { [], [] = [], [] }
func ( Float64Slice) () { Sort() }
type StringSlice []string
func ( StringSlice) () int { return len() }
func ( StringSlice) (, int) bool { return [] < [] }
func ( StringSlice) (, int) { [], [] = [], [] }
func ( StringSlice) () { Sort() }
func ( []float64) { Sort(Float64Slice()) }
func ( []string) { Sort(StringSlice()) }
func ( []float64) bool { return IsSorted(Float64Slice()) }
func ( []string) bool { return IsSorted(StringSlice()) }
func ( Interface) {
stable(, .Len())
}
func ( Interface, int) {
:= 20 // must be > 0
, := 0,
for <= {
insertionSort(, , )
=
+=
}
insertionSort(, , )
for < {
, = 0, 2*
for <= {
symMerge(, , +, )
=
+= 2 *
}
if := + ; < {
symMerge(, , , )
}
*= 2
}
}
for := ; < -1; ++ {
.Swap(, +1)
}
return
}
swapRange(, -, , )
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |