| Haskell Hierarchical Libraries (base package) | Source code | Contents | Index

Data.Queue |

Portability | portable
Stability | experimental
Maintainer | libraries@haskell.org

Contents

Primitive operations
Queues and lists

Description
NOTE: This module is DEPRECATED. The data structure in Data.Sequence is a faster queue and also supports a wider variety of operations. Queues with constant time operations, from Simple and efficient purely functional queues and deques, by Chris Okasaki, JFP 5(4):583-592, October 1995.
Synopsis

data Queue a
emptyQueue :: Queue a
addToQueue :: Queue a -> a -> Queue a
deQueue :: Queue a -> Maybe (a, Queue a)
listToQueue :: [a] -> Queue a
queueToList :: Queue a -> [a]

Documentation
data Queue a

The type of FIFO queues.
Instances

Functor Queue
Typeable1 Queue

Primitive operations
Each of these requires O(1) time in the worst case.
emptyQueue :: Queue a
The empty queue.
addToQueue :: Queue a -> a -> Queue a
Add an element to the back of a queue.
deQueue :: Queue a -> Maybe (a, Queue a)
Attempt to extract the front element from a queue. If the queue is empty, `Nothing`, otherwise the first element paired with the remainder of the queue.
Queues and lists
listToQueue :: [a] -> Queue a
A queue with the same elements as the list.
queueToList :: Queue a -> [a]
The elements of a queue, front first.
Produced by Haddock version 0.8