Queue

GitHub   Edit on GitHub

An immutable queue implementation. A queue is a FIFO (first-in-first-out) data structure where new values are added to the end and retrieved or removed from the beginning.

Added in 0.2.0 No other changes yet.
1
import Queue from "queue"

Values

Functions for working with queues.

Queue.make

Added in 0.2.0 No other changes yet.
1
make : () -> Queue<a>

Creates an empty queue.

Returns:

type description
Queue<a> An empty queue

Queue.isEmpty

Added in 0.2.0 No other changes yet.
1
isEmpty : Queue<a> -> Bool

Checks if the given queue contains any values.

Parameters:

param type description
queue Queue<a> The queue to check

Returns:

type description
Bool true if the given queue is empty or false otherwise

Queue.peek

Added in 0.3.2
versionchanges
0.2.0Originally named `head`
0.3.2Deprecated `head` function
0.4.0Removed `head` function
1
peek : Queue<a> -> Option<a>

Returns the value at the beginning of the queue. It is not removed from the queue.

Parameters:

param type description
queue Queue<a> The queue to inspect

Returns:

type description
Option<a> Some(value) containing the value at the beginning of the queue, or None if the queue is empty

Queue.push

Added in 0.3.2
versionchanges
0.2.0Originally named `enqueue`
0.3.2Deprecated `enqueue` function
0.4.0Removed `enqueue` function
1
push : (a, Queue<a>) -> Queue<a>

Adds a value to the end of the queue.

Parameters:

param type description
value a The value to append
queue Queue<a> The queue to update

Returns:

type description
Queue<a> An updated queue

Queue.pop

Added in 0.3.2
versionchanges
0.2.0Originally named `dequeue`
0.3.2Deprecated `dequeue` function
0.4.0Removed `dequeue` function
1
pop : Queue<a> -> Queue<a>

Dequeues the next value in the queue.

Parameters:

param type description
queue Queue<a> The queue to change

Returns:

type description
Queue<a> An updated queue

Queue.size

Added in 0.3.2 No other changes yet.
1
size : Queue<a> -> Number

Get the number of values in a queue.

Parameters:

param type description
queue Queue<a> The queue to inspect

Returns:

type description
Number The number of values in the queue
This is a notification!