sort

package
Version: v0.0.0-...-8d7462d Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//SELECT 选择排序
	SELECT uint8 = 1 << iota
	//INSERT 插入排序
	INSERT
	//SHELL 希尔排序
	SHELL
)

Variables

This section is empty.

Functions

func IsSorted

func IsSorted(data Interface) bool

IsSorted reports whether data is sorted.

func Sort

func Sort(data Interface, algo uint8)

Sort sort func

Types

type FuncAPI

type FuncAPI func(data Interface)

FuncAPI 排序函数

type IntSlice

type IntSlice []int

IntSlice attaches the methods of Interface to []int, sorting in increasing order.

func (IntSlice) Len

func (p IntSlice) Len() int

func (IntSlice) Less

func (p IntSlice) Less(i, j int) bool

func (IntSlice) Swap

func (p IntSlice) Swap(i, j int)

type Interface

type Interface interface {
	// Len is the number of elements in the collection.
	Len() int
	// Less reports whether the element with
	// index i should sort before the element with index j.
	Less(i, j int) bool
	// Swap swaps the elements with indexes i and j.
	Swap(i, j int)
}

Interface A type, typically a collection, that satisfies sort.Interface can be sorted by the routines in this package. The methods require that the elements of the collection be enumerated by an integer index. Copy from https://github.com/golang/go/blob/master/src/sort/sort.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL