-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Dynamic growable resizable mutable generic vector -- -- Dynamic, growable, resizable, mutable and generic vector -- implementation @package data-vector-growable @version 0 module Data.Vector.Growable -- | Growable is a dynamic vector based on mutable vector -- v. data Growable v s a type GrowableVector = Growable MVector type GrowableUnboxedVector = Growable MVector type GrowableStorableVector = Growable MVector type GrowableIOVector = Growable MVector RealWorld type GrowableUnboxedIOVector = Growable MVector RealWorld type GrowableStorableIOVector = Growable MVector RealWorld -- | Create an empty vector new :: (PrimMonad m, MVector v a) => m (Growable v (PrimState m) a) -- | Create an empty vector with the given number of pre-allocated -- elements. withCapacity :: (PrimMonad m, MVector v a) => Int -> m (Growable v (PrimState m) a) -- | Create a vector and fill with the initial value. replicate :: (PrimMonad m, MVector v a) => Int -> a -> m (Growable v (PrimState m) a) -- | Like replicate, but initialises the elements by running the -- action repeatedly replicateM :: (PrimMonad m, MVector v a) => Int -> m a -> m (Growable v (PrimState m) a) -- | Append an element to the vector (not atomic). push :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> a -> m () -- | Pop the last element. Returns Nothing if the vector is empty. pop :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> m (Maybe a) -- | Get the length of the vector. length :: PrimMonad m => Growable v (PrimState m) a -> m Int -- | Returns True if the vector is empty null :: PrimMonad m => Growable v (PrimState m) a -> m Bool -- | May throw IndexOutOfBounds read :: (PrimMonad m, MVector v a, MonadThrow m) => Growable v (PrimState m) a -> Int -> m a -- | Throws IndexOutOfBounds if the index is larger than the size. write :: (PrimMonad m, MVector v a, MonadThrow m) => Growable v (PrimState m) a -> Int -> a -> m () modify :: (PrimMonad m, MVector v a, MonadThrow m) => Growable v (PrimState m) a -> (a -> a) -> Int -> m () -- | Thaw an immutable vector and create a Growable one. thaw :: (Vector v a, PrimMonad m) => v a -> m (Growable (Mutable v) (PrimState m) a) -- | Take a snapshot of a Growable vector. freeze :: (Vector v a, PrimMonad m) => Growable (Mutable v) (PrimState m) a -> m (v a) -- | Take a snapshot of a Growable vector. The original vector may -- not be used. unsafeFreeze :: (Vector v a, PrimMonad m) => Growable (Mutable v) (PrimState m) a -> m (v a) -- | Turn Growable vector into a regular mutable vector. fromGrowable :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> m (v (PrimState m) a) -- | Create a Growable vector from a mutable vector. toGrowable :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m (Growable v (PrimState m) a)