# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

Abstract data type "Queue"

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```adt::Queue(`queue`)
```

## Description

`adt::Queue` implements the abstract data type "Queue". To create a queue, an expression sequence of any MuPAD® objects can be given to initialize the queue, otherwise an empty queue is built.

 Note:   The methods of all abstract data types must be called especially and will result changing the object itself as side effect.

With `Q := adt::Queue()` an empty queue is built and assigned to the variable `Q`.

Every queue will be displayed as `Queue` followed by a number. This name is generated by `genident`.

 Note:   All following methods changes the value of `Q` itself. A new assignment to the variable (in this example `Q`) is not necessary, in contrast to all other MuPAD functions and data types.

The methods `clear`, `dequeue`, `empty`, `enqueue`, `front`, `length`, `reverse` are available for handling with queues.

## Examples

### Example 1

Create a new queue with strings as arguments.

`Q := adt::Queue("1", "2", "3", "4")`
``` ```

Show the length of the queue.

`Q::length()`
``` ```

Fill up the queue with a new element. The queue will be changed by the method, no new assignment to `Q` is necessary!

`Q::enqueue("5")`
``` ```

Show the front of the queue. This method does not change the queue.

`Q::front(), Q::front()`
``` ```

After twice getting an element of the queue, the third element is the new front of the queue, and the length is `3`.

`Q::dequeue(), Q::dequeue(), Q::front(), Q::length()`
``` ```

Now revert the queue. The last element will be the first element.

`Q::reverse(): Q::front()`
``` ```

Enlarge the queue with `"2"`.

```Q::enqueue("2"): Q::empty()```
``` ```

Finally collect all elements of the queue in the list assigned to `ARGS`, until the queue is empty.

```ARGS := []: while not Q::empty() do ARGS := append(ARGS, Q::dequeue()) end: ARGS```
``` ```

## Parameters

 `queue` An expression sequence of objects to initialize the queue

## Methods

expand all

`clear()`

`dequeue()`

`empty()`

`enqueue(x)`

`front()`

`length()`

`reverse()`