Copyright | (c) 2008-2010 Dan Doel |
---|---|
Maintainer | Dan Doel |
Stability | Experimental |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 ()
- sortUniq :: (PrimMonad m, MVector v e, Ord e) => v (PrimState m) e -> m (v (PrimState m) e)
- sortBy :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> m ()
- sortUniqBy :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> m (v (PrimState m) e)
- 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 () Source #
Sorts an entire array using the default comparison for the type
sortUniq :: (PrimMonad m, MVector v e, Ord e) => v (PrimState m) e -> m (v (PrimState m) e) Source #
A variant on sort
that returns a vector of unique elements.
sortBy :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> m () Source #
Sorts an entire array using a given comparison
sortUniqBy :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> m (v (PrimState m) e) Source #
A variant on sortBy
which returns a vector of unique elements.
sortByBounds :: (PrimMonad m, MVector v e) => Comparison e -> v (PrimState m) e -> Int -> Int -> m () Source #
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 () Source #
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 Source #
A type of comparisons between two values of a given type.