Copyright | Copyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Tested with: GHC 8.0.1
An imperative vector.
Synopsis
- data Vector m a
- newVector :: MonadRef m => Simulation m (Vector m a)
- copyVector :: MonadRef m => Vector m a -> Event m (Vector m a)
- vectorCount :: MonadRef m => Vector m a -> Event m Int
- appendVector :: MonadRef m => Vector m a -> a -> Event m ()
- readVector :: MonadRef m => Vector m a -> Int -> Event m a
- writeVector :: MonadRef m => Vector m a -> Int -> a -> Event m ()
- vectorBinarySearch :: (MonadRef m, Ord a) => Vector m a -> a -> Event m Int
- vectorInsert :: MonadRef m => Vector m a -> Int -> a -> Event m ()
- vectorDeleteAt :: MonadRef m => Vector m a -> Int -> Event m ()
- vectorDeleteRange :: MonadRef m => Vector m a -> Int -> Int -> Event m ()
- vectorDelete :: (MonadRef m, Eq a) => Vector m a -> a -> Event m Bool
- vectorDeleteBy :: MonadRef m => Vector m a -> (a -> Bool) -> Event m (Maybe a)
- vectorIndex :: (MonadRef m, Eq a) => Vector m a -> a -> Event m Int
- vectorIndexBy :: MonadRef m => Vector m a -> (a -> Bool) -> Event m Int
- vectorContains :: (MonadRef m, Eq a) => Vector m a -> a -> Event m Bool
- vectorContainsBy :: MonadRef m => Vector m a -> (a -> Bool) -> Event m (Maybe a)
- freezeVector :: MonadRef m => Vector m a -> Event m (Array Int a)
Documentation
appendVector :: MonadRef m => Vector m a -> a -> Event m () Source #
Add the specified element to the end of the vector.
readVector :: MonadRef m => Vector m a -> Int -> Event m a Source #
Read a value from the vector, where indices are started from 0.
writeVector :: MonadRef m => Vector m a -> Int -> a -> Event m () Source #
Set an array item at the specified index which is started from 0.
vectorBinarySearch :: (MonadRef m, Ord a) => Vector m a -> a -> Event 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 :: MonadRef m => Vector m a -> Int -> a -> Event m () Source #
Insert the element in the vector at the specified index.
vectorDeleteAt :: MonadRef m => Vector m a -> Int -> Event m () Source #
Delete the element at the specified index.
:: MonadRef m | |
=> Vector m a | the vector |
-> Int | the start index |
-> Int | the count of items to be removed |
-> Event m () |
Delete the specified range of elements.
vectorDelete :: (MonadRef m, Eq a) => Vector m a -> a -> Event m Bool Source #
Remove the specified element and return a flag indicating whether the element was found and removed.
vectorDeleteBy :: MonadRef m => Vector m a -> (a -> Bool) -> Event m (Maybe a) Source #
Remove an element by the specified predicate and return the element if found.
vectorIndex :: (MonadRef m, Eq a) => Vector m a -> a -> Event m Int Source #
Return the index of the item or -1.
vectorIndexBy :: MonadRef m => Vector m a -> (a -> Bool) -> Event m Int Source #
Return an index of the item satisfying the predicate or -1.
vectorContains :: (MonadRef m, Eq a) => Vector m a -> a -> Event m Bool Source #
Detect whether the specified element is contained in the vector.