The delete
function removes a node from a doubly linked list based on either the node itself or its value.
The valOrNode
parameter can accept either a value of type E
or
a DoublyLinkedListNode<E>
object.
The delete
method returns a boolean value. It returns true
if the value or node was successfully
deleted from the doubly linked list, and false
if the value or node was not found in the list.
The delete
function removes a node from a doubly linked list based on either the node itself or its value.
The valOrNode
parameter can accept either a value of type E
or
a DoublyLinkedListNode<E>
object.
The delete
method returns a boolean value. It returns true
if the value or node was successfully
deleted from the doubly linked list, and false
if the value or node was not found in the list.
The deleteAt
function removes an element at a specified index from a linked list and returns the removed element.
The index parameter represents the position of the element that needs to be deleted in the data structure. It is of type number.
The method deleteAt
returns the value of the node that was deleted, or null
if the index is out of
bounds.
The filter
function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
elements that satisfy the given callback function.
The callback
parameter is a function that takes a value of type E
and returns a boolean value.
It is used to determine whether a value should be included in the filtered list or not.
The filtered list, which is an instance of the DoublyLinkedList class.
The find
function iterates through a linked list and returns the first element that satisfies a given condition.
A function that takes a value of type E as its parameter and returns a boolean value. This function is used to determine whether a particular value in the linked list satisfies a certain condition.
The method find
returns the first element in the linked list that satisfies the condition specified by
the callback function. If no element satisfies the condition, it returns null
.
The findLast
function iterates through a linked list from the last node to the first node and returns the last
value that satisfies the given callback function, or null if no value satisfies the callback.
A function that takes a value of type E as its parameter and returns a boolean value. This function is used to determine whether a given value satisfies a certain condition.
The method findLast
returns the last value in the linked list that satisfies the condition specified by
the callback function. If no value satisfies the condition, it returns null
.
The function findNodeByValue
searches for a node with a specific value in a doubly linked list and returns the
node if found, otherwise it returns null.
The val
parameter is the value that we want to search for in the doubly linked list.
The function findNodeByValue
returns a DoublyLinkedListNode<E>
if a node with the specified value val
is found in the linked list. If no such node is found, it returns null
.
The forEach
function iterates over each element in a linked list and applies a callback function to each element.
The callback parameter is a function that takes two arguments: val and index. The val argument represents the value of the current node in the linked list, and the index argument represents the index of the current node in the linked list.
The getAt
function returns the value at a specified index in a linked list, or null if the index is out of bounds.
The index parameter is a number that represents the position of the element we want to retrieve from the list.
The method is returning the value at the specified index in the linked list. If the index is out of bounds or the linked list is empty, it will return null.
The function getNodeAt
returns the node at a given index in a doubly linked list, or null if the index is out of
range.
The index
parameter is a number that represents the position of the node we want to
retrieve from the doubly linked list. It indicates the zero-based index of the node we want to access.
The method getNodeAt(index: number)
returns a DoublyLinkedListNode<E>
object if the index is within the
valid range of the linked list, otherwise it returns null
.
The function returns the index of the first occurrence of a given value in a linked list.
The parameter val
is of type E
, which means it can be any data type. It represents the value
that we are searching for in the linked list.
The method indexOf
returns the index of the first occurrence of the specified value val
in the linked
list. If the value is not found, it returns -1.
The insertAfter
function inserts a new node with a given value after an existing node in a doubly linked list.
The existing value or node in the doubly linked list after which the new value will be inserted. It can be either the value of the existing node or the existing node itself.
The value that you want to insert into the doubly linked list.
The method returns a boolean value. It returns true if the insertion is successful, and false if the existing value or node is not found in the doubly linked list.
The insertAfter
function inserts a new node with a given value after an existing node in a doubly linked list.
The existing value or node in the doubly linked list after which the new value will be inserted. It can be either the value of the existing node or the existing node itself.
The value that you want to insert into the doubly linked list.
The method returns a boolean value. It returns true if the insertion is successful, and false if the existing value or node is not found in the doubly linked list.
The insert
function inserts a value at a specified index in a doubly linked list.
The index parameter represents the position at which the new value should be inserted in the DoublyLinkedList. It is of type number.
The val
parameter represents the value that you want to insert into the Doubly Linked List at the
specified index.
The insert
method returns a boolean value. It returns true
if the insertion is successful, and false
if the index is out of bounds.
The insertBefore
function inserts a new value before an existing value or node in a doubly linked list.
The existing value or node in the doubly linked list before which the new value will be inserted. It can be either the value of the existing node or the existing node itself.
The newValue
parameter represents the value that you want to insert into the doubly linked
list.
The method returns a boolean value. It returns true
if the insertion is successful, and false
if the
insertion fails.
The insertBefore
function inserts a new value before an existing value or node in a doubly linked list.
The existing value or node in the doubly linked list before which the new value will be inserted. It can be either the value of the existing node or the existing node itself.
The newValue
parameter represents the value that you want to insert into the doubly linked
list.
The method returns a boolean value. It returns true
if the insertion is successful, and false
if the
insertion fails.
The map
function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
DoublyLinkedList with the transformed values.
The callback parameter is a function that takes a value of type E (the type of values stored in the original DoublyLinkedList) and returns a value of type U (the type of values that will be stored in the mapped DoublyLinkedList).
The map
function is returning a new instance of DoublyLinkedList<U>
that contains the mapped values.
The reduce
function iterates over a linked list and applies a callback function to each element, accumulating a
single value.
The callback
parameter is a function that takes two arguments: accumulator
and val
. It is
used to perform a specific operation on each element of the linked list.
The initialValue
parameter is the initial value of the accumulator. It is the starting
point for the reduction operation.
The reduce
method is returning the final value of the accumulator after iterating through all the
elements in the linked list.
Static
fromThe fromArray
function creates a new instance of a DoublyLinkedList and populates it with the elements from the
given array.
The data
parameter is an array of elements of type E
.
The fromArray
function returns a DoublyLinkedList object.
Generated using TypeDoc
The constructor initializes the linked list with an empty head, tail, and length.