Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Deque a
- fromStrict :: Deque a -> Deque a
- toStrict :: Deque a -> Deque a
- fromConsAndSnocLists :: [a] -> [a] -> Deque a
- cons :: a -> Deque a -> Deque a
- snoc :: a -> Deque a -> Deque a
- reverse :: Deque a -> Deque a
- shiftLeft :: Deque a -> Deque a
- shiftRight :: Deque a -> Deque a
- filter :: (a -> Bool) -> Deque a -> Deque a
- take :: Int -> Deque a -> Deque a
- drop :: Int -> Deque a -> Deque a
- takeWhile :: (a -> Bool) -> Deque a -> Deque a
- dropWhile :: (a -> Bool) -> Deque a -> Deque a
- span :: (a -> Bool) -> Deque a -> (Deque a, Deque a)
- uncons :: Deque a -> Maybe (a, Deque a)
- unsnoc :: Deque a -> Maybe (a, Deque a)
- null :: Deque a -> Bool
- head :: Deque a -> Maybe a
- last :: Deque a -> Maybe a
- tail :: Deque a -> Deque a
- init :: Deque a -> Deque a
Documentation
Lazy double-ended queue (aka Dequeue or Deque) based on head-tail linked list.
Instances
fromStrict :: Deque a -> Deque a Source #
Convert strict deque to lazy deque.
fromConsAndSnocLists :: [a] -> [a] -> Deque a Source #
\(\mathcal{O}(1)\). Construct from cons and snoc lists.
shiftLeft :: Deque a -> Deque a Source #
\(\mathcal{O}(1)\), occasionally \(\mathcal{O}(n)\). Move the first element to the end.
λ toList . shiftLeft $ fromList [1,2,3] [2,3,1]
shiftRight :: Deque a -> Deque a Source #
\(\mathcal{O}(1)\), occasionally \(\mathcal{O}(n)\). Move the last element to the beginning.
λ toList . shiftRight $ fromList [1,2,3] [3,1,2]
filter :: (a -> Bool) -> Deque a -> Deque a Source #
\(\mathcal{O}(n)\). Leave only the elements satisfying the predicate.
take :: Int -> Deque a -> Deque a Source #
\(\mathcal{O}(n)\). Leave only the specified amount of first elements.
drop :: Int -> Deque a -> Deque a Source #
\(\mathcal{O}(n)\). Drop the specified amount of first elements.
takeWhile :: (a -> Bool) -> Deque a -> Deque a Source #
\(\mathcal{O}(n)\). Leave only the first elements satisfying the predicate.
dropWhile :: (a -> Bool) -> Deque a -> Deque a Source #
\(\mathcal{O}(n)\). Drop the first elements satisfying the predicate.
uncons :: Deque a -> Maybe (a, Deque a) Source #
\(\mathcal{O}(1)\), occasionally \(\mathcal{O}(n)\). Get the first element and deque without it if it's not empty.
unsnoc :: Deque a -> Maybe (a, Deque a) Source #
\(\mathcal{O}(1)\), occasionally \(\mathcal{O}(n)\). Get the last element and deque without it if it's not empty.
head :: Deque a -> Maybe a Source #
\(\mathcal{O}(1)\), occasionally \(\mathcal{O}(n)\). Get the first element if deque is not empty.
last :: Deque a -> Maybe a Source #
\(\mathcal{O}(1)\), occasionally \(\mathcal{O}(n)\). Get the last element if deque is not empty.