imeckler/queue/1.1.3

NOTE: this package is not compatible with Elm 0.19.1

Queue

Just a simple queue data type.

Type

type alias Queue a =
Queue a

A queue is a sequence supporting O(1) appending (push) of a new element to the back and amortizsed O(1) removal of the element at the front (pop).

Construction

empty : Queue a

An empty queue, ready for pushin'.

push : a -> Queue a -> Queue a

Put the given element at the back of the given queue. O(1).

Inspection

pop : Queue a -> Maybe ( a, Queue a )

Get the first element of the queue and the queue with the first element removed. Returns nothing if the queue is empty. Amortized O(1).

Utilities

isEmpty : Queue a -> Bool
length : Queue a -> Int
map : (a -> b) -> Queue a -> Queue b
toList : Queue a -> List a

A list consisting of the elements in the order in which they were put into the queue (i.e., "front to back").