| Copyright | (c) 2008 Jed Brown |
|---|---|
| License | BSD-style |
| Maintainer | jed@59A2.org |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell98 |
Data.Array.IOCArray
Description
This module provides both the mutable IOCArray which uses pinned memory on
the GC'd heap. Elements are stored according to the class Storable. You
can obtain a pointer to the array contents to manipulate elements from
languages like C.
IOCArray is 16-byte aligned by default. If you create a IOCArray with
unsafeForeignPtrToIOCArray then it may not be aligned. This will be an
issue if you intend to use SIMD instructions.
IOCArray is equivalent to StorableArray and similar
to IOUArray but slower. IOCArray has O(1) versions of
unsafeFreeze and unsafeThaw when converting to/from CArray.
- data IOCArray i e
- withIOCArray :: IOCArray i e -> (Ptr e -> IO a) -> IO a
- touchIOCArray :: IOCArray i e -> IO ()
- unsafeForeignPtrToIOCArray :: Ix i => ForeignPtr e -> (i, i) -> IO (IOCArray i e)
- module Data.Array.MArray
IOCArray type
Absolutely equivalent representation, but used for the mutable interface.
Foreign support
touchIOCArray :: IOCArray i e -> IO () Source #
If you want to use it afterwards, ensure that you
touchCArray after the last use of the pointer,
so the array is not freed too early.
unsafeForeignPtrToIOCArray :: Ix i => ForeignPtr e -> (i, i) -> IO (IOCArray i e) Source #
O(1) Construct a CArray from an arbitrary ForeignPtr. It is
the caller's responsibility to ensure that the ForeignPtr points to
an area of memory sufficient for the specified bounds.
The overloaded mutable array interface
module Data.Array.MArray