uni-util-2.3.0.3: Utilities for the uniform workbench
Safe HaskellSafe-Inferred
LanguageHaskell2010

Util.Queue

Description

This is an implementation of queues inspired by the paper in Software Practice & Experience, ... The queue is divided into two sequences. The first sequence holds the elements in a LIFO order, the second in a FIFO order. The LIFO sequence is the one where elements are added, the FIFO the one from which elements are removed. When the remove operation is called and the FIFO sequence is empty, the LIFO sequence is turned into a FIFO sequence by reversing the order of its elements.

Note from GER - as far as I know, we only need the values emptyQ :: Queue a -- new empty queue singletonQ :: a -> Queue a -- new singleton queue insertQ :: Queue a -> a -> Queue a -- add to queue removeQ :: Queue a -> Maybe (a,Queue a) -- pop from queue. insertAtEndQ :: Queue a -> a -> Queue a -- undo the effect of the previous removeQ. isEmptyQ :: Queue a -> Bool queueToList :: Queue a -> [a]

Synopsis

Documentation

data Queue a Source #

Instances

Instances details
Functor Queue Source # 
Instance details

Defined in Util.Queue

Methods

fmap :: (a -> b) -> Queue a -> Queue b #

(<$) :: a -> Queue b -> Queue a #

Eq a => Eq (Queue a) Source # 
Instance details

Defined in Util.Queue

Methods

(==) :: Queue a -> Queue a -> Bool #

(/=) :: Queue a -> Queue a -> Bool #

insertQ :: Queue a -> a -> Queue a Source #

removeQ :: Queue a -> Maybe (a, Queue a) Source #

listToQueue :: [a] -> Queue a Source #

Converts a list to a queue with the first element of the list the first element of the queue.

queueToList :: Queue a -> [a] Source #

Inverts listToQueue