# Class Queue<E>

#### Type Parameters

- #### E = any

#### Hierarchy

- Queue

- Defined in src/data-structures/queue/queue.ts:34

#####
Index

### Constructors

constructor

### Properties

_nodes
_offset

### Accessors

nodes
offset
size

### Methods

[iterator]
clear
clone
dequeue
enqueue
getAt
isEmpty
peek
peekLast
push
shift
toArray
fromArray

## Constructors

### constructor

- new Queue<E>(elements?): Queue<E>

- The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.

  #### Type Parameters

  - #### E = any

  #### Parameters

  - ##### `Optional` elements: E[]

    The `elements` parameter is an optional array of elements of type `E`. If provided, it will be used to initialize the `_nodes` property of the class. If not provided, the `_nodes` property will be initialized as an empty array.

  #### Returns Queue<E>

  - Defined in src/data-structures/queue/queue.ts:41

## Properties

### `Private` _nodes

_nodes: E[]

- Defined in src/data-structures/queue/queue.ts:46

### `Private` _offset

_offset: number

- Defined in src/data-structures/queue/queue.ts:56

## Accessors

### nodes

- get nodes(): E[]

- #### Returns E[]

  - Defined in src/data-structures/queue/queue.ts:48
- set nodes(value): void

- #### Parameters

  - ##### value: E[]

  #### Returns void

  - Defined in src/data-structures/queue/queue.ts:52

### offset

- get offset(): number

- #### Returns number

  - Defined in src/data-structures/queue/queue.ts:58
- set offset(value): void

- #### Parameters

  - ##### value: number

  #### Returns void

  - Defined in src/data-structures/queue/queue.ts:62

### size

- get size(): number

- The size function returns the number of elements in an array.

  #### Returns number

  The size of the array, which is the difference between the length of the array and the offset.

  - Defined in src/data-structures/queue/queue.ts:70

## Methods

### [iterator]

- [iterator](): Generator<E, void, unknown>

- #### Returns Generator<E, void, unknown>

  - Defined in src/data-structures/queue/queue.ts:186

### clear

- clear(): void

- The clear function resets the nodes array and offset to their initial values.

  #### Returns void

  - Defined in src/data-structures/queue/queue.ts:173

### clone

- clone(): Queue<E>

- The `clone()` function returns a new Queue object with the same elements as the original Queue.

  #### Returns Queue<E>

  The `clone()` method is returning a new instance of the `Queue` class.

  - Defined in src/data-structures/queue/queue.ts:182

### dequeue

- dequeue(): undefined | E

- The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.

  #### Returns undefined | E

  The method is returning a value of type E or null.

  - Defined in src/data-structures/queue/queue.ts:146

### enqueue

- enqueue(value): void

- The enqueue function adds a value to the end of a queue.

  #### Parameters

  - ##### value: E

    The value parameter represents the value that you want to add to the queue.

  #### Returns void

  - Defined in src/data-structures/queue/queue.ts:138

### getAt

- getAt(index): undefined | E

- #### Parameters

  - ##### index: number

  #### Returns undefined | E

  - Defined in src/data-structures/queue/queue.ts:150

### isEmpty

- isEmpty(): boolean

- The function checks if a data structure is empty by comparing its size to zero.

  #### Returns boolean

  A boolean value indicating whether the size of the object is 0 or not.

  - Defined in src/data-structures/queue/queue.ts:158

### peek

- peek(): undefined | E

- The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `null`.

  #### Returns undefined | E

  The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at the `_offset` index. If the data structure is empty (size is 0), it returns `null`.

  - Defined in src/data-structures/queue/queue.ts:121

### peekLast

- peekLast(): undefined | E

- The `peekLast` function returns the last element in an array-like data structure, or null if the structure is empty.

  #### Returns undefined | E

  The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the array is empty, it returns `null`.

  - Defined in src/data-structures/queue/queue.ts:130

### push

- push(element): Queue<E>

- The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.

  #### Parameters

  - ##### element: E

    The `element` parameter represents the element that you want to add to the queue.

  #### Returns Queue<E>

  The `add` method is returning a `Queue<E>` object.

  - Defined in src/data-structures/queue/queue.ts:91

### shift

- shift(): undefined | E

- The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if necessary to optimize performance.

  #### Returns undefined | E

  The function `shift()` returns either the first element in the queue or `null` if the queue is empty.

  - Defined in src/data-structures/queue/queue.ts:101

### toArray

- toArray(): E[]

- The toArray() function returns an array of elements from the current offset to the end of the _nodes array.

  #### Returns E[]

  An array of type E is being returned.

  - Defined in src/data-structures/queue/queue.ts:166

### `Static` fromArray

- fromArray<E>(elements): Queue<E>

- The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.

  #### Type Parameters

  - #### E

  #### Parameters

  - ##### elements: E[]

    The "elements" parameter is an array of elements of type E.

  #### Returns Queue<E>

  The method is returning a new instance of the Queue class, initialized with the elements from the input array.

  #### Static

  - Defined in src/data-structures/queue/queue.ts:82

Generated using TypeDoc