# DoublyLinkedList | data-structure-typed
Documentation for data-structure-typed

# Class DoublyLinkedList<T>

#### Type Parameters

- #### T

#### Hierarchy

- DoublyLinkedList
  - Deque

- Defined in src/data-structures/linked-list/doubly-linked-list.ts:19

#####
Index

### Constructors

constructor

### Properties

_first
_last
_size

### Accessors

size

### Methods

get
insert
isEmpty
offerFirst
offerLast
peekFirst
peekLast
pollFirst
pollLast
remove
set

## Constructors

### constructor

- new DoublyLinkedList<T>(): DoublyLinkedList <T>

- #### Type Parameters

  - #### T

  #### Returns DoublyLinkedList <T>

## Properties

### `Private` _first

_first: null | DoublyLinkedListNode <T> = null

- Defined in src/data-structures/linked-list/doubly-linked-list.ts:20

### `Private` _last

_last: null | DoublyLinkedListNode <T> = null

- Defined in src/data-structures/linked-list/doubly-linked-list.ts:21

### `Private` _size

_size: number = 0

- Defined in src/data-structures/linked-list/doubly-linked-list.ts:22

## Accessors

### size

- get size(): number

- #### Returns number

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:23
- set size(v): void

- #### Parameters

  - ##### v: number

  #### Returns void

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:27

## Methods

### get

- get(index): null | T

- Returns the node at the specified index of the linked list. If index = 0; first element in the list is returned. If index = 3; fourth element in the list is returned.

  #### Parameters

  - ##### index: number

    Index of the node to be retrieved

  #### Returns null | T

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:184
- get(index, by): null | DoublyLinkedListNode <T>

- Returns the node at the specified index of the linked list. If index = 0; first element in the list is returned. If index = 3; fourth element in the list is returned.

  #### Parameters

  - ##### index: number

    Index of the node to be retrieved

  - ##### by: "node"

    Return value type

  #### Returns null | DoublyLinkedListNode <T>

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:185
- get(index, by): null | T

- Returns the node at the specified index of the linked list. If index = 0; first element in the list is returned. If index = 3; fourth element in the list is returned.

  #### Parameters

  - ##### index: number

    Index of the node to be retrieved

  - ##### by: "val"

    Return value type

  #### Returns null | T

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:186

### insert

- insert(index, val): boolean

- Inserts a new node at the specified index.

  #### Parameters

  - ##### index: number

    Index at which the new node has to be inserted

  - ##### val: T

    Value of the new node to be inserted

  #### Returns boolean

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:248

### isEmpty

- isEmpty(): boolean

- #### Returns boolean

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:238

### offerFirst

- offerFirst(val): boolean

- The function adds a new node with a given value to the beginning of a doubly linked list.

  #### Parameters

  - ##### val: T

    The `val` parameter represents the value of the element that you want to add to the beginning of the doubly linked list.

  #### Returns boolean

  A boolean value is being returned.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:37

### offerLast

- offerLast(val): boolean

- The function adds a new node with a given value to the end of a doubly linked list.

  #### Parameters

  - ##### val: T

    The `val` parameter represents the value of the element that you want to add to the end of the doubly linked list.

  #### Returns boolean

  a boolean value, which is always true.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:57

### peekFirst

- peekFirst(): null | T

- The `peekFirst` function returns the first node or value in a doubly linked list, depending on the specified parameter.

  #### Returns null | T

  The method `peekFirst` returns either the first node of the doubly linked list (`DoublyLinkedListNode<T>`), the value of the first node (`T`), or `null` depending on the value of the `by` parameter.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:71
- peekFirst(by): null | T

- The `peekFirst` function returns the first node or value in a doubly linked list, depending on the specified parameter.

  #### Parameters

  - ##### by: "val"

    The "by" parameter is an optional parameter of type DoublyLinkedListGetBy. It is used to specify whether to return the first node, the value of the first node, or the first node itself.

  #### Returns null | T

  The method `peekFirst` returns either the first node of the doubly linked list (`DoublyLinkedListNode<T>`), the value of the first node (`T`), or `null` depending on the value of the `by` parameter.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:72
- peekFirst(by): null | DoublyLinkedListNode <T>

- The `peekFirst` function returns the first node or value in a doubly linked list, depending on the specified parameter.

  #### Parameters

  - ##### by: "node"

    The "by" parameter is an optional parameter of type DoublyLinkedListGetBy. It is used to specify whether to return the first node, the value of the first node, or the first node itself.

  #### Returns null | DoublyLinkedListNode <T>

  The method `peekFirst` returns either the first node of the doubly linked list (`DoublyLinkedListNode<T>`), the value of the first node (`T`), or `null` depending on the value of the `by` parameter.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:73

### peekLast

- peekLast(): null | T

- The `peekLast` function returns the last node or value in a doubly linked list.

  #### Returns null | T

  The method `peekLast` returns the last node, value, or null based on the specified `by` parameter.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:93
- peekLast(by): null | T

- The `peekLast` function returns the last node or value in a doubly linked list.

  #### Parameters

  - ##### by: "val"

    The "by" parameter is an optional parameter of type DoublyLinkedListGetBy. It specifies whether to return the last node, the value of the last node, or both. The default value is 'val', which means that if no value is provided for the "by" parameter, the method

  #### Returns null | T

  The method `peekLast` returns the last node, value, or null based on the specified `by` parameter.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:94
