feat(Go-Tool):

2021/02/23:删除linq包使用示例,修改二进制工具与单测类,修改lomuto划分,修改前缀树与单测类,修改时间比较工具
This commit is contained in:
Huangzj
2021-02-23 10:57:41 +08:00
parent 39cee0ce6a
commit 74dd19c675
14 changed files with 98 additions and 794 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ func LomutoPartition(list []int, start int, end int) int {
if list[i] < compareValue {
moveSubscript++
charge++
list[moveSubscript], list[i] = list[i], list[moveSubscript]
list[moveSubscript], list[i] = list[i], list[moveSubscript] //交换元素
}
}
charge++
+17 -8
View File
@@ -13,17 +13,26 @@ import (
func TestPartition(t *testing.T) {
list := []int{99, 1, 2, 3, 4, 100, 200, 90, 5}
s := LomutoPartition(list, 0, 9-1)
fmt.Println(fmt.Sprintf("当前第一个元素应该存在位置为:%d", s))
for _, r := range list {
fmt.Print(r, " ")
for i := 1; i <= len(list); i++ {
s := LomutoPartition(list, 0, len(list)-1)
fmt.Println()
fmt.Println(fmt.Sprintf("当前第一个元素应该存在位置为:%d", s))
for _, r := range list {
fmt.Print(r, " ")
}
}
s = LomutoPartition(list, 0, 9-1)
fmt.Println(fmt.Sprintf("当前第一个元素应该存在位置为:%d", s))
for _, r := range list {
fmt.Print(r, " ")
fmt.Println()
for i := 1; i <= len(list); i++ {
num, _, _ := LomutoQuiteSelect(list, i)
fmt.Println(fmt.Sprintf("第%d个位置的数是:%d", i, num))
}
for i := 0; i < len(list); i++ {
fmt.Println(list[i])
}
}
func doc() string {