A module containing semi-public StorableVector internals. This exposes the StorableVector representation and low level construction functions. Modules which extend the StorableVector system will need to use this module while ideally most users will be able to make do with the public interface modules.
- data Vector a = SV !(ForeignPtr a) !Int !Int
- unsafeHead :: Storable a => Vector a -> a
- unsafeTail :: Storable a => Vector a -> Vector a
- unsafeLast :: Storable a => Vector a -> a
- unsafeInit :: Storable a => Vector a -> Vector a
- unsafeIndex :: Storable a => Vector a -> Int -> a
- unsafeTake :: Storable a => Int -> Vector a -> Vector a
- unsafeDrop :: Storable a => Int -> Vector a -> Vector a
- create :: Storable a => Int -> (Ptr a -> IO ()) -> IO (Vector a)
- createAndTrim :: Storable a => Int -> (Ptr a -> IO Int) -> IO (Vector a)
- createAndTrim' :: Storable a => Int -> (Ptr a -> IO (Int, Int, b)) -> IO (Vector a, b)
- unsafeCreate :: Storable a => Int -> (Ptr a -> IO ()) -> Vector a
- fromForeignPtr :: ForeignPtr a -> Int -> Vector a
- toForeignPtr :: Vector a -> (ForeignPtr a, Int, Int)
- withStartPtr :: Storable a => Vector a -> (Ptr a -> Int -> IO b) -> IO b
- incPtr :: Storable a => Ptr a -> Ptr a
- inlinePerformIO :: IO a -> a
Vector type and representation
A space-efficient representation of a vector, supporting many efficient operations.
Instances of Eq, Ord, Read, Show, Data, Typeable
Vector index (subscript) operator, starting from 0, returning a
single element. This omits the bounds check, which means there is an
accompanying obligation on the programmer to ensure the bounds are checked in
some other way.
Low level introduction and elimination
Wrapper of mallocForeignPtrArray.
Given the maximum size needed and a function to make the contents
of a Vector, createAndTrim makes the
Vector. The generating
function is required to return the actual final size (<= the maximum
size), and the resulting byte array is realloced to this size.
createAndTrim is the main mechanism for creating custom, efficient Vector functions, using Haskell or C functions to fill the space.
A way of creating Vectors outside the IO monad. The
argument gives the final size of the Vector. Unlike
createAndTrim the Vector is not reallocated if the final size
is less than the estimated size.
O(1) Deconstruct a ForeignPtr from a Vector
Run an action that is initialized with a pointer to the first element to be used.