Reference
Queue
New
| Input | A list of elements. |
|---|---|
| Output | A queue containing the list of elements with the first element at the beginning of the queue. |
Signature
queue_new(a: List): QueueExample
queue_new([1, 2, 3]) // returns a queue with 1 at the frontEnqueue
| Input | A queue and an element. |
|---|---|
| Output | A new queue with the element added to the end. |
Signature
queue_enqueue(a: Queue, b: Any): QueueExample
queue_enqueue(queue_new([1, 2]), 3) // returns a queue [1, 2, 3]Dequeue
| Input | A queue. |
|---|---|
| Output | A new queue with the element at the beginning removed. |
Signature
queue_dequeue(a: Queue): QueueExample
queue_dequeue(queue_new([1, 2, 3])) // returns a queue [2, 3]Peek
| Input | A queue. |
|---|---|
| Output | The element at the beginning of the queue. |
Signature
queue_peek(a: Queue): AnyExample
queue_peek(queue_new([1, 2, 3])) // returns 1Reverse
| Input | A queue. |
|---|---|
| Output | A new queue with the elements in reverse order. |
Signature
queue_reverse(a: Queue): QueueExample
queue_reverse(queue_new([1, 2, 3])) // returns a queue [3, 2, 1]Is Empty
| Input | A queue. |
|---|---|
| Output | True if the queue is empty, false otherwise. |
Signature
queue_isEmpty(a: Queue): BooleanExample
queue_isEmpty(queue_new([])) // returns trueIs Not Empty
| Input | A queue. |
|---|---|
| Output | True if the queue is not empty, false otherwise. |
Signature
queue_isNotEmpty(a: Queue): BooleanExample
queue_isNotEmpty(queue_new([1, 2])) // returns trueLength
| Input | A queue. |
|---|---|
| Output | The number of elements in the queue. |
Signature
queue_length(a: Queue): NumberExample
queue_length(queue_new([1, 2, 3])) // returns 3