samsort-0.1.0.0: A stable adaptive mergesort implementation
Copyright(c) 2024 Soumik Sarkar
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.SamSort

Description

A stable adaptive mergesort implementation.

The merging strategy used is "2-merge" as described by

Synopsis

Documentation

sortArrayBy Source #

Arguments

:: (a -> a -> Ordering)

comparison

-> MutableArray# s a 
-> Int

offset

-> Int

length

-> ST s () 

\(O(n \log n)\). Sort a slice of a MutableArray# using a comparison function.

The comparison must form a total order, as required by the Ord laws.

offset and length must be valid, i.e.

  • 0 <= offset < array size .
  • 0 <= length .
  • offset + length <= array size .

This function will inline to get the best performance out of statically known comparison functions. To avoid code duplication, create a wrapping definition and reuse it as necessary.

sortIntArrayBy Source #

Arguments

:: (Int -> Int -> Ordering)

comparison

-> MutableByteArray# s 
-> Int

offset in Int#s

-> Int

length in Int#s

-> ST s () 

\(O(n \log n)\). Sort a slice of a MutableByteArray# interpreted as an array of Int#s using a comparison function.

The comparison must form a total order, as required by the Ord laws.

offset and length must be valid, i.e.

  • 0 <= offset < array size .
  • 0 <= length .
  • offset + length <= array size .

This function will inline to get the best performance out of statically known comparison functions. To avoid code duplication, create a wrapping definition and reuse it as necessary.