Data.Vector.Algorithms

vector-algorithms-0.9.0.1: Efficient algorithms for vector arrays

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Vector.Algorithms

Synopsis

- nub :: forall v e. (Vector v e, Ord e) => v e -> v e
- nubBy :: forall v e. Vector v e => Comparison e -> v e -> v e
- nubByMut :: forall m v e. (PrimMonad m, MVector v e) => (Comparison e -> v (PrimState m) e -> m (v (PrimState m) e)) -> Comparison e -> v (PrimState m) e -> m (v (PrimState m) e)

# Documentation

nub :: forall v e. (Vector v e, Ord e) => v e -> v e #

The `nub` function which removes duplicate elements from a vector.

nubBy :: forall v e. Vector v e => Comparison e -> v e -> v e #

A version of `nub` with a custom comparison predicate.

Note: This function makes use of `sortByUniq` using the intro sort algorithm.

nubByMut :: forall m v e. (PrimMonad m, MVector v e) => (Comparison e -> v (PrimState m) e -> m (v (PrimState m) e)) -> Comparison e -> v (PrimState m) e -> m (v (PrimState m) e) #

The `nubByMut` function takes in an in-place sort algorithm and uses it to do a de-deduplicated sort. It then uses this to remove duplicate elements from the input.

Note: Since this algorithm needs the original input and so copies before sorting in-place. As such, it is safe to use on immutable inputs.