Documentation ¶
Index ¶
- func GetTopNBaseline(records []storage.Record, topN int) []storage.Record
- func GetTopNMaxHeap(records []storage.Record, topN int) []storage.Record
- func GetTopNMaxHeapWithKeyRange(records []storage.Record, topN int, minKey, maxKey int64) []storage.Record
- func GetTopNParallel(records []storage.Record, topN int, topNFn TopNSolver) []storage.Record
- func GetTopNQuickSelect(records []storage.Record, topN int) []storage.Record
- func QuickSelect(data sort.Interface, k int)
- func Run()
- type TopNSolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTopNBaseline ¶
GetTopNBaseline 作为 baseline,先排序再取 topN,用来检验其他内存版本算法的正确性
func GetTopNMaxHeap ¶
GetTopNMaxHeap 在 records 的前 min(TopN, len(records)) 范围内原地建堆,因此会导致传入数据发生变化
func GetTopNMaxHeapWithKeyRange ¶
func GetTopNMaxHeapWithKeyRange(records []storage.Record, topN int, minKey, maxKey int64) []storage.Record
GetTopNMaxHeapWithKeyRange 只返回 [minKey, maxKey] 范围内的 topN
func GetTopNParallel ¶
GetTopNParallel 实现了并行版本的调度,传入单核版本算法作为参数,分段计算再合并
func GetTopNQuickSelect ¶
GetTopNQuickSelect 基于 quickSort 算法改进,复杂度为
func QuickSelect ¶
QuickSelect 基于 sort.Sort 修改,主要是将原版 quickSort 的停止条件修改为找到第 k 大的数为止,借用 doPivot 函数选择较好的 pivot
Types ¶
Click to show internal directories.
Click to hide internal directories.