Documentation
¶
Index ¶
Constants ¶
const WorkersToSliceLimitRatio = 1.5
WorkersToSliceLimitRatio is the "ideal" ratio between the number of workers and the slice size limit for concurrency Check quicksort.bench package for more informations
Variables ¶
This section is empty.
Functions ¶
func GetIdealSliceSizeLimit ¶
GetIdealSliceSizeLimit will return the best slice size limit for concurrency based on the number of workers and the number of availables cpu cores. Check quicksort.bench package for more informations
func QuickSort ¶
func QuickSort(data QuickSortable)
QuickSort sorts data using the quicksort algo distributed on multiples workers. It is just a high level wrapper which set optimal parameters to QuickSortCustom(). The number of workers will be equal to runtime.NumCPU() and the concurrent limit adapted to the number of workers.
func QuickSortCustom ¶
func QuickSortCustom(data QuickSortable, nbWorkers int, concurrentSliceSizeLimit int)
QuickSortCustom sorts data using the quicksort algo distributed on nbWorkers goroutines nbWorkers allows to specify the number of max goroutines which will be used for concurrency. concurrentSliceSizeLimit sets the minimum slice size limit for concurrency. Check quicksort.bench package readme for more informations.
Types ¶
type IntSlice ¶
type IntSlice []int
IntSlice attaches the methods of Interface to []int, sorting in increasing order.
func (IntSlice) GetSubSliceFrom ¶
func (p IntSlice) GetSubSliceFrom(i int) QuickSortable
func (IntSlice) GetSubSliceTo ¶
func (p IntSlice) GetSubSliceTo(i int) QuickSortable
func (IntSlice) LessOrEqual ¶
type QuickSortable ¶
type QuickSortable interface { Len() int LessOrEqual(i, j int) bool Swap(i, j int) GetSubSliceTo(i int) QuickSortable GetSubSliceFrom(j int) QuickSortable }
QuickSortable is an interface which must be satisfied in order to call QuickSort()