Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Vector a = RootNode {}
- data Node a
- = InternalNode {
- getInternalNode :: !(Array (Node a))
- | DataNode {
- getDataNode :: !(Array a)
- = InternalNode {
- foldr :: (a -> b -> b) -> b -> Vector a -> b
- foldr' :: (a -> b -> b) -> b -> Vector a -> b
- foldl :: (b -> a -> b) -> b -> Vector a -> b
- foldl' :: (b -> a -> b) -> b -> Vector a -> b
- ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b
- ifoldl :: (Int -> b -> a -> b) -> b -> Vector a -> b
- ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> b
- ifoldl' :: (Int -> b -> a -> b) -> b -> Vector a -> b
- persistentVectorEq :: Eq a => Vector a -> Vector a -> Bool
- nodeEq :: Eq a => Node a -> Node a -> Bool
- persistentVectorCompare :: Ord a => Vector a -> Vector a -> Ordering
- nodeCompare :: Ord a => Node a -> Node a -> Ordering
- singleton :: a -> Vector a
- empty :: Vector a
- null :: Vector a -> Bool
- (|>) :: Vector a -> a -> Vector a
- pattern (:|>) :: Vector a -> a -> Vector a
- pattern Empty :: Vector a
- snoc :: Vector a -> a -> Vector a
- unsafeSnoc :: Vector a -> a -> Vector a
- snocArr :: Vector a -> Int -> Array a -> Vector a
- snocTail :: Int -> Array a -> Int -> Array (Node a) -> Array (Node a)
- newPath :: Int -> Array a -> Node a
- unsafeIndex :: Vector a -> Int -> a
- unsafeIndex# :: Vector a -> Int -> (# a #)
- lookup# :: Int -> Vector a -> (# (# #) | a #)
- lookup :: Int -> Vector a -> Maybe a
- index :: HasCallStack => Int -> Vector a -> a
- (!) :: HasCallStack => Vector a -> Int -> a
- (!?) :: Vector a -> Int -> Maybe a
- adjust :: (a -> a) -> Int -> Vector a -> Vector a
- adjust# :: (a -> (# a #)) -> Int -> Vector a -> Vector a
- adjustF :: Applicative f => (a -> f a) -> Int -> Vector a -> f (Vector a)
- update :: Int -> a -> Vector a -> Vector a
- unsnoc :: Vector a -> Maybe (Vector a, a)
- unsnocTail# :: Int -> Int -> Array (Node a) -> (# Array (Node a), Array a #)
- tailOffset :: Vector a -> Int
- length :: Vector a -> Int
- impossibleError :: forall a. a
- moduleError :: forall a. HasCallStack => String -> String -> a
- toList :: Vector a -> [a]
- pureStreamToList :: Stream Identity a -> [a]
- map :: (a -> b) -> Vector a -> Vector b
- imap :: (Int -> a -> b) -> Vector a -> Vector b
- traverse :: Applicative f => (a -> f b) -> Vector a -> f (Vector b)
- itraverse :: Applicative f => (Int -> a -> f b) -> Vector a -> f (Vector b)
- (//) :: Vector a -> [(Int, a)] -> Vector a
- (><) :: Vector a -> Vector a -> Vector a
- invariant :: Vector a -> Bool
- fromList :: [a] -> Vector a
- keyBits :: Int
- nodeWidth :: Int
- keyMask :: Int
- (!<<.) :: Bits a => a -> Int -> a
- (!>>.) :: Bits a => a -> Int -> a
- unstream :: Stream Identity a -> Vector a
- streamToContents :: PrimMonad m => Stream Identity a -> m (Int, SmallArray a, [Node a])
- streamL :: Monad m => Vector a -> Stream m a
- streamR :: Monad m => Vector a -> Stream m a
- istreamL :: Monad m => Vector a -> Stream m (Int, a)
- istreamR :: Monad m => Vector a -> Stream m (Int, a)
Documentation
A vector.
The instances are based on those of Seq
s, which are in turn based on those of lists.
RootNode | Invariants: The only time tail can be empty is when init is empty. Otherwise tailOffset will give the wrong value. |
Instances
InternalNode | |
| |
DataNode | |
|
(|>) :: Vector a -> a -> Vector a Source #
\(O(\log n)\). An alias for snoc
Mnemonic: a triangle with the single element at the pointy end.
pattern (:|>) :: Vector a -> a -> Vector a infixl 5 Source #
\(O(\log n)\). A bidirectional pattern synonym viewing the rear of a non-empty sequence.
pattern Empty :: Vector a Source #
\(O(1)\). A bidirectional pattern synonym matching an empty sequence.
unsafeSnoc :: Vector a -> a -> Vector a Source #
unsafeIndex :: Vector a -> Int -> a Source #
unsafeIndex# :: Vector a -> Int -> (# a #) Source #
lookup :: Int -> Vector a -> Maybe a Source #
\(O(\log n)\). The element at the index or Nothing
if the index is out of range.
index :: HasCallStack => Int -> Vector a -> a Source #
\(O(\log n)\). The element at the index. Calls error
if the index is out of range.
adjust :: (a -> a) -> Int -> Vector a -> Vector a Source #
\(O(\log n)\). Adjust the element at the index by applying the function to it. If the index is out of range, the original vector is returned.
adjustF :: Applicative f => (a -> f a) -> Int -> Vector a -> f (Vector a) Source #
\(O(\log n)\). Same as adjust
but can have effects through Applicative
update :: Int -> a -> Vector a -> Vector a Source #
\(O(\log n)\). Replace the element at the specified position. If the position is out of range, the original sequence is returned.
tailOffset :: Vector a -> Int Source #
The index of the first element of the tail of the vector (that is, the *last* element of the list representing the tail). This is also the number of elements stored in the array tree.
Caution: Only gives a sensible result if the vector is nonempty.
impossibleError :: forall a. a Source #
moduleError :: forall a. HasCallStack => String -> String -> a Source #
map :: (a -> b) -> Vector a -> Vector b Source #
\(O(n)\). Apply a function to all values in the vector.
imap :: (Int -> a -> b) -> Vector a -> Vector b Source #
\(O(n)\). Apply a function to all values of a vector and its index.
(//) :: Vector a -> [(Int, a)] -> Vector a Source #
\(O(n)\). For each pair (i,a)
from the vector of index/value pairs,
replace the vector element at position i
by a
.
update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>
streamToContents :: PrimMonad m => Stream Identity a -> m (Int, SmallArray a, [Node a]) Source #