dashsort

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package dashsort

常见排序算法封装

Common sorting algorithm encapsulation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bubble

func Bubble[T constraints.Ordered](sli []T)

Bubble 冒泡排序:依次两两交换,大的往前冒,不断重复遍历,直到有序

func Bubble2

func Bubble2[T constraints.Ordered](sli []T)

Bubble2 冒泡排序:依次两两交换,大的往前冒,不断重复遍历,直到有序

func Insertion

func Insertion[T constraints.Ordered](sli []T)

Insertion 插入排序:将 b区 中的 val 依次插到 a区中 最合适的位置

func Insertion2

func Insertion2[T constraints.Ordered](sli []T)

Insertion2 插入排序:将 b区 中的 val 依次插到 a区中 最合适的位置

func Quick

func Quick[T constraints.Ordered](sli []T) []T

Quick 快速排序(串行版):

1、先从数列中 取出一个数 作为基准数 val 2、分区过程,将比这个数大的数 全放到它的右边,小于或等于它的数 全放到它的左边 (右找小, 左找大) 3、再对左右区间 重复第二步,直到各区间 只有一个数

func QuickParallel

func QuickParallel[T constraints.Ordered](sli []T) []T

QuickParallel 快速排序(并发版):

1、先从数列中 取出一个数 作为基准数 val 2、分区过程,将比这个数大的数 全放到它的右边,小于或等于它的数 全放到它的左边 (右找小, 左找大) 3、再对左右区间 重复第二步,直到各区间 只有一个数

func Selection

func Selection[T constraints.Ordered](sli []T)

Selection 选择排序:b区 中最小的 val 排到 a区 最后

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL