Copyright | Copyright (c) 2009-2015, David Sorokin <david.sorokin@gmail.com> |
---|---|

License | BSD3 |

Maintainer | David Sorokin <david.sorokin@gmail.com> |

Stability | experimental |

Safe Haskell | Safe |

Language | Haskell2010 |

Tested with: GHC 7.10.1

An imperative unboxed vector.

- data Vector a
- newVector :: Unboxed a => IO (Vector a)
- copyVector :: Unboxed a => Vector a -> IO (Vector a)
- vectorCount :: Unboxed a => Vector a -> IO Int
- appendVector :: Unboxed a => Vector a -> a -> IO ()
- readVector :: Unboxed a => Vector a -> Int -> IO a
- writeVector :: Unboxed a => Vector a -> Int -> a -> IO ()
- vectorBinarySearch :: (Unboxed a, Ord a) => Vector a -> a -> IO Int
- vectorInsert :: Unboxed a => Vector a -> Int -> a -> IO ()
- vectorDeleteAt :: Unboxed a => Vector a -> Int -> IO ()
- vectorDelete :: (Unboxed a, Eq a) => Vector a -> a -> IO Bool
- vectorDeleteBy :: Unboxed a => Vector a -> (a -> Bool) -> IO Bool
- vectorIndex :: (Unboxed a, Eq a) => Vector a -> a -> IO Int
- vectorIndexBy :: Unboxed a => Vector a -> (a -> Bool) -> IO Int
- vectorContains :: (Unboxed a, Eq a) => Vector a -> a -> IO Bool
- vectorContainsBy :: Unboxed a => Vector a -> (a -> Bool) -> IO (Maybe a)
- freezeVector :: Unboxed a => Vector a -> IO (Array Int a)

# Documentation

appendVector :: Unboxed a => Vector a -> a -> IO () Source

Add the specified element to the end of the vector.

readVector :: Unboxed a => Vector a -> Int -> IO a Source

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

writeVector :: Unboxed a => Vector a -> Int -> a -> IO () Source

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

vectorBinarySearch :: (Unboxed a, Ord a) => Vector a -> a -> IO 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 :: Unboxed a => Vector a -> Int -> a -> IO () Source

Insert the element in the vector at the specified index.

vectorDeleteAt :: Unboxed a => Vector a -> Int -> IO () Source

Delete the element at the specified index.

vectorDelete :: (Unboxed a, Eq a) => Vector a -> a -> IO Bool Source

Remove the specified element and return a flag indicating whether the element was found and removed.

vectorDeleteBy :: Unboxed a => Vector a -> (a -> Bool) -> IO Bool Source

Remove an element by the specified predicate and return a flag indicating whether the element was found and removed.

vectorIndex :: (Unboxed a, Eq a) => Vector a -> a -> IO Int Source

Return the index of the item or -1.

vectorIndexBy :: Unboxed a => Vector a -> (a -> Bool) -> IO Int Source

Return an index of the item satisfying the predicate or -1.

vectorContains :: (Unboxed a, Eq a) => Vector a -> a -> IO Bool Source

Detect whether the specified element is contained in the vector.