HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulevector-algorithms-0.9.1.0Haskell2010

Data.Vector.Algorithms.Search

This module implements several methods of searching for indicies to insert elements into a sorted vector.

  • 1 type
  • 15 values
valuebinarySearch
  1. :: (PrimMonad m, MVector v e, Ord e)
  2. => v (PrimState m) e
  3. -> e
  4. -> m Int
#

Finds an index in a given sorted vector at which the given element could be inserted while maintaining the sortedness of the vector.

valuebinarySearchBy
  1. :: (PrimMonad m, MVector v e)
  2. => Comparison e
  3. -> v (PrimState m) e
  4. -> e
  5. -> m Int
#

Finds an index in a given vector, which must be sorted with respect to the given comparison function, at which the given element could be inserted while preserving the vector's sortedness.

valuebinarySearchLBy
  1. :: (PrimMonad m, MVector v e)
  2. => Comparison e
  3. -> v (PrimState m) e
  4. -> e
  5. -> m Int
#

Finds the lowest index in a given vector, which must be sorted with respect to the given comparison function, at which the given element could be inserted while preserving the sortedness.

valuebinarySearchRBy
  1. :: (PrimMonad m, MVector v e)
  2. => Comparison e
  3. -> v (PrimState m) e
  4. -> e
  5. -> m Int
#

Finds the greatest index in a given vector, which must be sorted with respect to the given comparison function, at which the given element could be inserted while preserving the sortedness.

valuebinarySearchP
  1. :: (PrimMonad m, MVector v e)
  2. => e -> Bool
  3. -> v (PrimState m) e
  4. -> m Int
#

Given a predicate that is guaranteed to be monotone on the given vector, finds the first index at which the predicate returns True, or the length of the array if the predicate is false for the entire array.

valuebinarySearchPBounds
  1. :: (PrimMonad m, MVector v e)
  2. => e -> Bool
  3. -> v (PrimState m) e
  4. -> Int
  5. -> Int
  6. -> m Int
#

Given a predicate that is guaranteed to be monotone on the indices [l,u) in a given vector, finds the index in [l,u] at which the predicate turns from False to True (yielding u if the entire interval is False).

valuegallopingSearchLeftP
  1. :: (PrimMonad m, MVector v e)
  2. => e -> Bool
  3. -> v (PrimState m) e
  4. -> m Int
#

Given a predicate that is guaranteed to be monotone on the vector elements in order, finds the index at which the predicate turns from False to True. The length of the vector is returned if the predicate is False for the entire vector.

Begins searching at the start of the vector, in increasing steps of size 2^n.

valuegallopingSearchLeftPBounds
  1. :: (PrimMonad m, MVector v e)
  2. => (e -> Bool)
  3. -> v (PrimState m) e
  4. -> Int

    l

  5. -> Int

    u

  6. -> m Int
#

Given a predicate that is guaranteed to be monotone on the indices [l,u) in a given vector, finds the index in [l,u] at which the predicate turns from False to True (yielding u if the entire interval is False). Begins searching at l, going right in increasing (2^n)-steps.

valuegallopingSearchRightP
  1. :: (PrimMonad m, MVector v e)
  2. => e -> Bool
  3. -> v (PrimState m) e
  4. -> m Int
#

Given a predicate that is guaranteed to be monotone on the vector elements in order, finds the index at which the predicate turns from False to True. The length of the vector is returned if the predicate is False for the entire vector.

Begins searching at the end of the vector, in increasing steps of size 2^n.

valuegallopingSearchRightPBounds
  1. :: (PrimMonad m, MVector v e)
  2. => (e -> Bool)
  3. -> v (PrimState m) e
  4. -> Int

    l

  5. -> Int

    u

  6. -> m Int
#

Given a predicate that is guaranteed to be monotone on the indices [l,u) in a given vector, finds the index in [l,u] at which the predicate turns from False to True (yielding u if the entire interval is False). Begins searching at u, going left in increasing (2^n)-steps.

typetype Comparison e = e -> e -> Ordering
#

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