Implementations of various algorithms for vector (http://code.haskell.org/~dolio/)
#7partialSort is unsafe
using Data.Vector.Algorithms.Intro.partialSort with a value k greater than the length of the vector will result in out of bounds memory access. This is not documented but it can and will happen. To demonstrate, compiling vector with unsafechecks: true results in an exception thrown:
(import Data.Vector.Unboxed as U, import Data.Vector.Algorithms.Intro as V)
Prelude L U V> U.modify (flip V.partialSort 10) (U.fromList [3,2,1,2])
*** Exception: src/Data/Vector/Algorithms/Optimal.hs:78 (sort3ByIndex): index out of bounds (4,4)- description updated
At the very least the documentation should be updated to indicate this behavior. As accessing garbage memory is no fun to track down.
- description updated