-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Primitive functions for updating many elements in mutable arrays at once -- -- An collection of functions for working with multiple elements in -- mutable arrays. It is hoped some or all of these functions will be -- included in the array package for GHC 7.2. @package array-utils @version 0.2 module Data.Array.Util -- | updateElems mutates every element in an array while avoiding all -- bounds checks. O(size of arr) -- --
--   >>> arr <- newArray (1,10) 0 :: IO (IOArray Int Int)
--       -- Produces a 1 based array with 10 elements all set to 0.
--   
--   >>> updateElems arr (+ 10)
--       -- Updates all elements to 10
--   
updateElems :: (MArray a e m, Ix i) => (e -> e) -> a i e -> m () -- | The same as updateElems, but also providing the index to the mapping -- function. O(size of arr) updateElemsIx :: (MArray a e m, Ix i) => (i -> e -> e) -> a i e -> m () -- | The same as updateElems but taking a monadic function. O(size of -- arr) updateElemsM :: (MArray a e m, Ix i) => (e -> m e) -> a i e -> m () -- | The same updateElemsIx but taking a monadic function. O(size of -- arr) updateElemsIxM :: (MArray a e m, Ix i) => (i -> e -> m e) -> a i e -> m () -- | Takes a mapping function, and a list of indicies to mutate. -- -- Throws an IndexOutOfBounds exception if any of the indicies are -- out of bounds. In this case the array will be left unmutated. -- O(length xs) updateOn :: (MArray a e m, Ix i) => (e -> e) -> [i] -> a i e -> m () -- | Takes a mapping function which takes an index, and a list of indicies -- to mutate. Throws IndexOutOfBounds exception as -- updateElems' does. O(length xs) updateOnIx :: (MArray a e m, Ix i) => (i -> e -> e) -> [i] -> a i e -> m () -- | Takes a mapping function, and a list of indicies to mutate. Throws an -- IndexOutOfBounds exception if any of the indicies are out of -- bounds. In this case the array will be left unmutated. O(length -- xs) updateOnM :: (MArray a e m, Ix i) => (e -> m e) -> [i] -> a i e -> m () -- | Takes a mapping function which takes an index, and a list of indicies -- to mutate. O(length xs) -- -- Throws IndexOutOfBounds exception as updateElems' -- does. updateOnIxM :: (MArray a e m, Ix i) => (i -> e -> m e) -> [i] -> a i e -> m () -- | Takes an update function f and a tuple of indicies '(start, -- finish)', and applies the function to all elements returned by 'range -- (start, finish)'. -- -- If this is a 2D array, then the area updated will be the box bounded -- by these elements, and the rectangular prism area for a 3D array etc. -- -- Throws an IndexOutOfBounds exception if either of the indicies -- are out of bounds. updateWithin :: (MArray a e m, Ix i) => (e -> e) -> (i, i) -> a i e -> m () -- | Takes an update function f and a tuple of indicies '(start, -- finish)' , and applies the function to all elements returned by range -- (start, finish). -- -- Throws an IndexOutOfBounds exception if either of the indicies -- are out of bounds. updateWithinIx :: (MArray a e m, Ix i, Show i) => (i -> e -> e) -> (i, i) -> a i e -> m () -- | The same as updateWithin but taking a monadic function. -- -- Throws an IndexOutOfBounds exception if either of the indicies -- are out of bounds. updateWithinM :: (MArray a e m, Ix i) => (e -> m e) -> (i, i) -> a i e -> m () -- | The same as updateWithinIx but taking a monadic function. -- -- Throws an IndexOutOfBounds exception if either of the indicies -- are out of bounds. updateWithinIxM :: (MArray a e m, Ix i, Show i) => (i -> e -> m e) -> (i, i) -> a i e -> m () -- | updateSlice mutates every element in an array between a start index -- and an end index. O(size of arr) -- --
--   >>> arr <- newArray (1,10) 0 :: IO (IOArray Int Int)
--       -- Produces a 1 based array with 10 elements all set to 0.
--   
--   >>> updateSlice arr (2,4) (+ 10)
--       -- Updates elements at indexes 2, 3 and 4 to 10
--   
updateSlice :: (MArray a e m, Ix i) => (e -> e) -> (i, i) -> a i e -> m () -- | The same as updateElems but taking a monadic function. O(size of -- arr) updateSliceM :: (MArray a e m, Ix i) => (e -> m e) -> (i, i) -> a i e -> m ()