learning_notes

学习笔记

View project on GitHub

常用的包

sort

type Interface interface {
	// 序列长度
	Len() int
    // 两个元素比较结果
	Less(i, j int) bool
	// 两个元素交换方式
	Swap(i, j int)
}

使用pdqsort算法排序,根据数据量选择 插入排序、快速排序、堆排序。

heap

type Interface interface {
	sort.Interface
	Push(x any)
	Pop() any 
}
// 使用 heap.Init 初始化堆。