Class: TypedQueue

@include <TypedQueue>

Queue which enforces type restrictions on its elements

The type must be set before adding any elements to the queue. Once elements have been added, the type cannot be changed.

Methods

@TypedQueue.set_type

Scope: public

Set the type of elements that this queue will hold.

This method must be called before adding elements to the queue. The queue’s type cannot be changed after elements have been added.

Returns: 1 if the type cannot be changed, 0 otherwise.

Usage: @TypedQueue.set_type $type

Parameters

  • type
    • Type: Primitive
    • The type to enforce for the elements of this queue.

@TypedQueue.enqueue

Scope: public

Add a value to the end of the queue, enforcing the specified type.

Returns: 1 if the value is of the wrong type, 0 otherwise.

Usage: @TypedQueue.enqueue $value

Parameters

  • value
    • Type: Primitive
    • The value to add to the queue.

@TypedQueue.size

Scope: public

Echo the number of elements in the queue.

Outputs: The number of elements in the queue.

Usage: @TypedQueue.size

@TypedQueue.empty

Scope: public

Silently check if the queue is empty.

Returns: 0 if the queue is empty, 1 otherwise.

Outputs: nothing

Usage: @TypedQueue.empty

@TypedQueue.dequeue

Scope: public

Remove and echo the value at the front of the queue.

Returns: 1 if the queue is empty, 0 otherwise.

Outputs: The value at the front of the queue.

Usage: @TypedQueue.dequeue

@TypedQueue.front

Scope: public

Echo the value at the front of the queue.

Returns: 1 if the queue is empty, 0 otherwise.

Outputs: The value at the front of the queue.

Usage: @TypedQueue.front

@TypedQueue.back

Scope: public

Echo the value at the back of the queue.

Returns: 1 if the queue is empty, 0 otherwise.

Outputs: The value at the back of the queue.

Usage: @TypedQueue.back

@TypedQueue.clear

Scope: public

Clear the queue by removing all elements.

Usage: @TypedQueue.clear