local

package
v0.0.0-...-b4d98a6 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTopNBaseline

func GetTopNBaseline(records []storage.Record, topN int) []storage.Record

GetTopNBaseline 作为 baseline,先排序再取 topN,用来检验其他内存版本算法的正确性

func GetTopNMaxHeap

func GetTopNMaxHeap(records []storage.Record, topN int) []storage.Record

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

func GetTopNParallel(records []storage.Record, topN int, topNFn TopNSolver) []storage.Record

GetTopNParallel 实现了并行版本的调度,传入单核版本算法作为参数,分段计算再合并

func GetTopNQuickSelect

func GetTopNQuickSelect(records []storage.Record, topN int) []storage.Record

GetTopNQuickSelect 基于 quickSort 算法改进,复杂度为

func QuickSelect

func QuickSelect(data sort.Interface, k int)

QuickSelect 基于 sort.Sort 修改,主要是将原版 quickSort 的停止条件修改为找到第 k 大的数为止,借用 doPivot 函数选择较好的 pivot

func Run

func Run()

Types

type TopNSolver

type TopNSolver func(records []storage.Record, topN int) []storage.Record

Jump to

Keyboard shortcuts

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