text-2.0.2: An efficient packed Unicode text type.

Copyright | (c) 2009 2010 2011 Bryan O'Sullivan
License | BSD-style
Maintainer | bos@serpentine.com
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Text.Array

Contents

- Types
- Functions

Description

Packed, unboxed, heap-resident arrays. Suitable for performance critical use, both in terms of large data quantities and high speed.

This module is intended to be imported `qualified`, to avoid name clashes with Prelude functions, e.g.

    import qualified Data.Text.Array as A

The names in this module resemble those in the `Array` family of modules, but are shorter due to the assumption of qualified naming.

Synopsis

- data Array = ByteArray ByteArray#
- data MArray s = MutableByteArray (MutableByteArray# s)
- resizeM :: MArray s -> Int -> ST s (MArray s)
- shrinkM :: MArray s -> Int -> ST s ()
- copyM :: MArray s -> Int -> MArray s -> Int -> Int -> ST s ()
- copyI :: Int -> MArray s -> Int -> Array -> Int -> ST s ()
- copyFromPointer :: MArray s -> Int -> Ptr Word8 -> Int -> ST s ()
- copyToPointer :: Array -> Int -> Ptr Word8 -> Int -> ST s ()
- empty :: Array
- equal :: Array -> Int -> Array -> Int -> Int -> Bool
- compare :: Array -> Int -> Array -> Int -> Int -> Ordering
- run :: (forall s. ST s (MArray s)) -> Array
- run2 :: (forall s. ST s (MArray s, a)) -> (Array, a)
- toList :: Array -> Int -> Int -> [Word8]
- unsafeFreeze :: MArray s -> ST s Array
- unsafeIndex :: Array -> Int -> Word8
- new :: forall s. Int -> ST s (MArray s)
- newPinned :: forall s. Int -> ST s (MArray s)
- newFilled :: Int -> Int -> ST s (MArray s)
- unsafeWrite :: MArray s -> Int -> Word8 -> ST s ()
- tile :: MArray s -> Int -> ST s ()
- getSizeofMArray :: MArray s -> ST s Int

# Types

data Array Source #

Immutable array type.

Constructors

ByteArray ByteArray# |

data MArray s Source #

Mutable array type, for use in the ST monad.

Constructors

MutableByteArray (MutableByteArray# s) |

# Functions

resizeM :: MArray s -> Int -> ST s (MArray s) Source #

Since: text-2.0

shrinkM :: MArray s -> Int -> ST s () Source #

Since: text-2.0

copyM Source #

Arguments

:: MArray s | Destination
-> Int | Destination offset
-> MArray s | Source
-> Int | Source offset
-> Int | Count
-> ST s () |

Copy some elements of a mutable array.

copyI Source #

Arguments

:: Int | Count
-> MArray s | Destination
-> Int | Destination offset
-> Array | Source
-> Int | Source offset
-> ST s () |

Copy some elements of an immutable array.

copyFromPointer Source #

Arguments

:: MArray s | Destination
-> Int | Destination offset
-> Ptr Word8 | Source
-> Int | Count
-> ST s () |

Copy from pointer.

Since: text-2.0

copyToPointer Source #

Arguments

:: Array | Source
-> Int | Source offset
-> Ptr Word8 | Destination
-> Int | Count
-> ST s () |

Copy to pointer.

Since: text-2.0

empty :: Array Source #

An empty immutable array.

equal :: Array -> Int -> Array -> Int -> Int -> Bool Source #

Compare portions of two arrays for equality. No bounds checking is performed.

compare :: Array -> Int -> Array -> Int -> Int -> Ordering Source #

Compare portions of two arrays. No bounds checking is performed.

Since: text-2.0

run :: (forall s. ST s (MArray s)) -> Array Source #

Run an action in the ST monad and return an immutable array of its result.

run2 :: (forall s. ST s (MArray s, a)) -> (Array, a) Source #

Run an action in the ST monad and return an immutable array of its result paired with whatever else the action returns.

toList :: Array -> Int -> Int -> [Word8] Source #

Convert an immutable array to a list.

unsafeFreeze :: MArray s -> ST s Array Source #

Freeze a mutable array. Do not mutate the `MArray` afterwards!

unsafeIndex :: Array -> Int -> Word8 Source #

Unchecked read of an immutable array. May return garbage or crash on an out-of-bounds access.

new :: forall s. Int -> ST s (MArray s) Source #

Create an uninitialized mutable array.

newPinned :: forall s. Int -> ST s (MArray s) Source #

Create an uninitialized mutable pinned array.

Since: text-2.0

newFilled :: Int -> Int -> ST s (MArray s) Source #

Since: text-2.0

unsafeWrite :: MArray s -> Int -> Word8 -> ST s () Source #

Unchecked write of a mutable array. May return garbage or crash on an out-of-bounds access.

tile :: MArray s -> Int -> ST s () Source #

Since: text-2.0

getSizeofMArray :: MArray s -> ST s Int Source #

Since: text-2.0