-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Mutable vector with efficient appends
--
-- Mutable vector with efficient updates. Simple implementation on
-- partially filled array with capacity tracking and resizing.
@package grow-vector
@version 0.1.2.0
-- | Module defines mutable vector that can grow in size automatically when
-- an user adds new elements at the end of vector.
--
-- We reallocate vector with 1.5x length to get amortized append.
module Data.Vector.Grow.Unboxed
-- | Grow vector that is wrap around mutable vector. We allocate partially
-- filled vector and grow it when there is no more space for new element.
data GrowVector s a
GrowVector :: !MutVar s (MVector s a) -> !MutVar s Int -> GrowVector s a
[growVector] :: GrowVector s a -> !MutVar s (MVector s a)
[growVectorLength] :: GrowVector s a -> !MutVar s Int
-- | Synonim for GrowVector in IO monad
type IOGrowVector a = GrowVector RealWorld a
-- | Return current amount of elements in the vector
length :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> m Int
-- | Return True if there is no elements inside the vector
null :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> m Bool
-- | Return current capacity of the vector (amount of elements that it can
-- fit without realloc)
capacity :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> m Int
-- | Allocation of new growable vector with given capacity.
new :: (Unbox a, PrimMonad m) => Int -> m (GrowVector (PrimState m) a)
-- | Allocation of new growable vector with given filled size and capacity.
-- Elements is not initialized. Capacity must be greater than filled
-- size.
newSized :: (Unbox a, PrimMonad m) => Int -> Int -> m (GrowVector (PrimState m) a)
-- | Yield a part of mutable vector without copying it. The vector must
-- contain at least i+n elements.
slice :: (Unbox a, PrimMonad m) => Int -> Int -> GrowVector (PrimState m) a -> m (GrowVector (PrimState m) a)
-- | Convert immutable vector to grow mutable version. Doesn't allocate
-- additonal memory for appending, use ensure to add capacity to
-- the vector.
thaw :: (Unbox a, PrimMonad m) => Vector a -> m (GrowVector (PrimState m) a)
-- | Freezing growable vector. It will contain only actual elements of the
-- vector not including capacity space, but you should call force
-- on resulting vector to not hold the allocated capacity of original
-- vector in memory.
freeze :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> m (Vector a)
-- | Ensure that grow vector has at least given capacity possibly with
-- reallocation.
ensure :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> Int -> m ()
-- | Ensure that grow vector has enough space for additonal n elements. We
-- grow vector by 1.5 factor or by required elements count * 1.5.
ensureAppend :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> Int -> m ()
-- | Read element from vector at given index.
read :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> Int -> m a
-- | Write down element in the vector at given index.
write :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> Int -> a -> m ()
-- | Read element from vector at given index.
unsafeRead :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> Int -> m a
-- | Write down element in the vector at given index.
unsafeWrite :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> Int -> a -> m ()
-- | O(1) amortized appending to vector
pushBack :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> a -> m ()
-- | O(1) amortized appending to vector. Doesn't reallocate vector, so
-- there must by capacity - length >= 1.
unsafePushBack :: (Unbox a, PrimMonad m) => GrowVector (PrimState m) a -> a -> m ()
instance GHC.Generics.Generic (Data.Vector.Grow.Unboxed.GrowVector s a)