Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data Deque a = Deque [a] [a]
- fromList :: [a] -> Deque a
- shiftLeft :: Deque a -> Deque a
- shiftRight :: Deque a -> Deque a
- cons :: a -> Deque a -> Deque a
- snoc :: a -> Deque a -> Deque a
- uncons :: Deque a -> Maybe (a, Deque a)
- unsnoc :: Deque a -> Maybe (a, Deque a)
- prepend :: Deque a -> Deque a -> Deque a
- reverse :: Deque a -> Deque a
- head :: Deque a -> Maybe a
- tail :: Deque a -> Deque a
- init :: Deque a -> Deque a
- last :: Deque a -> Maybe a
Documentation
Double-ended queue (aka Dequeue or Deque) based on the head-tail linked list.
Can be cycled. See shiftLeft
and shiftRight
.
Deque [a] [a] |
shiftLeft :: Deque a -> Deque a Source #
O(1), occasionally O(n).
λ toList . shiftLeft $ fromList [1,2,3] [2,3,1]
shiftRight :: Deque a -> Deque a Source #
O(1), occasionally O(n).
λ toList . shiftRight $ fromList [1,2,3] [3,1,2]