Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- data IOVector a = IOVector !(IORef (IOVector a)) !(IOVector Int)
- new :: Int -> IO (IOVector a)
- read :: IOVector a -> Int -> IO a
- safeLength :: IOVector a -> IO Int
- length :: IOVector a -> Int
- safeCapacity :: IOVector a -> IO Int
- capacity :: IOVector a -> Int
- write :: IOVector a -> Int -> a -> IO ()
- insert :: IOVector a -> Int -> a -> IO ()
- delete :: IOVector a -> Int -> IO ()
- push :: IOVector a -> a -> IO ()
- fromList :: [a] -> IO (IOVector a)
- asIOVector :: IOVector a -> IO (IOVector a)
- asUnsafeIOVector :: IOVector a -> IOVector a
Documentation
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.
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
.
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.
asUnsafeIOVector :: IOVector a -> IOVector a Source #