Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | rl@cse.unsw.edu.au |
Generic interface to mutable vectors
- class MVectorPure v a where
- 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)
- update :: MVector v m a => v a -> Stream (Int, a) -> m ()
- reverse :: MVector v m a => v a -> m ()
- map :: MVector v m a => (a -> a) -> v a -> m ()
Documentation
class MVectorPure v a whereSource
Basic pure functions on mutable vectors
Length of the mutable vector
Yield a part of the mutable vector without copying it. No range checks!
Unbox a => MVectorPure (Vector s) a | |
MVectorPure (Vector s) a |
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.
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 all references to external objects
Write the value at each position.
:: v a | target |
-> v a | source |
-> 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!
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
.