vector-0.4: Efficient ArraysSource codeContentsIndex
Data.Vector.Generic.Mutable
Portabilitynon-portable
Stabilityexperimental
MaintainerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Description
Generic interface to mutable vectors
Synopsis
class MVectorPure v a where
length :: v a -> Int
unsafeSlice :: v a -> Int -> Int -> v a
overlaps :: v a -> v a -> Bool
class (Monad m, MVectorPure v a) => MVector v m a where
unsafeNew :: Int -> m (v a)
unsafeNewWith :: Int -> a -> m (v a)
unsafeRead :: v a -> Int -> m a
unsafeWrite :: v a -> Int -> a -> m ()
clear :: v a -> m ()
set :: v a -> a -> m ()
unsafeCopy :: v a -> v a -> m ()
unsafeGrow :: v a -> Int -> m (v a)
slice :: MVectorPure v a => v a -> Int -> Int -> v a
new :: MVector v m a => Int -> m (v a)
newWith :: MVector v m a => Int -> a -> m (v a)
read :: MVector v m a => v a -> Int -> m a
write :: MVector v m a => v a -> Int -> a -> m ()
copy :: MVector v m a => v a -> v a -> m ()
grow :: MVector v m a => v a -> Int -> m (v a)
unstream :: MVector v m a => Stream a -> m (v a)
transform :: MVector v m a => (MStream m a -> MStream m a) -> v a -> m (v a)
accum :: MVector v m a => (a -> b -> a) -> v a -> Stream (Int, b) -> m ()
update :: MVector v m a => v a -> Stream (Int, a) -> m ()
reverse :: MVector v m a => v a -> m ()
Documentation
class MVectorPure v a whereSource
Basic pure functions on mutable vectors
Methods
length :: v a -> IntSource
Length of the mutable vector
unsafeSliceSource
:: v a
-> Intstarting index
-> Intlength of the slice
-> v a
Yield a part of the mutable vector without copying it. No range checks!
overlaps :: v a -> v a -> BoolSource
show/hide Instances
class (Monad m, MVectorPure v a) => MVector v m a whereSource
Class of mutable vectors. The type m is the monad in which the mutable vector can be transformed and a is the type of elements.
Methods
unsafeNew :: Int -> m (v a)Source
Create a mutable vector of the given length. Length is not checked!
unsafeNewWith :: Int -> a -> m (v a)Source
Create a mutable vector of the given length and fill it with an initial value. Length is not checked!
unsafeRead :: v a -> Int -> m aSource
Yield the element at the given position. Index is not checked!
unsafeWrite :: v a -> Int -> a -> m ()Source
Replace the element at the given position. Index is not checked!
clear :: v a -> m ()Source
Clear all references to external objects
set :: v a -> a -> m ()Source
Write the value at each position.
unsafeCopySource
:: v atarget
-> v asource
-> m ()
Copy a vector. The two vectors may not overlap. This is not checked!
unsafeGrow :: v a -> Int -> m (v a)Source
Grow a vector by the given number of elements. The length is not checked!
show/hide Instances
slice :: MVectorPure v a => v a -> Int -> Int -> v aSource
Yield a part of the mutable vector without copying it. Safer version of unsafeSlice.
new :: MVector v m a => Int -> m (v a)Source
Create a mutable vector of the given length. Safer version of unsafeNew.
newWith :: MVector v m a => Int -> a -> m (v a)Source
Create a mutable vector of the given length and fill it with an initial value. Safer version of unsafeNewWith.
read :: MVector v m a => v a -> Int -> m aSource
Yield the element at the given position. Safer version of unsafeRead.
write :: MVector v m a => v a -> Int -> a -> m ()Source
Replace the element at the given position. Safer version of unsafeWrite.
copy :: MVector v m a => v a -> v a -> m ()Source
Copy a vector. The two vectors may not overlap. Safer version of unsafeCopy.
grow :: MVector v m a => v a -> Int -> m (v a)Source
Grow a vector by the given number of elements. Safer version of unsafeGrow.
unstream :: MVector v m a => Stream a -> m (v a)Source
Create a new mutable vector and fill it with elements from the Stream. The vector will grow logarithmically if the Size hint of the Stream is inexact.
transform :: MVector v m a => (MStream m a -> MStream m a) -> v a -> m (v a)Source
accum :: MVector v m a => (a -> b -> a) -> v a -> Stream (Int, b) -> m ()Source
update :: MVector v m a => v a -> Stream (Int, a) -> m ()Source
reverse :: MVector v m a => v a -> m ()Source
Produced by Haddock version 2.4.2