vector-quicksort-0.1: Fast and flexible quicksort implementation for mutable vectors
Copyright(c) Sergey Vinokurov 2023
LicenseApache-2.0 (see LICENSE)
Maintainerserg.foo@gmail.com
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Vector.Algorithms.FixedSort

Description

Sorts for fixed number of elements. Mostly helpers for quicksort

Synopsis

Documentation

sort3 :: (PrimMonad m, MVector v a, Ord a) => v (PrimState m) a -> m () Source #

Sorts the elements at the three given indices. The indices are assumed to be given from lowest to highest, so if 'l < m < u' then 'sort3ByIndex cmp a m l u' essentially sorts the median of three into the lowest position in the array.

sort4 :: (PrimMonad m, MVector v a, Ord a) => v (PrimState m) a -> m () Source #

Sorts the elements at the four given indices. Like the 2 and 3 element versions, this assumes that the indices are given in increasing order, so it can be used to sort medians into particular positions and so on.

bitonicSort Source #

Arguments

:: forall m v a. (PrimMonad m, Ord a, MVector v a) 
=> Int

Vector length

-> v (PrimState m) a

Vector to be sorted

-> m () 

Sorts vectors containing strictly less that 17 elements. Otherwise does nothing.

Depending on GHC may be good candidate for SPECIALIZE pragma.