minilight-0.5.0: A SDL2-based graphics library, batteries-included.
Safe HaskellNone
LanguageHaskell2010

Data.Vector.Mutable.PushBack

Description

This module provides a variant of the vector, equipped with push_back operation. IOVector here are supposed to be used in single thread situation.

Synopsis

Documentation

data IOVector a Source #

IOVector consists of (1) pointer to the underlying vector (2) length While Vector has the underlying array itself, this type only has the pointer. This means read/write should be slower than the original vector.

Constructors

IOVector !(IORef (IOVector a)) !(IOVector Int) 

read :: IOVector a -> Int -> IO a Source #

safeLength :: IOVector a -> IO Int Source #

Get the position of the last cell in the IOVector. This operation is not safe because of the unsafePerformIO.

capacity :: IOVector a -> Int Source #

Get the capacity of the IOVector. This operation is not safe because of the unsafePerformIO.

write :: IOVector a -> Int -> a -> IO () Source #

insert Source #

Arguments

:: IOVector a

The vector should have positive (non-zero) length

-> Int 
-> a 
-> IO () 

O(n) Insert a value into any place. This is a slow operation.

delete :: IOVector a -> Int -> IO () Source #

O(n) This is a slow operation. This also throws an exception if the specified index does not exist.

push :: IOVector a -> a -> IO () Source #

fromList :: [a] -> IO (IOVector a) Source #