vector-algorithms-0.5.2: Efficient algorithms for vector arrays

Portability | Portable
Stability | Experimental
Maintainer | Dan Doel

Data.Vector.Algorithms.Insertion

Description

A simple insertion sort. Though it's O(n^2), its iterative nature can be beneficial for small arrays. It is used to sort small segments of an array by some of the more heavy-duty, recursive algorithms.

Synopsis

- sort :: (PrimMonad m, MVector v e, Ord e) => v (PrimState m) e -> m ()
- sortBy :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> m ()
- sortByBounds :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> Int -> Int -> m ()
- sortByBounds' :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> Int -> Int -> Int -> m ()
- type Comparison e = e -> e -> Ordering

# Documentation

sort :: (PrimMonad m, MVector v e, Ord e) => v (PrimState m) e -> m ()

Sorts an entire array using the default comparison for the type

sortBy :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> m ()

Sorts an entire array using a given comparison

sortByBounds :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> Int -> Int -> m ()

Sorts the portion of an array delimited by [l,u)

sortByBounds' :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> Int -> Int -> Int -> m ()

Sorts the portion of the array delimited by [l,u) under the assumption that [l,m) is already sorted.

type Comparison e = e -> e -> Ordering

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