Rest ...args: NodeVal[]args is a rest parameter that allows the constructor to accept an arbitrary number of arguments of type NodeVal.
Protected _headProtected _sizeProtected _tailRest ...args: NodeVal[]The clear() function resets the linked list by setting the head and tail to null and the size to 0.
The "this" object is being returned.
The filter function filters the elements of a singly linked list based on a given callback function.
A callback function that takes three parameters: data, index, and list. It should return a boolean value indicating whether the current element should be included in the filtered list or not.
Optional reverse: boolean = falseThe reverse parameter is a boolean value that determines whether the filtered list should
be reversed or not. If reverse is set to true, the filtered list will be in reverse order. If reverse is set
to false or not provided, the filtered list will be in
The filter method is returning a new SinglyLinkedList object.
The find function in TypeScript searches for a node in a singly linked list based on a given callback function and
returns the value of the found node.
A callback function that takes three parameters: data, index, and list. It returns a boolean value indicating whether the condition is met for a particular node in the linked list.
The method find returns the NodeVal value of the first node in the linked list that satisfies the
condition specified by the callbackFn function. If no node satisfies the condition, it returns undefined.
The findIndex function returns the index of the first node in a singly linked list that satisfies a given condition, or -1 if no such node is found.
A callback function that takes three parameters: data, index, and list. It returns a boolean value indicating whether the condition is met for a particular node in the singly linked list.
The method findIndex returns a number.
The findNode function searches for a node in a singly linked list based on a given callback function.
A callback function that takes three parameters: data, index, and list. It returns a boolean value indicating whether the current node matches the desired criteria.
The function findNode returns a SinglyLinkedListNode<NodeVal> if a node satisfying the condition
specified by the callbackFn is found in the linked list. If no such node is found, it returns undefined.
The function findNodeIndex searches for a node in a singly linked list that satisfies a given condition and
returns its index and the node itself.
The callbackFn parameter is a function that takes three arguments: data, index, and list. It is used to determine whether a node in the singly linked list matches a certain condition. The function should return a boolean value indicating whether the condition is met for the given node.
The function findNodeIndex returns an object with two properties: node and index. The node property
contains the node that matches the condition specified in the callbackFn function, and the index property
contains the index of that node in the linked list. If no node matches the condition, the function returns
undefined.
The forEach function iterates over a singly linked list and applies a callback function to each node, either in
forward or reverse order.
A callback function that will be called for each element in the linked list. It takes three parameters:
Optional reverse: boolean = falseA boolean value indicating whether to iterate over the linked list in reverse order. If set to true, the iteration will start from the tail of the linked list and move towards the head. If set to false (default), the iteration will start from the head and move towards the tail.
The get function returns the value of a node at a given index in a data structure.
The index parameter is a number that represents the position of the node in the data structure.
The method is returning the value of the node at the specified index if the node exists, otherwise it returns undefined.
The function getNode returns the node at a given index in a singly linked list.
The index parameter is a number that represents the position of the node we want to
retrieve from the linked list.
a SinglyLinkedListNode
The insertAfter function inserts a new node with a given value after a specified reference node in a singly linked
list.
The referenceNode parameter is the node after which the new node will be inserted.
The value of the new node that will be inserted after the reference node.
The insertAfter method is returning the updated SinglyLinkedList object.
The insertAt function inserts a value at a specified index in a singly linked list.
The index parameter is a number that represents the position at which the new node should be inserted in the linked list.
The val parameter represents the value of the node that you want to insert into the linked
list.
The method insertAt returns the updated SinglyLinkedList object.
The insertBefore function inserts a new node with a given value before a specified reference node in a singly
linked list.
The referenceNode parameter is the node in the linked list before which the new node will be inserted.
The value of the new node that will be inserted before the reference node.
The method is returning the updated SinglyLinkedList object.
The map function takes a callback function and applies it to each element in the linked list, returning a new linked list with the results.
A callback function that will be applied to each element in the linked list. It takes three parameters:
Optional reverse: boolean = falseThe reverse parameter is a boolean value that determines whether the mapping should be
done in reverse order or not. If reverse is set to true, the mapping will be done in reverse order. If reverse
is set to false or not provided, the mapping will be
The map function is returning a new SinglyLinkedList object.
The merge function merges two singly linked lists by updating the next and prev pointers, as well as the head, tail, and size properties.
The parameter "list" is a SinglyLinkedList object that contains nodes with data of type NodeVal.
The prepend function adds new nodes to the beginning of a singly linked list.
Rest ...args: NodeVal[]An array of NodeVal objects.
The prepend method is returning the updated SinglyLinkedList object.
The push function appends multiple NodeVal objects to a data structure and returns the new size of the data structure.
Rest ...args: NodeVal[]args is a rest parameter of type NodeVal[]. It allows the function to accept any number of arguments of type NodeVal.
The size of the data structure after the nodes are appended.
The reduce function iterates over a singly linked list and applies a callback function to each element,
accumulating a single value.
A callback function that will be called for each element in the linked list. It takes four parameters:
Optional start: anyThe start parameter is an optional initial value for the accumulator. If provided, the
reduce function will start accumulating from this value. If not provided, the reduce function will use the value
of the first element in the linked list as the initial value.
Optional reverse: boolean = falseA boolean value indicating whether to iterate over the linked list in reverse order. If set to true, the iteration will start from the tail of the linked list and move towards the head. If set to false (default), the iteration will start from the head and move towards the tail.
The reduce method returns the accumulated value after applying the callback function to each element in
the linked list.
The removeAt function removes a node at a specified index from a singly linked list.
The index parameter is a number that represents the position of the node to be removed in the singly linked list.
The method removeAt returns a SinglyLinkedListNode<NodeVal> if the node at the specified index is
found and removed successfully. If the node is not found, it returns undefined.
Protected removeThe function removes a node from either end of a singly linked list and returns its value.
The node parameter is a reference to a node in a singly
linked list. It can be either a SinglyLinkedListNode object or null.
The value of the removed node if the node is not null, otherwise undefined.
The removeNode function removes a node from a singly linked list and updates the head, tail, and size properties accordingly.
The node parameter is of type SinglyLinkedListNode<NodeVal>, which represents a node in a singly
linked list.
the removed node.
The reverse() function reverses the order of nodes in a singly linked list.
The reverse() method is returning the reversed SinglyLinkedList.
The slice function returns a new SinglyLinkedList containing a portion of the original list, starting from the
specified index and ending at the optional end index.
The start parameter is a number that represents the index at which to start slicing the
linked list.
Optional end: numberThe end parameter is an optional number that specifies the index at which to end the
slicing. If no value is provided for end, or if the provided value is less than the start index, the slicing
will continue until the end of the list.
a new SinglyLinkedList containing the sliced elements from the original list.
The sort function uses the quicksort algorithm to sort the elements of a singly linked list based on a provided
comparison function.
The sort method is returning the sorted SinglyLinkedList object.
Static fromThe from function in TypeScript creates a new SinglyLinkedList instance from an iterable object.
The iterable parameter is an object that can be iterated over, such as an array or a string. It
contains a collection of elements of type T.
The method is returning a new instance of the SinglyLinkedList class.
Generated using TypeDoc
The constructor initializes a linked list with the given arguments as nodes.