uulib-0.9.10: Haskell Utrecht Tools Library

UU.DData.Queue

Contents

Description

 

Synopsis

Queue type

data Queue a Source

Instances

Eq a => Eq (Queue a) 
Show a => Show (Queue a) 

Operators

(<>) :: Queue a -> Queue a -> Queue aSource

O(n). Append two queues, see append.

Query

isEmpty :: Queue a -> BoolSource

O(1). Is the queue empty?

length :: Queue a -> IntSource

O(n). The number of elements in the queue.

head :: Queue a -> aSource

O(1). The element in front of the queue. Raises an error when the queue is empty.

tail :: Queue a -> Queue aSource

O(1). The tail of the queue. Raises an error when the queue is empty.

front :: Queue a -> Maybe (a, Queue a)Source

O(1). The head and tail of the queue.

Construction

empty :: Queue aSource

O(1). The empty queue.

single :: a -> Queue aSource

O(1). A queue of one element.

insert :: a -> Queue a -> Queue aSource

O(1). Insert an element at the back of a queue.

append :: Queue a -> Queue a -> Queue aSource

O(n). Append two queues.

Filter

filter :: (a -> Bool) -> Queue a -> Queue aSource

O(n). Filter elements according to some predicate.

partition :: (a -> Bool) -> Queue a -> (Queue a, Queue a)Source

O(n). Partition the elements according to some predicate.

Fold

foldL :: (b -> a -> b) -> b -> Queue a -> bSource

O(n). Fold over the elements from left to right (ie. head to tail).

foldR :: (a -> b -> b) -> b -> Queue a -> bSource

O(n). Fold over the elements from right to left (ie. tail to head).

Conversion

elems :: Queue a -> [a]Source

O(n). The elements of a queue.

List

toList :: Queue a -> [a]Source

O(n). Convert to a list.

fromList :: [a] -> Queue aSource

O(n). Convert from a list.