- peekLast(by): null | DoublyLinkedListNode <T>

- The `peekLast` function returns the last node or value in a doubly linked list.

  #### Parameters

  - ##### by: "node"

    The "by" parameter is an optional parameter of type DoublyLinkedListGetBy. It specifies whether to return the last node, the value of the last node, or both. The default value is 'val', which means that if no value is provided for the "by" parameter, the method

  #### Returns null | DoublyLinkedListNode <T>

  The method `peekLast` returns the last node, value, or null based on the specified `by` parameter.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:95

### pollFirst

- pollFirst(): null | T

- The function `pollFirst` removes and returns the first element of a doubly linked list, either as a node or its value, depending on the specified parameter.

  #### Returns null | T

  The method `pollFirst` returns either the value of the first node in the doubly linked list, the first node itself, or null if the list is empty. The specific return type depends on the value of the `by` parameter. If `by` is set to 'node', the method returns the first node. If `by` is set to 'val', the method returns the value

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:114
- pollFirst(by): null | T

- The function `pollFirst` removes and returns the first element of a doubly linked list, either as a node or its value, depending on the specified parameter.

  #### Parameters

  - ##### by: "val"

    The "by" parameter is an optional parameter of type DoublyLinkedListGetBy. It specifies the criteria by which the first element should be retrieved from the doubly linked list. The default value is 'val', which means the first element will be retrieved by its value. Other possible values for "by

  #### Returns null | T

  The method `pollFirst` returns either the value of the first node in the doubly linked list, the first node itself, or null if the list is empty. The specific return type depends on the value of the `by` parameter. If `by` is set to 'node', the method returns the first node. If `by` is set to 'val', the method returns the value

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:115
- pollFirst(by): null | DoublyLinkedListNode <T>

- The function `pollFirst` removes and returns the first element of a doubly linked list, either as a node or its value, depending on the specified parameter.

  #### Parameters

  - ##### by: "node"

    The "by" parameter is an optional parameter of type DoublyLinkedListGetBy. It specifies the criteria by which the first element should be retrieved from the doubly linked list. The default value is 'val', which means the first element will be retrieved by its value. Other possible values for "by

  #### Returns null | DoublyLinkedListNode <T>

  The method `pollFirst` returns either the value of the first node in the doubly linked list, the first node itself, or null if the list is empty. The specific return type depends on the value of the `by` parameter. If `by` is set to 'node', the method returns the first node. If `by` is set to 'val', the method returns the value

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:116

### pollLast

- pollLast(): null | T

- The function `pollLast` removes and returns the last element in a doubly linked list, either as a node or its value, depending on the specified parameter.

  #### Returns null | T

  The method `pollLast` returns either a `DoublyLinkedListNode<T>`, the value of the node (`T`), or `null`. The specific type that is returned depends on the value of the `by` parameter. If `by` is set to `'node'`, then a `DoublyLinkedListNode<T>` is returned. If `by` is set to `'

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:149
- pollLast(by): null | T

- The function `pollLast` removes and returns the last element in a doubly linked list, either as a node or its value, depending on the specified parameter.

  #### Parameters

  - ##### by: "val"

    The parameter "by" is of type DoublyLinkedListGetBy, which is an enum that can have two possible values: 'node' or 'val'. It determines the type of value that will be returned by the pollLast method. If 'node' is specified, the method will return the

  #### Returns null | T

  The method `pollLast` returns either a `DoublyLinkedListNode<T>`, the value of the node (`T`), or `null`. The specific type that is returned depends on the value of the `by` parameter. If `by` is set to `'node'`, then a `DoublyLinkedListNode<T>` is returned. If `by` is set to `'

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:150
- pollLast(by): null | DoublyLinkedListNode <T>

- The function `pollLast` removes and returns the last element in a doubly linked list, either as a node or its value, depending on the specified parameter.

  #### Parameters

  - ##### by: "node"

    The parameter "by" is of type DoublyLinkedListGetBy, which is an enum that can have two possible values: 'node' or 'val'. It determines the type of value that will be returned by the pollLast method. If 'node' is specified, the method will return the

  #### Returns null | DoublyLinkedListNode <T>

  The method `pollLast` returns either a `DoublyLinkedListNode<T>`, the value of the node (`T`), or `null`. The specific type that is returned depends on the value of the `by` parameter. If `by` is set to `'node'`, then a `DoublyLinkedListNode<T>` is returned. If `by` is set to `'

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:151

### remove

- remove(index): null | T

- The `remove` function removes an element at a specified index from a data structure, updating the links between nodes accordingly.

  #### Parameters

  - ##### index: number

    The index parameter represents the position of the element to be removed in the data structure. It is of type number.

  #### Returns null | T

  The `remove` method returns the value of the removed element (`T`) if the removal is successful, or `null` if the index is out of bounds.

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:273

### set

- set(index, val): boolean

- Updates the value of the node at the specified index. If index = 0; Value of the first element in the list is updated. If index = 3; Value of the fourth element in the list is updated.

  #### Parameters

  - ##### index: number

    Index of the node to be updated

  - ##### val: T

    New value of the node

  #### Returns boolean

  - Defined in src/data-structures/linked-list/doubly-linked-list.ts:229

Generated using TypeDoc