Queue
Edit on GitHubAn 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.
Values
Functions for working with queues.
Queue.make
Added in 0.2.0
No other changes yet.
Creates an empty queue.
Returns:
type | description |
---|---|
Queue<a> |
An empty queue |
Queue.isEmpty
Added in 0.2.0
No other changes yet.
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
version | changes |
---|---|
0.2.0 | Originally named `head` |
0.3.2 | Deprecated `head` function |
0.4.0 | Removed `head` function |
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
version | changes |
---|---|
0.2.0 | Originally named `enqueue` |
0.3.2 | Deprecated `enqueue` function |
0.4.0 | Removed `enqueue` function |
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
version | changes |
---|---|
0.2.0 | Originally named `dequeue` |
0.3.2 | Deprecated `dequeue` function |
0.4.0 | Removed `dequeue` function |
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.
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 |