An implementation of double-ended queues supporting access at both
ends in constant amortized time.
Author: Bernd Brassel, Olaf Chitil, Michael Hanus, Sebastian Fischer
Version: October 2006
| Exported names: |
Datatypes:
Queue
Functions:
cons
| deqHead
| deqInit
| deqLast
| deqLength
| deqReverse
| deqTail
| deqToList
| empty
| isEmpty
| listToDeq
| matchHead
| matchLast
| rotate
| snoc
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
The datatype of a queue.
Constructors:
| Exported functions: |
:: Queue a
The empty queue.
:: Queue a -> Bool
Is the queue empty?
:: Queue a -> a
The first element of the queue.
:: Queue a -> a
The last element of the queue.
:: a -> Queue a -> Queue a
Inserts an element at the front of the queue.
:: Queue a -> Queue a
Removes an element at the front of the queue.
:: a -> Queue a -> Queue a
Inserts an element at the end of the queue.
:: Queue a -> Queue a
Removes an element at the end of the queue.
:: Queue a -> Queue a
Reverses a double ended queue.
:: [a] -> Queue a
Transforms a list to a double ended queue.
:: Queue a -> [a]
Transforms a double ended queue to a list.
:: Queue a -> Int
Returns the number of elements in the queue.
:: Queue a -> Queue a
Moves the first element to the end of the queue.
:: Queue a -> Maybe (a,Queue a)
Matches the front of a queue.
matchHead q is equivalent to
if isEmpty q then Nothing else Just (deqHead q,deqTail q)
but more efficient.
:: Queue a -> Maybe (a,Queue a)
Matches the end of a queue.
matchLast q is equivalent to
if isEmpty q then Nothing else Just (deqLast q,deqInit q)
but more efficient.