Queue

types/collections/queue.ql

Function Overview

Function Description
static fun fromList(list) Creates a new queue from a list of elements.
fun enqueue(element) Enqueues an element onto the queue.
fun dequeue() Dequeues an element from the queue.
fun peek() Peeks at the front element of the queue.
fun isEmpty() Checks if the queue is empty.
fun size() Gets the size of the queue.
fun toList() Converts the queue to a list.

Field Overview

Field Description
any _queue

Functions

static fun fromList(list) link

Creates a new queue from a list of elements.

Params
list ( list )

A list of elements

Returns Queue

A new queue with the given elements

fun enqueue(element) link

Enqueues an element onto the queue.

Params
element

The element to enqueue onto the queue

fun dequeue() link

Dequeues an element from the queue.

Returns

The element dequeued from the queue

Errors

If the queue is empty

fun peek() link

Peeks at the front element of the queue.

Returns

The front element of the queue

Errors

If the queue is empty

fun isEmpty() link

Checks if the queue is empty.

Returns boolean

true if the queue is empty, false if otherwise

fun size() link

Gets the size of the queue.

Returns int

The size of the queue

fun toList() link

Converts the queue to a list.

Returns list

The queue as a list