diff --git a/docs/algorithm.md b/docs/algorithm.md index fdaf583..6cb2b05 100644 --- a/docs/algorithm.md +++ b/docs/algorithm.md @@ -21,18 +21,23 @@ import (
## Index -- [BubbleSort](#BubbleSort) -- [CountSort](#CountSort) -- [HeapSort](#HeapSort) -- [InsertionSort](#InsertionSort) -- [MergeSort](#MergeSort) -- [QuickSort](#QuickSort) -- [SelectionSort](#SelectionSort) -- [ShellSort](#ShellSort) -- [BinarySearch](#BinarySearch) -- [BinaryIterativeSearch](#BinaryIterativeSearch) -- [LinearSearch](#LinearSearch) -- [LRUCache](#LRUCache) +- [Algorithm](#algorithm) + - [Source](#source) + - [Usage](#usage) + - [Index](#index) + - [Documentation](#documentation) + - [BubbleSort](#bubblesort) + - [InsertionSort](#insertionsort) + - [SelectionSort](#selectionsort) + - [ShellSort](#shellsort) + - [QuickSort](#quicksort) + - [HeapSort](#heapsort) + - [MergeSort](#mergesort) + - [CountSort](#countsort) + - [BinarySearch](#binarysearch) + - [BinaryIterativeSearch](#binaryiterativesearch) + - [LinearSearch](#linearsearch) + - [LRUCache](#lrucache)
@@ -46,7 +51,7 @@ import ( Signature: ```go -func BubbleSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func BubbleSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -76,9 +81,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.BubbleSort(intSlice, comparator) + algorithm.BubbleSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -91,7 +96,7 @@ func main() { Signature: ```go -func InsertionSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func InsertionSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -141,9 +146,9 @@ func main() { {Name: "e", Age: 28}, } comparator := &peopleAgeComparator{} - sortedPeople := algorithm.InsertionSort(peoples, comparator) + algorithm.InsertionSort(peoples, comparator) - fmt.Println(sortedSlice) //[{d 8} {b 10} {c 17} {a 20} {e 28}] + fmt.Println(peoples) //[{d 8} {b 10} {c 17} {a 20} {e 28}] } ``` @@ -156,7 +161,7 @@ func main() { Signature: ```go -func SelectionSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func SelectionSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -186,9 +191,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.SelectionSort(intSlice, comparator) + algorithm.SelectionSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -201,7 +206,7 @@ func main() { Signature: ```go -func ShellSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func ShellSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -231,9 +236,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.ShellSort(intSlice, comparator) + algorithm.ShellSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -246,7 +251,7 @@ func main() { Signature: ```go -func QuickSort[T any](slice []T, lowIndex, highIndex int, comparator lancetconstraints.Comparator) []T +func QuickSort[T any](slice []T, lowIndex, highIndex int, comparator lancetconstraints.Comparator) ``` Example: @@ -276,9 +281,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.QuickSort(intSlice, 0, len(intSlice)-1, comparator) + algorithm.QuickSort(intSlice, 0, len(intSlice)-1, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -291,7 +296,7 @@ func main() { Signature: ```go -func HeapSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func HeapSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -321,9 +326,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.HeapSort(intSlice, comparator) + algorithm.HeapSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -336,7 +341,7 @@ func main() { Signature: ```go -func MergeSort[T any](slice []T, lowIndex, highIndex int, comparator lancetconstraints.Comparator) []T +func MergeSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -366,9 +371,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.MergeSort(intSlice, 0, len(intSlice)-1, comparator) + algorithm.MergeSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` diff --git a/docs/algorithm_zh-CN.md b/docs/algorithm_zh-CN.md index 1334a67..412dd5d 100644 --- a/docs/algorithm_zh-CN.md +++ b/docs/algorithm_zh-CN.md @@ -21,18 +21,23 @@ import (
## 目录 -- [BubbleSort](#BubbleSort) -- [CountSort](#CountSort) -- [HeapSort](#HeapSort) -- [InsertionSort](#InsertionSort) -- [MergeSort](#MergeSort) -- [QuickSort](#QuickSort) -- [SelectionSort](#SelectionSort) -- [ShellSort](#ShellSort) -- [BinarySearch](#BinarySearch) -- [BinaryIterativeSearch](#BinaryIterativeSearch) -- [LinearSearch](#LinearSearch) -- [LRUCache](#LRUCache) +- [Algorithm](#algorithm) + - [源码](#源码) + - [用法](#用法) + - [目录](#目录) + - [文档](#文档) + - [BubbleSort](#bubblesort) + - [InsertionSort](#insertionsort) + - [SelectionSort](#selectionsort) + - [ShellSort](#shellsort) + - [QuickSort](#quicksort) + - [HeapSort](#heapsort) + - [MergeSort](#mergesort) + - [CountSort](#countsort) + - [BinarySearch](#binarysearch) + - [BinaryIterativeSearch](#binaryiterativesearch) + - [LinearSearch](#linearsearch) + - [LRUCache](#lrucache)
@@ -46,7 +51,7 @@ import ( 函数签名: ```go -func BubbleSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func BubbleSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -76,9 +81,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.BubbleSort(intSlice, comparator) + algorithm.BubbleSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -91,7 +96,7 @@ func main() { 函数签名: ```go -func InsertionSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func InsertionSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -141,9 +146,9 @@ func main() { {Name: "e", Age: 28}, } comparator := &peopleAgeComparator{} - sortedPeople := algorithm.InsertionSort(peoples, comparator) + algorithm.InsertionSort(peoples, comparator) - fmt.Println(sortedSlice) //[{d 8} {b 10} {c 17} {a 20} {e 28}] + fmt.Println(intSlice) //[{d 8} {b 10} {c 17} {a 20} {e 28}] } ``` @@ -156,7 +161,7 @@ func main() { 函数签名: ```go -func SelectionSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func SelectionSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -186,9 +191,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.SelectionSort(intSlice, comparator) + algorithm.SelectionSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -201,7 +206,7 @@ func main() { 函数签名: ```go -func ShellSort[T any](slice []T, comparator lancetconstraints.Comparator) []T +func ShellSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -231,9 +236,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.ShellSort(intSlice, comparator) + algorithm.ShellSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -276,9 +281,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.QuickSort(intSlice, 0, len(intSlice)-1, comparator) + algorithm.QuickSort(intSlice, 0, len(intSlice)-1, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -321,9 +326,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.HeapSort(intSlice, comparator) + algorithm.HeapSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ``` @@ -336,7 +341,7 @@ func main() { 函数签名: ```go -func MergeSort[T any](slice []T, lowIndex, highIndex int, comparator lancetconstraints.Comparator) []T +func MergeSort[T any](slice []T, comparator lancetconstraints.Comparator) ``` Example: @@ -366,9 +371,9 @@ func main() { intSlice := []int{2, 1, 5, 3, 6, 4} comparator := &intComparator{} - sortedSlice := algorithm.MergeSort(intSlice, 0, len(intSlice)-1, comparator) + algorithm.MergeSort(intSlice, comparator) - fmt.Println(sortedSlice) //[]int{1, 2, 3, 4, 5, 6} + fmt.Println(intSlice) //[]int{1, 2, 3, 4, 5, 6} } ```