data-vector-growable-0: Dynamic growable resizable mutable generic vector
Safe HaskellNone
LanguageHaskell2010

Data.Vector.Growable

Synopsis

Documentation

data Growable v s a Source #

Growable is a dynamic vector based on mutable vector v.

Type synonyms

Operations

new :: (PrimMonad m, MVector v a) => m (Growable v (PrimState m) a) Source #

Create an empty vector

withCapacity :: (PrimMonad m, MVector v a) => Int -> m (Growable v (PrimState m) a) Source #

Create an empty vector with the given number of pre-allocated elements.

replicate :: (PrimMonad m, MVector v a) => Int -> a -> m (Growable v (PrimState m) a) Source #

Create a vector and fill with the initial value.

replicateM :: (PrimMonad m, MVector v a) => Int -> m a -> m (Growable v (PrimState m) a) Source #

Like replicate, but initialises the elements by running the action repeatedly

push :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> a -> m () Source #

Append an element to the vector (not atomic).

pop :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> m (Maybe a) Source #

Pop the last element. Returns Nothing if the vector is empty.

length :: PrimMonad m => Growable v (PrimState m) a -> m Int Source #

Get the length of the vector.

null :: PrimMonad m => Growable v (PrimState m) a -> m Bool Source #

Returns True if the vector is empty

read :: (PrimMonad m, MVector v a, MonadThrow m) => Growable v (PrimState m) a -> Int -> m a Source #

write :: (PrimMonad m, MVector v a, MonadThrow m) => Growable v (PrimState m) a -> Int -> a -> m () Source #

Throws IndexOutOfBounds if the index is larger than the size.

modify :: (PrimMonad m, MVector v a, MonadThrow m) => Growable v (PrimState m) a -> (a -> a) -> Int -> m () Source #

thaw :: (Vector v a, PrimMonad m) => v a -> m (Growable (Mutable v) (PrimState m) a) Source #

Thaw an immutable vector and create a Growable one.

freeze :: (Vector v a, PrimMonad m) => Growable (Mutable v) (PrimState m) a -> m (v a) Source #

Take a snapshot of a Growable vector.

unsafeFreeze :: (Vector v a, PrimMonad m) => Growable (Mutable v) (PrimState m) a -> m (v a) Source #

Take a snapshot of a Growable vector. The original vector may not be used.

fromGrowable :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> m (v (PrimState m) a) Source #

Turn Growable vector into a regular mutable vector.

toGrowable :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m (Growable v (PrimState m) a) Source #

Create a Growable vector from a mutable vector.