Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- 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
- new :: (PrimMonad m, MVector v a) => m (Growable v (PrimState m) a)
- withCapacity :: (PrimMonad m, MVector v a) => Int -> m (Growable v (PrimState m) a)
- replicate :: (PrimMonad m, MVector v a) => Int -> a -> m (Growable v (PrimState m) a)
- replicateM :: (PrimMonad m, MVector v a) => Int -> m a -> m (Growable v (PrimState m) a)
- push :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> a -> m ()
- pop :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> m (Maybe a)
- length :: PrimMonad m => Growable v (PrimState m) a -> m Int
- null :: PrimMonad m => Growable v (PrimState m) a -> m Bool
- read :: (PrimMonad m, MVector v a, MonadThrow m) => Growable v (PrimState m) a -> Int -> m a
- 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 :: (Vector v a, PrimMonad m) => v a -> m (Growable (Mutable v) (PrimState m) a)
- freeze :: (Vector v a, PrimMonad m) => Growable (Mutable v) (PrimState m) a -> m (v a)
- unsafeFreeze :: (Vector v a, PrimMonad m) => Growable (Mutable v) (PrimState m) a -> m (v a)
- fromGrowable :: (PrimMonad m, MVector v a) => Growable v (PrimState m) a -> m (v (PrimState m) a)
- toGrowable :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m (Growable v (PrimState m) a)
Documentation
Type synonyms
type GrowableVector = Growable MVector Source #
type GrowableUnboxedVector = Growable MVector Source #
type GrowableStorableVector = Growable MVector Source #
Operations
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.
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 #
May throw IndexOutOfBounds
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.