Data.Vector.Algorithms.Merge

vector-algorithms-0.9.0.1: Efficient algorithms for vector arrays

Copyright | (c) 2008-2011 Dan Doel
Maintainer | Dan Doel <dan.doel@gmail.com>
Stability | Experimental
Portability | Portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Vector.Algorithms.Merge

Description

This module implements a simple top-down merge sort. The temporary buffer is preallocated to 1/2 the size of the input array, and shared through the entire sorting process to ease the amount of allocation performed in total. This is a stable sort.

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)
- type Comparison e = e -> e -> Ordering

# Documentation

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

Sorts an array using the default comparison.

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

A variant on `sort` that returns a vector of unique elements.

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

Sorts an array using a custom comparison.

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

A variant on `sortBy` which returns a vector of unique elements.

type Comparison e = e -> e -> Ordering #

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