HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulevector-algorithms-0.9.1.0Haskell2010

Data.Vector.Algorithms.Optimal

Optimal sorts for very small array sizes, or for small numbers of particular indices in a larger array (to be used, for instance, for sorting a median of 3 values into the lowest position in an array for a median-of-3 quicksort).

  • 1 type
  • 6 values
valuesort2ByIndex
  1. :: (PrimMonad m, MVector v e)
  2. => Comparison e
  3. -> v (PrimState m) e
  4. -> Int
  5. -> Int
  6. -> m ()
#

Sorts the elements at the two given indices using the comparison. This is essentially a compare-and-swap, although the first index is assumed to be the lower of the two.

valuesort3ByIndex
  1. :: (PrimMonad m, MVector v e)
  2. => Comparison e
  3. -> v (PrimState m) e
  4. -> Int
  5. -> Int
  6. -> Int
  7. -> m ()
#

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.

valuesort4ByIndex
  1. :: (PrimMonad m, MVector v e)
  2. => Comparison e
  3. -> v (PrimState m) e
  4. -> Int
  5. -> Int
  6. -> Int
  7. -> Int
  8. -> m ()
#

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.

typetype Comparison e = e -> e -> Ordering
#

A type of comparisons between two values of a given type.