aivika-transformers-2.0: Transformers for the Aivika simulation library

CopyrightCopyright (c) 2009-2014, David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Simulation.Aivika.Trans.Vector

Description

Tested with: GHC 7.8.3

It defines a prototype of mutable vectors.

Synopsis

Documentation

data Vector m a Source

A prototype of mutable vector.

newVector :: ProtoArrayMonad m => Session m -> m (Vector m a) Source

Create a new vector within the specified simulation session.

copyVector :: ProtoArrayMonad m => Vector m a -> m (Vector m a) Source

Copy the vector.

vectorCount :: ProtoArrayMonad m => Vector m a -> m Int Source

Return the element count.

appendVector :: ProtoArrayMonad m => Vector m a -> a -> m () Source

Add the specified element to the end of the vector.

readVector :: ProtoArrayMonad m => Vector m a -> Int -> m a Source

Read a value from the vector, where indices are started from 0.

writeVector :: ProtoArrayMonad m => Vector m a -> Int -> a -> m () Source

Set an array item at the specified index which is started from 0.

vectorBinarySearch :: (ProtoArrayMonad m, Ord a) => Vector m a -> a -> m Int Source

Return the index of the specified element using binary search; otherwise, a negated insertion index minus one: 0 -> -0 - 1, ..., i -> -i - 1, ....

vectorInsert :: ProtoArrayMonad m => Vector m a -> Int -> a -> m () Source

Insert the element in the vector at the specified index.

vectorDeleteAt :: ProtoArrayMonad m => Vector m a -> Int -> m () Source

Delete the element at the specified index.

vectorIndex :: (ProtoArrayMonad m, Eq a) => Vector m a -> a -> m Int Source

Return the index of the item or -1.

freezeVector :: ProtoArrayMonad m => Vector m a -> m (Array Int a) Source

Return the elements of the vector in an immutable array.