data-structure-typed 1.16.1 → 1.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +178 -70
- package/dist/data-structures/linked-list/doubly-linked-list.js +475 -244
- package/dist/data-structures/linked-list/index.d.ts +1 -0
- package/dist/data-structures/linked-list/index.js +1 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +111 -248
- package/dist/data-structures/linked-list/singly-linked-list.js +338 -619
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
- package/dist/data-structures/linked-list/skip-linked-list.js +7 -0
- package/dist/data-structures/matrix/vector2d.js +2 -2
- package/dist/data-structures/types/binary-tree.d.ts +0 -5
- package/docs/assets/search.js +1 -1
- package/docs/classes/AVLTree.html +94 -94
- package/docs/classes/AVLTreeNode.html +37 -37
- package/docs/classes/AaTree.html +2 -2
- package/docs/classes/AbstractEdge.html +12 -12
- package/docs/classes/AbstractGraph.html +30 -30
- package/docs/classes/AbstractVertex.html +7 -7
- package/docs/classes/ArrayDeque.html +15 -15
- package/docs/classes/BST.html +87 -87
- package/docs/classes/BSTNode.html +37 -37
- package/docs/classes/BTree.html +2 -2
- package/docs/classes/BinaryIndexedTree.html +8 -8
- package/docs/classes/BinaryTree.html +83 -83
- package/docs/classes/BinaryTreeNode.html +37 -37
- package/docs/classes/Character.html +5 -5
- package/docs/classes/CoordinateMap.html +11 -11
- package/docs/classes/CoordinateSet.html +10 -10
- package/docs/classes/Deque.html +564 -356
- package/docs/classes/DirectedEdge.html +18 -18
- package/docs/classes/DirectedGraph.html +42 -42
- package/docs/classes/DirectedVertex.html +7 -7
- package/docs/classes/DoublyLinkedList.html +546 -313
- package/docs/classes/DoublyLinkedListNode.html +53 -36
- package/docs/classes/Heap.html +21 -21
- package/docs/classes/HeapItem.html +9 -9
- package/docs/classes/Matrix2D.html +17 -17
- package/docs/classes/MatrixNTI2D.html +5 -5
- package/docs/classes/MaxHeap.html +21 -21
- package/docs/classes/MaxPriorityQueue.html +35 -35
- package/docs/classes/MinHeap.html +21 -21
- package/docs/classes/MinPriorityQueue.html +35 -35
- package/docs/classes/Navigator.html +11 -11
- package/docs/classes/ObjectDeque.html +26 -26
- package/docs/classes/PriorityQueue.html +33 -33
- package/docs/classes/Queue.html +15 -15
- package/docs/classes/RBTree.html +2 -2
- package/docs/classes/SegmentTree.html +13 -13
- package/docs/classes/SegmentTreeNode.html +27 -27
- package/docs/classes/SinglyLinkedList.html +277 -606
- package/docs/classes/SinglyLinkedListNode.html +40 -167
- package/docs/classes/SkipLinkedList.html +150 -0
- package/docs/classes/SplayTree.html +2 -2
- package/docs/classes/Stack.html +13 -13
- package/docs/classes/TreeMultiSet.html +87 -87
- package/docs/classes/TreeNode.html +9 -9
- package/docs/classes/Trie.html +14 -14
- package/docs/classes/TrieNode.html +12 -12
- package/docs/classes/TwoThreeTree.html +2 -2
- package/docs/classes/UndirectedEdge.html +14 -14
- package/docs/classes/UndirectedGraph.html +36 -36
- package/docs/classes/UndirectedVertex.html +7 -7
- package/docs/classes/Vector2D.html +29 -29
- package/docs/enums/CP.html +5 -5
- package/docs/enums/FamilyPosition.html +5 -5
- package/docs/enums/LoopType.html +4 -4
- package/docs/index.html +3 -3
- package/docs/interfaces/AVLTreeDeleted.html +4 -4
- package/docs/interfaces/HeapOptions.html +3 -3
- package/docs/interfaces/IDirectedGraph.html +8 -8
- package/docs/interfaces/IGraph.html +20 -20
- package/docs/interfaces/NavigatorParams.html +6 -6
- package/docs/interfaces/PriorityQueueOptions.html +5 -5
- package/docs/modules.html +2 -2
- package/docs/types/BSTComparator.html +2 -2
- package/docs/types/BSTDeletedResult.html +2 -2
- package/docs/types/BinaryTreeDeleted.html +2 -2
- package/docs/types/BinaryTreeNodeId.html +2 -2
- package/docs/types/BinaryTreeNodePropertyName.html +2 -2
- package/docs/types/DFSOrderPattern.html +2 -2
- package/docs/types/DijkstraResult.html +2 -2
- package/docs/types/Direction.html +2 -2
- package/docs/types/DoublyLinkedListGetBy.html +2 -2
- package/docs/types/NodeOrPropertyName.html +2 -2
- package/docs/types/PriorityQueueComparator.html +2 -2
- package/docs/types/PriorityQueueDFSOrderPattern.html +2 -2
- package/docs/types/ResultByProperty.html +2 -2
- package/docs/types/ResultsByProperty.html +2 -2
- package/docs/types/SegmentTreeNodeVal.html +2 -2
- package/docs/types/SpecifyOptional.html +2 -2
- package/docs/types/Thunk.html +2 -2
- package/docs/types/ToThunkFn.html +2 -2
- package/docs/types/TopologicalStatus.html +2 -2
- package/docs/types/TreeMultiSetDeletedResult.html +2 -2
- package/docs/types/TrlAsyncFn.html +2 -2
- package/docs/types/TrlFn.html +2 -2
- package/docs/types/Turning.html +2 -2
- package/docs/types/VertexId.html +2 -2
- package/package.json +1 -3
- package/docs/interfaces/BinaryTreeNodeObj.html +0 -168
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./singly-linked-list"), exports);
|
|
18
18
|
__exportStar(require("./doubly-linked-list"), exports);
|
|
19
|
+
__exportStar(require("./skip-linked-list"), exports);
|
|
@@ -5,290 +5,153 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
export declare class SinglyLinkedListNode<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
set list(value: SinglyLinkedList<NodeVal> | null);
|
|
22
|
-
get index(): number | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* The `insertBefore` function inserts a new node with the given value before the current node in a singly linked list.
|
|
25
|
-
* @param {NodeVal} val - The parameter "val" is of type "NodeVal". It represents the value of the node that you want
|
|
26
|
-
* to insert before the current node.
|
|
27
|
-
* @returns The method is returning a SinglyLinkedList<NodeVal>.
|
|
28
|
-
*/
|
|
29
|
-
insertBefore(val: NodeVal): SinglyLinkedList<NodeVal>;
|
|
30
|
-
/**
|
|
31
|
-
* The function inserts a new node with the given value after the current node in a singly linked list.
|
|
32
|
-
* @param {NodeVal} val - The parameter `val` is the value of the node that you want to insert after the current node.
|
|
33
|
-
* @returns The method is returning a SinglyLinkedList<NodeVal>.
|
|
34
|
-
*/
|
|
35
|
-
insertAfter(val: NodeVal): SinglyLinkedList<NodeVal>;
|
|
36
|
-
/**
|
|
37
|
-
* The `remove()` function removes a node from a singly linked list.
|
|
38
|
-
* @returns The remove() method is returning a SinglyLinkedListNode<NodeVal> object.
|
|
39
|
-
*/
|
|
40
|
-
remove(): SinglyLinkedListNode<NodeVal>;
|
|
8
|
+
export declare class SinglyLinkedListNode<T = number> {
|
|
9
|
+
/**
|
|
10
|
+
* The constructor function initializes an instance of a class with a given value and sets the next property to null.
|
|
11
|
+
* @param {T} val - The "val" parameter is of type T, which means it can be any data type. It represents the value that
|
|
12
|
+
* will be stored in the node of a linked list.
|
|
13
|
+
*/
|
|
14
|
+
constructor(val: T);
|
|
15
|
+
private _val;
|
|
16
|
+
get val(): T;
|
|
17
|
+
set val(value: T);
|
|
18
|
+
private _next;
|
|
19
|
+
get next(): SinglyLinkedListNode<T> | null;
|
|
20
|
+
set next(value: SinglyLinkedListNode<T> | null);
|
|
41
21
|
}
|
|
42
|
-
export declare class SinglyLinkedList<
|
|
43
|
-
/**
|
|
44
|
-
* The constructor initializes a linked list with the given arguments as nodes.
|
|
45
|
-
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
|
|
46
|
-
* arguments of type NodeVal.
|
|
47
|
-
*/
|
|
48
|
-
constructor(...args: NodeVal[]);
|
|
49
|
-
protected _head: SinglyLinkedListNode<NodeVal> | null;
|
|
50
|
-
get head(): SinglyLinkedListNode<NodeVal> | null;
|
|
51
|
-
set head(value: SinglyLinkedListNode<NodeVal> | null);
|
|
52
|
-
protected _tail: SinglyLinkedListNode<NodeVal> | null;
|
|
53
|
-
get tail(): SinglyLinkedListNode<NodeVal> | null;
|
|
54
|
-
set tail(value: SinglyLinkedListNode<NodeVal> | null);
|
|
55
|
-
protected _size: number;
|
|
56
|
-
get size(): number;
|
|
57
|
-
set size(value: number);
|
|
58
|
-
/**
|
|
59
|
-
* The `from` function in TypeScript creates a new SinglyLinkedList instance from an iterable object.
|
|
60
|
-
* @param iterable - The `iterable` parameter is an object that can be iterated over, such as an array or a string. It
|
|
61
|
-
* contains a collection of elements of type `T`.
|
|
62
|
-
* @returns The method is returning a new instance of the SinglyLinkedList class.
|
|
63
|
-
*/
|
|
64
|
-
static from<T>(iterable: Iterable<T>): SinglyLinkedList<T>;
|
|
65
|
-
/**
|
|
66
|
-
* The `get` function returns the value of a node at a given index in a data structure.
|
|
67
|
-
* @param {number} index - The index parameter is a number that represents the position of the node in the data
|
|
68
|
-
* structure.
|
|
69
|
-
* @returns The method is returning the value of the node at the specified index if the node exists, otherwise it
|
|
70
|
-
* returns undefined.
|
|
71
|
-
*/
|
|
72
|
-
get(index: number): NodeVal | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* The function `getNode` returns the node at a given index in a singly linked list.
|
|
75
|
-
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
76
|
-
* retrieve from the linked list.
|
|
77
|
-
* @returns a SinglyLinkedListNode<NodeVal> object or undefined.
|
|
78
|
-
*/
|
|
79
|
-
getNode(index: number): SinglyLinkedListNode<NodeVal> | undefined;
|
|
80
|
-
/**
|
|
81
|
-
* The function `findNodeIndex` searches for a node in a singly linked list that satisfies a given condition and
|
|
82
|
-
* returns its index and the node itself.
|
|
83
|
-
* @param callbackFn - The callbackFn parameter is a function that takes three arguments: data, index, and list. It is
|
|
84
|
-
* used to determine whether a node in the singly linked list matches a certain condition. The function should return a
|
|
85
|
-
* boolean value indicating whether the condition is met for the given node.
|
|
86
|
-
* @returns The function `findNodeIndex` returns an object with two properties: `node` and `index`. The `node` property
|
|
87
|
-
* contains the node that matches the condition specified in the `callbackFn` function, and the `index` property
|
|
88
|
-
* contains the index of that node in the linked list. If no node matches the condition, the function returns
|
|
89
|
-
* `undefined`.
|
|
90
|
-
*/
|
|
91
|
-
findNodeIndex(callbackFn: (data: NodeVal, index: number, list: SinglyLinkedList<NodeVal>) => boolean): ({
|
|
92
|
-
node: SinglyLinkedListNode<NodeVal>;
|
|
93
|
-
index: number;
|
|
94
|
-
}) | undefined;
|
|
95
|
-
/**
|
|
96
|
-
* The findNode function searches for a node in a singly linked list based on a given callback function.
|
|
97
|
-
* @param callbackFn - A callback function that takes three parameters: data, index, and list. It returns a boolean
|
|
98
|
-
* value indicating whether the current node matches the desired criteria.
|
|
99
|
-
* @returns The function `findNode` returns a `SinglyLinkedListNode<NodeVal>` if a node satisfying the condition
|
|
100
|
-
* specified by the `callbackFn` is found in the linked list. If no such node is found, it returns `undefined`.
|
|
101
|
-
*/
|
|
102
|
-
findNode(callbackFn: (data: NodeVal, index: number, list: SinglyLinkedList<NodeVal>) => boolean): SinglyLinkedListNode<NodeVal> | undefined;
|
|
22
|
+
export declare class SinglyLinkedList<T> {
|
|
103
23
|
/**
|
|
104
|
-
* The
|
|
105
|
-
* returns the value of the found node.
|
|
106
|
-
* @param callbackFn - A callback function that takes three parameters: data, index, and list. It returns a boolean
|
|
107
|
-
* value indicating whether the condition is met for a particular node in the linked list.
|
|
108
|
-
* @returns The method `find` returns the `NodeVal` value of the first node in the linked list that satisfies the
|
|
109
|
-
* condition specified by the `callbackFn` function. If no node satisfies the condition, it returns `undefined`.
|
|
24
|
+
* The constructor initializes the linked list with an empty head, tail, and length.
|
|
110
25
|
*/
|
|
111
|
-
|
|
26
|
+
constructor();
|
|
27
|
+
private _head;
|
|
28
|
+
get head(): SinglyLinkedListNode<T> | null;
|
|
29
|
+
set head(value: SinglyLinkedListNode<T> | null);
|
|
30
|
+
private _tail;
|
|
31
|
+
get tail(): SinglyLinkedListNode<T> | null;
|
|
32
|
+
set tail(value: SinglyLinkedListNode<T> | null);
|
|
33
|
+
private _length;
|
|
34
|
+
get length(): number;
|
|
35
|
+
protected set length(value: number);
|
|
112
36
|
/**
|
|
113
|
-
* The
|
|
114
|
-
*
|
|
115
|
-
* @param
|
|
116
|
-
*
|
|
117
|
-
* @returns The method `findIndex` returns a number.
|
|
37
|
+
* The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
|
|
38
|
+
* array.
|
|
39
|
+
* @param {T[]} data - The `data` parameter is an array of elements of type `T`.
|
|
40
|
+
* @returns The `fromArray` function returns a `SinglyLinkedList` object.
|
|
118
41
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
42
|
+
static fromArray<T>(data: T[]): SinglyLinkedList<T>;
|
|
43
|
+
getLength(): number;
|
|
121
44
|
/**
|
|
122
|
-
* The push function
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* of arguments of type NodeVal.
|
|
126
|
-
* @returns The size of the data structure after the nodes are appended.
|
|
45
|
+
* The `push` function adds a new node with the given data to the end of a singly linked list.
|
|
46
|
+
* @param {T} data - The "data" parameter represents the value that you want to add to the linked list. It can be of
|
|
47
|
+
* any type (T) as specified in the generic type declaration of the class or function.
|
|
127
48
|
*/
|
|
128
|
-
push(
|
|
49
|
+
push(data: T): void;
|
|
129
50
|
/**
|
|
130
|
-
* The `
|
|
131
|
-
*
|
|
132
|
-
* @returns The `
|
|
51
|
+
* The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
52
|
+
* pointers accordingly.
|
|
53
|
+
* @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
|
|
54
|
+
* the linked list is empty, it returns `null`.
|
|
133
55
|
*/
|
|
134
|
-
|
|
56
|
+
pop(): T | null;
|
|
135
57
|
/**
|
|
136
|
-
* The `
|
|
137
|
-
* @
|
|
138
|
-
* inserted in the linked list.
|
|
139
|
-
* @param {NodeVal} val - The `val` parameter represents the value of the node that you want to insert into the linked
|
|
140
|
-
* list.
|
|
141
|
-
* @returns The method `insertAt` returns the updated `SinglyLinkedList` object.
|
|
58
|
+
* The `shift()` function removes and returns the value of the first node in a linked list.
|
|
59
|
+
* @returns The value of the node that is being removed from the beginning of the linked list.
|
|
142
60
|
*/
|
|
143
|
-
|
|
61
|
+
shift(): T | null;
|
|
144
62
|
/**
|
|
145
|
-
* The
|
|
146
|
-
*
|
|
147
|
-
* @param node - The `node` parameter is of type `SinglyLinkedListNode<NodeVal>`, which represents a node in a singly
|
|
63
|
+
* The unshift function adds a new node with the given value to the beginning of a singly linked list.
|
|
64
|
+
* @param {T} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
|
|
148
65
|
* linked list.
|
|
149
|
-
* @returns the removed node.
|
|
150
|
-
*/
|
|
151
|
-
removeNode(node: SinglyLinkedListNode<NodeVal>): SinglyLinkedListNode<NodeVal>;
|
|
152
|
-
/**
|
|
153
|
-
* The `removeAt` function removes a node at a specified index from a singly linked list.
|
|
154
|
-
* @param {number} index - The index parameter is a number that represents the position of the node to be removed in
|
|
155
|
-
* the singly linked list.
|
|
156
|
-
* @returns The method `removeAt` returns a `SinglyLinkedListNode<NodeVal>` if the node at the specified index is
|
|
157
|
-
* found and removed successfully. If the node is not found, it returns `undefined`.
|
|
158
|
-
*/
|
|
159
|
-
removeAt(index: number): SinglyLinkedListNode<NodeVal> | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* The `insertBefore` function inserts a new node with a given value before a specified reference node in a singly
|
|
162
|
-
* linked list.
|
|
163
|
-
* @param referenceNode - The referenceNode parameter is the node in the linked list before which the new node will be
|
|
164
|
-
* inserted.
|
|
165
|
-
* @param {NodeVal} val - The value of the new node that will be inserted before the reference node.
|
|
166
|
-
* @returns The method is returning the updated SinglyLinkedList object.
|
|
167
|
-
*/
|
|
168
|
-
insertBefore(referenceNode: SinglyLinkedListNode<NodeVal>, val: NodeVal): SinglyLinkedList<NodeVal>;
|
|
169
|
-
/**
|
|
170
|
-
* The `sort` function uses the quicksort algorithm to sort the elements of a singly linked list based on a provided
|
|
171
|
-
* comparison function.
|
|
172
|
-
* @param start - The `start` parameter is the starting node of the sublist that needs to be sorted.
|
|
173
|
-
* @param end - The `end` parameter is a reference to the last node in the linked list. It is used as the pivot element
|
|
174
|
-
* for the quicksort algorithm.
|
|
175
|
-
* @returns The `sort` method is returning the sorted `SinglyLinkedList` object.
|
|
176
66
|
*/
|
|
177
|
-
|
|
67
|
+
unshift(val: T): void;
|
|
178
68
|
/**
|
|
179
|
-
* The `
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
183
|
-
*
|
|
69
|
+
* The function `getAt` returns the value at a specified index in a linked list, or null if the index is out of range.
|
|
70
|
+
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
71
|
+
* retrieve from the list.
|
|
72
|
+
* @returns The method `getAt(index: number): T | null` returns the value at the specified index in the linked list, or
|
|
73
|
+
* `null` if the index is out of bounds.
|
|
184
74
|
*/
|
|
185
|
-
|
|
75
|
+
getAt(index: number): T | null;
|
|
186
76
|
/**
|
|
187
|
-
* The `
|
|
188
|
-
* @
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
* The `pop()` function removes and returns the last element from a linked list.
|
|
193
|
-
* @returns The `pop()` method is returning a value of type `NodeVal` or `undefined`.
|
|
194
|
-
*/
|
|
195
|
-
pop(): NodeVal | undefined;
|
|
196
|
-
/**
|
|
197
|
-
* The merge function merges two singly linked lists by updating the next and prev pointers, as well as the head, tail,
|
|
198
|
-
* and size properties.
|
|
199
|
-
* @param list - The parameter "list" is a SinglyLinkedList object that contains nodes with data of type NodeVal.
|
|
200
|
-
*/
|
|
201
|
-
merge(list: SinglyLinkedList<NodeVal>): void;
|
|
202
|
-
/**
|
|
203
|
-
* The clear() function resets the linked list by setting the head and tail to null and the size to 0.
|
|
204
|
-
* @returns The "this" object is being returned.
|
|
77
|
+
* The function `getNodeAt` returns the node at a given index in a singly linked list.
|
|
78
|
+
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
79
|
+
* retrieve from the linked list. It indicates the zero-based index of the node we want to access.
|
|
80
|
+
* @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<T>` object if the node at the
|
|
81
|
+
* specified index exists, or `null` if the index is out of bounds.
|
|
205
82
|
*/
|
|
206
|
-
|
|
83
|
+
getNodeAt(index: number): SinglyLinkedListNode<T> | null;
|
|
207
84
|
/**
|
|
208
|
-
* The `
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* slicing. If no value is provided for `end`, or if the provided value is less than the `start` index, the slicing
|
|
214
|
-
* will continue until the end of the list.
|
|
215
|
-
* @returns a new SinglyLinkedList containing the sliced elements from the original list.
|
|
85
|
+
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
86
|
+
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
87
|
+
* data structure. It is of type number.
|
|
88
|
+
* @returns The method `deleteAt` returns the value of the node that was deleted, or `null` if the index is out of
|
|
89
|
+
* bounds.
|
|
216
90
|
*/
|
|
217
|
-
|
|
91
|
+
deleteAt(index: number): T | null;
|
|
92
|
+
delete(valueOrNode: T): boolean;
|
|
93
|
+
delete(valueOrNode: SinglyLinkedListNode<T>): boolean;
|
|
218
94
|
/**
|
|
219
|
-
* The
|
|
220
|
-
* @
|
|
95
|
+
* The `insertAt` function inserts a value at a specified index in a singly linked list.
|
|
96
|
+
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
97
|
+
* linked list. It is of type number.
|
|
98
|
+
* @param {T} val - The `val` parameter represents the value that you want to insert into the linked list at the
|
|
99
|
+
* specified index.
|
|
100
|
+
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
101
|
+
* if the index is out of bounds.
|
|
221
102
|
*/
|
|
222
|
-
|
|
103
|
+
insertAt(index: number, val: T): boolean;
|
|
223
104
|
/**
|
|
224
|
-
* The
|
|
225
|
-
*
|
|
226
|
-
* @
|
|
227
|
-
* parameters:
|
|
228
|
-
* @param [reverse=false] - A boolean value indicating whether to iterate over the linked list in reverse order. If set
|
|
229
|
-
* to true, the iteration will start from the tail of the linked list and move towards the head. If set to false
|
|
230
|
-
* (default), the iteration will start from the head and move towards the tail.
|
|
105
|
+
* The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
|
|
106
|
+
* whether it is empty or not.
|
|
107
|
+
* @returns A boolean value indicating whether the length of the object is equal to 0.
|
|
231
108
|
*/
|
|
232
|
-
|
|
109
|
+
isEmpty(): boolean;
|
|
233
110
|
/**
|
|
234
|
-
* The
|
|
235
|
-
* list with the results.
|
|
236
|
-
* @param callbackFn - A callback function that will be applied to each element in the linked list. It takes three
|
|
237
|
-
* parameters:
|
|
238
|
-
* @param [reverse=false] - The `reverse` parameter is a boolean value that determines whether the mapping should be
|
|
239
|
-
* done in reverse order or not. If `reverse` is set to `true`, the mapping will be done in reverse order. If `reverse`
|
|
240
|
-
* is set to `false` or not provided, the mapping will be
|
|
241
|
-
* @returns The `map` function is returning a new `SinglyLinkedList` object.
|
|
111
|
+
* The `clear` function resets the linked list by setting the head, tail, and length to null and 0 respectively.
|
|
242
112
|
*/
|
|
243
|
-
|
|
113
|
+
clear(): void;
|
|
244
114
|
/**
|
|
245
|
-
* The `
|
|
246
|
-
* @
|
|
247
|
-
* boolean value indicating whether the current element should be included in the filtered list or not.
|
|
248
|
-
* @param [reverse=false] - The `reverse` parameter is a boolean value that determines whether the filtered list should
|
|
249
|
-
* be reversed or not. If `reverse` is set to `true`, the filtered list will be in reverse order. If `reverse` is set
|
|
250
|
-
* to `false` or not provided, the filtered list will be in
|
|
251
|
-
* @returns The `filter` method is returning a new `SinglyLinkedList` object.
|
|
115
|
+
* The `toArray` function converts a linked list into an array.
|
|
116
|
+
* @returns The `toArray()` method is returning an array of type `T[]`.
|
|
252
117
|
*/
|
|
253
|
-
|
|
118
|
+
toArray(): T[];
|
|
254
119
|
/**
|
|
255
|
-
* The `
|
|
256
|
-
*
|
|
257
|
-
* @param callbackFn - A callback function that will be called for each element in the linked list. It takes four
|
|
258
|
-
* parameters:
|
|
259
|
-
* @param {any} [start] - The `start` parameter is an optional initial value for the accumulator. If provided, the
|
|
260
|
-
* `reduce` function will start accumulating from this value. If not provided, the `reduce` function will use the value
|
|
261
|
-
* of the first element in the linked list as the initial value.
|
|
262
|
-
* @param [reverse=false] - A boolean value indicating whether to iterate over the linked list in reverse order. If set
|
|
263
|
-
* to true, the iteration will start from the tail of the linked list and move towards the head. If set to false
|
|
264
|
-
* (default), the iteration will start from the head and move towards the tail.
|
|
265
|
-
* @returns The `reduce` method returns the accumulated value after applying the callback function to each element in
|
|
266
|
-
* the linked list.
|
|
120
|
+
* The `reverse` function reverses the order of the nodes in a singly linked list.
|
|
121
|
+
* @returns The reverse() method does not return anything. It has a return type of void.
|
|
267
122
|
*/
|
|
268
|
-
|
|
123
|
+
reverse(): void;
|
|
269
124
|
/**
|
|
270
|
-
* The
|
|
271
|
-
* @
|
|
125
|
+
* The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
|
|
126
|
+
* @param callback - A function that takes a value of type T as its parameter and returns a boolean value. This
|
|
127
|
+
* function is used to determine whether a particular value in the linked list satisfies a certain condition.
|
|
128
|
+
* @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
|
|
129
|
+
* the callback function. If no element satisfies the condition, it returns `null`.
|
|
272
130
|
*/
|
|
273
|
-
|
|
131
|
+
find(callback: (val: T) => boolean): T | null;
|
|
274
132
|
/**
|
|
275
|
-
* The `
|
|
276
|
-
*
|
|
277
|
-
* @
|
|
278
|
-
*
|
|
279
|
-
* character (' ').
|
|
280
|
-
* @returns The toString method is being returned as a string.
|
|
133
|
+
* The `indexOf` function returns the index of the first occurrence of a given value in a linked list.
|
|
134
|
+
* @param {T} value - The value parameter is the value that you want to find the index of in the linked list.
|
|
135
|
+
* @returns The method is returning the index of the first occurrence of the specified value in the linked list. If the
|
|
136
|
+
* value is not found, it returns -1.
|
|
281
137
|
*/
|
|
282
|
-
|
|
138
|
+
indexOf(value: T): number;
|
|
283
139
|
/**
|
|
284
|
-
* The function
|
|
140
|
+
* The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
|
|
141
|
+
* null.
|
|
142
|
+
* @param {T} value - The value parameter is the value that we want to search for in the linked list.
|
|
143
|
+
* @returns a `SinglyLinkedListNode<T>` if a node with the specified value is found in the linked list. If no node with
|
|
144
|
+
* the specified value is found, the function returns `null`.
|
|
285
145
|
*/
|
|
286
|
-
|
|
146
|
+
findNode(value: T): SinglyLinkedListNode<T> | null;
|
|
147
|
+
insertBefore(existingValue: T, newValue: T): boolean;
|
|
148
|
+
insertBefore(existingValue: SinglyLinkedListNode<T>, newValue: T): boolean;
|
|
149
|
+
insertAfter(existingValueOrNode: T, newValue: T): boolean;
|
|
150
|
+
insertAfter(existingValueOrNode: SinglyLinkedListNode<T>, newValue: T): boolean;
|
|
287
151
|
/**
|
|
288
|
-
* The function
|
|
289
|
-
* @param {
|
|
290
|
-
*
|
|
291
|
-
* @returns The value of the removed node if the node is not null, otherwise undefined.
|
|
152
|
+
* The function counts the number of occurrences of a given value in a linked list.
|
|
153
|
+
* @param {T} value - The value parameter is the value that you want to count the occurrences of in the linked list.
|
|
154
|
+
* @returns The count of occurrences of the given value in the linked list.
|
|
292
155
|
*/
|
|
293
|
-
|
|
156
|
+
countOccurrences(value: T): number;
|
|
294
157
|
}
|