Skip to content

Commit eb28396

Browse files
committed
rename
1 parent a872ae6 commit eb28396

File tree

10 files changed

+17
-18
lines changed

10 files changed

+17
-18
lines changed

demo/sort.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import (
88

99
func main() {
1010
sli := []int{46, 4, 1, 26, 4, 25}
11-
sort.QuickSort(sli)
11+
sort.Quick(sli)
1212
fmt.Println(sli)
1313
}

graphs/digraph_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestDFS_Digraph(t *testing.T) {
124124
func checkDFSResults(t *testing.T, g *Digraph, dfsResults [][]int) {
125125
for src := range dfsResults {
126126
reach := g.ReachableSlice(src)
127-
sort.QuickSort(stdsort.IntSlice(reach))
127+
sort.Quick(stdsort.IntSlice(reach))
128128
if !util.SliceEqual(reach, dfsResults[src]) {
129129
t.Errorf("v %d reach %v not equal %v", src, reach, dfsResults[src])
130130
}

sort/pop_sort.go sort/bubble.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package sort
22

33
import "golang.org/x/exp/constraints"
44

5-
func PopSort[Ord constraints.Ordered](data []Ord) {
5+
func Bubble[Ord constraints.Ordered](data []Ord) {
66
for i := len(data) - 1; i > 0; i-- {
77
for j := 0; j < i; j++ {
88
if data[j] > data[j+1] {

sort/heap_sort.go sort/heap.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package sort
22

33
import "golang.org/x/exp/constraints"
44

5-
func HeapSort[Ord constraints.Ordered](data []Ord) {
5+
func Heap[Ord constraints.Ordered](data []Ord) {
66
adjust(data)
77
for i := len(data) - 1; i > 0; i-- {
88
data[0], data[i] = data[i], data[0]

sort/insert_sort.go sort/insert.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package sort
22

33
import "golang.org/x/exp/constraints"
44

5-
// InsertSort -
6-
func InsertSort[Ord constraints.Ordered](data []Ord) {
5+
func Insert[Ord constraints.Ordered](data []Ord) {
76
for i := 1; i < len(data); i++ {
87
insrtNum := data[i]
98
j := i - 1

sort/merge_sort.go sort/merge.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package sort
22

33
import "golang.org/x/exp/constraints"
44

5-
func MergeSort[Ord constraints.Ordered](data []Ord) {
5+
func Merge[Ord constraints.Ordered](data []Ord) {
66
aux := make([]Ord, len(data))
77
mergeSort(data, aux)
88
}

sort/quick_sort.go sort/quick.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package sort
22

33
import "golang.org/x/exp/constraints"
44

5-
func QuickSort[Ord constraints.Ordered](data []Ord) {
5+
func Quick[Ord constraints.Ordered](data []Ord) {
66
quickSort(data, 0, len(data)-1)
77
}
88

sort/select_sort.go sort/select.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package sort
22

33
import "golang.org/x/exp/constraints"
44

5-
func SelectSort[Ord constraints.Ordered](data []Ord) {
5+
func Select[Ord constraints.Ordered](data []Ord) {
66
for i := 0; i < len(data)-1; i++ {
77
idxMin := i
88
for j := i + 1; j < len(data); j++ {

sort/shell_sort.go sort/shell.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package sort
22

33
import "golang.org/x/exp/constraints"
44

5-
func ShellSort[Ord constraints.Ordered](data []Ord) {
5+
func Shell[Ord constraints.Ordered](data []Ord) {
66
// 使用希尔增量
77
for incre := len(data) >> 1; incre > 1; incre >>= 1 {
88
for i := incre; i < len(data); i++ {
@@ -14,7 +14,7 @@ func ShellSort[Ord constraints.Ordered](data []Ord) {
1414
data[j+incre] = insrtNum
1515
}
1616
}
17-
InsertSort(data)
17+
Insert(data)
1818
}
1919

2020
//func ShellSort(data []int) {

sort/sort_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import (
99
)
1010

1111
func TestContrast(t *testing.T) {
12-
testPerformance(PopSort[int], "PopSort")
13-
testPerformance(SelectSort[int], "SelectSort")
14-
testPerformance(InsertSort[int], "InsertSort")
15-
testPerformance(ShellSort[int], "ShellSort")
16-
testPerformance(MergeSort[int], "MergeSort")
17-
testPerformance(HeapSort[int], "HeapSort")
18-
testPerformance(QuickSort[int], "QuickSort")
12+
testPerformance(Bubble[int], "PopSort")
13+
testPerformance(Select[int], "SelectSort")
14+
testPerformance(Insert[int], "InsertSort")
15+
testPerformance(Shell[int], "ShellSort")
16+
testPerformance(Merge[int], "MergeSort")
17+
testPerformance(Heap[int], "HeapSort")
18+
testPerformance(Quick[int], "QuickSort")
1919

2020
testPerformance(func(p []int) { stdsort.Sort(stdsort.IntSlice(p)) }, "Go library sort.Ints")
2121
}

0 commit comments

Comments
 (0)