Safe Haskell | None |
---|

- data MVector
- type IOVector = MVector RealWorld
- type STVector = MVector
- length :: MVector u a => u s a -> Int
- null :: MVector u a => u s a -> Bool
- slice :: Mixed u v a => Int -> Int -> u s a -> MVector s a
- init :: Mixed u v a => u s a -> MVector s a
- tail :: Mixed u v a => u s a -> MVector s a
- take :: Mixed u v a => Int -> u s a -> MVector s a
- drop :: Mixed u v a => Int -> u s a -> MVector s a
- splitAt :: Mixed u v a => Int -> u s a -> (MVector s a, MVector s a)
- unsafeSlice :: Mixed u v a => Int -> Int -> u s a -> MVector s a
- unsafeInit :: Mixed u v a => u s a -> MVector s a
- unsafeTail :: Mixed u v a => u s a -> MVector s a
- unsafeTake :: Mixed u v a => Int -> u s a -> MVector s a
- unsafeDrop :: Mixed u v a => Int -> u s a -> MVector s a
- overlaps :: (Mixed u v a, Mixed u' v' a) => u s a -> u' s a -> Bool
- replicateM :: PrimMonad m => Int -> m a -> m (MVector (PrimState m) a)
- move :: (PrimMonad m, Mixed u v a, Mixed u' v' a) => u (PrimState m) a -> u' (PrimState m) a -> m ()
- unsafeMove :: (PrimMonad m, Mixed u v a, Mixed u' v' a) => u (PrimState m) a -> u' (PrimState m) a -> m ()
- new :: PrimMonad m => Int -> m (MVector (PrimState m) a)
- unsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) a)
- replicate :: PrimMonad m => Int -> a -> m (MVector (PrimState m) a)
- clone :: (PrimMonad m, Mixed u v a) => u (PrimState m) a -> m (MVector (PrimState m) a)
- grow :: (PrimMonad m, Mixed u v a) => u (PrimState m) a -> Int -> m (MVector (PrimState m) a)
- unsafeGrow :: (PrimMonad m, Mixed u v a) => u (PrimState m) a -> Int -> m (MVector (PrimState m) a)
- clear :: (PrimMonad m, MVector u a) => u (PrimState m) a -> m ()
- read :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> m a
- write :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> a -> m ()
- swap :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> Int -> m ()
- unsafeRead :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> m a
- unsafeWrite :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> a -> m ()
- unsafeSwap :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> Int -> m ()
- set :: (PrimMonad m, MVector u a) => u (PrimState m) a -> a -> m ()
- copy :: (PrimMonad m, Mixed u v a, Mixed u' v' a) => u (PrimState m) a -> u' (PrimState m) a -> m ()
- unsafeCopy :: (PrimMonad m, Mixed u v a, Mixed u' v' a) => u (PrimState m) a -> u' (PrimState m) a -> m ()

# Documentation

A `MVector s a`

is mutable vector that could have any vector type underneath

# Accessors

## Length information

## Extracting subvectors

slice :: Mixed u v a => Int -> Int -> u s a -> MVector s aSource

Yield a part of the mutable vector without copying it.

Yield a part of the mutable vector without copying it. No bounds checks are performed.

unsafeInit :: Mixed u v a => u s a -> MVector s aSource

unsafeTail :: Mixed u v a => u s a -> MVector s aSource

unsafeTake :: Mixed u v a => Int -> u s a -> MVector s aSource

unsafeDrop :: Mixed u v a => Int -> u s a -> MVector s aSource

## Overlapping

# Construction

replicateM :: PrimMonad m => Int -> m a -> m (MVector (PrimState m) a)Source

Create a mutable vector of the given length (0 if the length is negative) and fill it with values produced by repeatedly executing the monadic action.

move :: (PrimMonad m, Mixed u v a, Mixed u' v' a) => u (PrimState m) a -> u' (PrimState m) a -> m ()Source

Move the contents of a vector. The two vectors must have the same length.

If the vectors do not overlap, then this is equivalent to `copy`

.
Otherwise, the copying is performed as if the source vector were
copied to a temporary vector and then the temporary vector was copied
to the target vector.

:: (PrimMonad m, Mixed u v a, Mixed u' v' a) | |

=> u (PrimState m) a | target |

-> u' (PrimState m) a | source |

-> m () |

Move the contents of a vector. The two vectors must have the same length, but this is not checked.

If the vectors do not overlap, then this is equivalent to `unsafeCopy`

.
Otherwise, the copying is performed as if the source vector were
copied to a temporary vector and then the temporary vector was copied
to the target vector.

## Initialisation

new :: PrimMonad m => Int -> m (MVector (PrimState m) a)Source

Create a mutable vector of the given length.

unsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) a)Source

Create a mutable vector of the given length. The length is not checked.

replicate :: PrimMonad m => Int -> a -> m (MVector (PrimState m) a)Source

Create a mutable vector of the given length (0 if the length is negative) and fill it with an initial value.

clone :: (PrimMonad m, Mixed u v a) => u (PrimState m) a -> m (MVector (PrimState m) a)Source

Create a copy of a mutable vector.

## Growing

grow :: (PrimMonad m, Mixed u v a) => u (PrimState m) a -> Int -> m (MVector (PrimState m) a)Source

Grow a vector by the given number of elements. The number must be positive.

unsafeGrow :: (PrimMonad m, Mixed u v a) => u (PrimState m) a -> Int -> m (MVector (PrimState m) a)Source

Grow a vector by the given number of elements. The number must be positive but this is not checked.

## Restricting memory usage

clear :: (PrimMonad m, MVector u a) => u (PrimState m) a -> m ()Source

Reset all elements of the vector to some undefined value, clearing all references to external objects. This is usually a noop for unboxed vectors.

# Accessing individual elements

read :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> m aSource

Yield the element at the given position.

write :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> a -> m ()Source

Replace the element at the given position.

swap :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> Int -> m ()Source

Swap the elements at the given positions.

unsafeRead :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> m aSource

Yield the element at the given position. No bounds checks are performed.

unsafeWrite :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> a -> m ()Source

Replace the element at the given position. No bounds checks are performed.

unsafeSwap :: (PrimMonad m, MVector u a) => u (PrimState m) a -> Int -> Int -> m ()Source

Swap the elements at the given positions. No bounds checks are performed.

# Modifying vectors

## Filling and copying

set :: (PrimMonad m, MVector u a) => u (PrimState m) a -> a -> m ()Source

Set all elements of the vector to the given value.