HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

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).

Synopsis
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.