doc: update document for algorithm package

This commit is contained in:
dudaodong
2022-12-29 15:32:47 +08:00
parent 39c576248c
commit b5f7b0e670
6 changed files with 88 additions and 33 deletions

View File

@@ -1,7 +1,6 @@
// Copyright 2021 dudaodong@gmail.com. All rights reserved.
// Use of this source code is governed by MIT license
// Package algorithm contain some basic algorithm functions. eg. sort, search
package algorithm
import "github.com/duke-git/lancet/v2/lancetconstraints"
@@ -35,7 +34,7 @@ func InsertionSort[T any](slice []T, comparator lancetconstraints.Comparator) {
}
// SelectionSort applys the selection sort algorithm to sort the collection, will change the original collection data.
// Play:
// Play: https://go.dev/play/p/oXovbkekayS
func SelectionSort[T any](slice []T, comparator lancetconstraints.Comparator) {
for i := 0; i < len(slice); i++ {
min := i