min-heap-typed 1.50.1 → 1.50.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.
Files changed (85) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +120 -9
  2. package/dist/data-structures/base/iterable-base.js +143 -7
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +72 -47
  4. package/dist/data-structures/binary-tree/avl-tree.js +101 -72
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  6. package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
  8. package/dist/data-structures/binary-tree/binary-tree.js +484 -376
  9. package/dist/data-structures/binary-tree/bst.d.ts +92 -79
  10. package/dist/data-structures/binary-tree/bst.js +68 -76
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +127 -57
  12. package/dist/data-structures/binary-tree/rb-tree.js +152 -99
  13. package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
  14. package/dist/data-structures/binary-tree/segment-tree.js +127 -10
  15. package/dist/data-structures/binary-tree/tree-multimap.d.ts +72 -58
  16. package/dist/data-structures/binary-tree/tree-multimap.js +102 -85
  17. package/dist/data-structures/graph/abstract-graph.d.ts +1 -78
  18. package/dist/data-structures/graph/abstract-graph.js +3 -189
  19. package/dist/data-structures/graph/directed-graph.d.ts +73 -0
  20. package/dist/data-structures/graph/directed-graph.js +131 -0
  21. package/dist/data-structures/graph/map-graph.d.ts +8 -0
  22. package/dist/data-structures/graph/map-graph.js +14 -0
  23. package/dist/data-structures/graph/undirected-graph.d.ts +76 -7
  24. package/dist/data-structures/graph/undirected-graph.js +151 -18
  25. package/dist/data-structures/hash/hash-map.d.ts +254 -28
  26. package/dist/data-structures/hash/hash-map.js +347 -78
  27. package/dist/data-structures/heap/heap.d.ts +95 -25
  28. package/dist/data-structures/heap/heap.js +95 -26
  29. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
  30. package/dist/data-structures/linked-list/doubly-linked-list.js +141 -77
  31. package/dist/data-structures/linked-list/singly-linked-list.d.ts +154 -106
  32. package/dist/data-structures/linked-list/singly-linked-list.js +164 -115
  33. package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  34. package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
  35. package/dist/data-structures/matrix/matrix.d.ts +35 -4
  36. package/dist/data-structures/matrix/matrix.js +50 -11
  37. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  38. package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
  39. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  40. package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
  41. package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
  42. package/dist/data-structures/priority-queue/priority-queue.js +8 -0
  43. package/dist/data-structures/queue/deque.d.ts +139 -35
  44. package/dist/data-structures/queue/deque.js +200 -62
  45. package/dist/data-structures/queue/queue.d.ts +103 -49
  46. package/dist/data-structures/queue/queue.js +111 -49
  47. package/dist/data-structures/stack/stack.d.ts +51 -21
  48. package/dist/data-structures/stack/stack.js +58 -22
  49. package/dist/data-structures/tree/tree.d.ts +57 -3
  50. package/dist/data-structures/tree/tree.js +77 -11
  51. package/dist/data-structures/trie/trie.d.ts +135 -34
  52. package/dist/data-structures/trie/trie.js +153 -33
  53. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  54. package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
  55. package/dist/types/utils/utils.d.ts +1 -0
  56. package/package.json +2 -2
  57. package/src/data-structures/base/iterable-base.ts +184 -19
  58. package/src/data-structures/binary-tree/avl-tree.ts +134 -100
  59. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  60. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  61. package/src/data-structures/binary-tree/bst.ts +127 -136
  62. package/src/data-structures/binary-tree/rb-tree.ts +199 -166
  63. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  64. package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
  65. package/src/data-structures/graph/abstract-graph.ts +4 -211
  66. package/src/data-structures/graph/directed-graph.ts +152 -0
  67. package/src/data-structures/graph/map-graph.ts +15 -0
  68. package/src/data-structures/graph/undirected-graph.ts +171 -19
  69. package/src/data-structures/hash/hash-map.ts +389 -96
  70. package/src/data-structures/heap/heap.ts +97 -26
  71. package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
  72. package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
  73. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  74. package/src/data-structures/matrix/matrix.ts +52 -12
  75. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  76. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  77. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  78. package/src/data-structures/queue/deque.ts +225 -70
  79. package/src/data-structures/queue/queue.ts +118 -49
  80. package/src/data-structures/stack/stack.ts +63 -23
  81. package/src/data-structures/tree/tree.ts +89 -15
  82. package/src/data-structures/trie/trie.ts +173 -38
  83. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  84. package/src/types/data-structures/hash/hash-map.ts +4 -3
  85. package/src/types/utils/utils.ts +2 -0
@@ -8,33 +8,73 @@
8
8
  import type { ElementCallback } from '../../types';
9
9
  import { IterableElementBase } from '../base';
10
10
  export declare class SinglyLinkedListNode<E = any> {
11
- value: E;
12
- next: SinglyLinkedListNode<E> | undefined;
13
11
  /**
14
12
  * The constructor function initializes an instance of a class with a given value and sets the next property to undefined.
15
13
  * @param {E} value - The "value" parameter is of type E, which means it can be any data type. It represents the value that
16
14
  * will be stored in the node of a linked list.
17
15
  */
18
16
  constructor(value: E);
17
+ protected _value: E;
18
+ /**
19
+ * The function returns the value of a protected variable.
20
+ * @returns The value of the variable `_value` is being returned.
21
+ */
22
+ get value(): E;
23
+ /**
24
+ * The above function sets the value of a variable.
25
+ * @param {E} value - The parameter "value" is of type E, which means it can be any type.
26
+ */
27
+ set value(value: E);
28
+ protected _next: SinglyLinkedListNode<E> | undefined;
29
+ /**
30
+ * The `next` function returns the next node in a singly linked list.
31
+ * @returns The `next` property is being returned. It can be either a `SinglyLinkedListNode<E>`
32
+ * object or `undefined`.
33
+ */
34
+ get next(): SinglyLinkedListNode<E> | undefined;
35
+ /**
36
+ * The "next" property of a SinglyLinkedListNode is set to the provided value.
37
+ * @param {SinglyLinkedListNode<E> | undefined} value - The `value` parameter is of type
38
+ * `SinglyLinkedListNode<E> | undefined`. This means that it can accept either a
39
+ * `SinglyLinkedListNode` object or `undefined` as its value.
40
+ */
41
+ set next(value: SinglyLinkedListNode<E> | undefined);
19
42
  }
20
43
  export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
21
44
  /**
22
- * The constructor initializes the linked list with an empty head, tail, and length.
45
+ * The constructor initializes a new instance of a class with an optional iterable of elements.
46
+ * @param elements - The `elements` parameter is an optional iterable object that contains the
47
+ * initial elements to be added to the instance of the class. If no `elements` are provided, an empty
48
+ * array will be used as the default value.
23
49
  */
24
50
  constructor(elements?: Iterable<E>);
25
51
  protected _head: SinglyLinkedListNode<E> | undefined;
52
+ /**
53
+ * The `head` function returns the first node of a singly linked list.
54
+ * @returns The method is returning either a SinglyLinkedListNode object or undefined.
55
+ */
26
56
  get head(): SinglyLinkedListNode<E> | undefined;
27
57
  protected _tail: SinglyLinkedListNode<E> | undefined;
58
+ /**
59
+ * The `tail` function returns the last node of a singly linked list.
60
+ * @returns The method is returning either a SinglyLinkedListNode object or undefined.
61
+ */
28
62
  get tail(): SinglyLinkedListNode<E> | undefined;
29
63
  protected _size: number;
64
+ /**
65
+ * The function returns the size of an object.
66
+ * @returns The size of the object, which is a number.
67
+ */
30
68
  get size(): number;
31
69
  /**
32
- * Time Complexity: O(n) - Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
33
- * Space Complexity: O(n) - Linear space, as it creates a new node for each element in the array.
70
+ * Time Complexity: O(n)
71
+ * Space Complexity: O(n)
72
+ * Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
73
+ * Linear space, as it creates a new node for each element in the array.
34
74
  */
35
75
  /**
36
- * Time Complexity: O(n) - Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
37
- * Space Complexity: O(n) - Linear space, as it creates a new node for each element in the array.
76
+ * Time Complexity: O(n)
77
+ * Space Complexity: O(n)
38
78
  *
39
79
  * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
40
80
  * array.
@@ -43,12 +83,14 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
43
83
  */
44
84
  static fromArray<E>(data: E[]): SinglyLinkedList<E>;
45
85
  /**
46
- * Time Complexity: O(1) - Constant time, as it involves basic pointer adjustments.
47
- * Space Complexity: O(1) - Constant space, as it only creates a new node.
86
+ * Time Complexity: O(1)
87
+ * Space Complexity: O(1)
88
+ * Constant time, as it involves basic pointer adjustments.
89
+ * Constant space, as it only creates a new node.
48
90
  */
49
91
  /**
50
- * Time Complexity: O(1) - Constant time, as it involves basic pointer adjustments.
51
- * Space Complexity: O(1) - Constant space, as it only creates a new node.
92
+ * Time Complexity: O(1)
93
+ * Space Complexity: O(1)
52
94
  *
53
95
  * The `push` function adds a new node with the given value to the end of a singly linked list.
54
96
  * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
@@ -56,12 +98,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
56
98
  */
57
99
  push(value: E): boolean;
58
100
  /**
59
- * Time Complexity: O(1) - Constant time, as it involves basic pointer adjustments.
60
- * Space Complexity: O(1) - Constant space, as it only creates a new node.
101
+ * Time Complexity: O(1)
102
+ * Space Complexity: O(1)
61
103
  */
62
104
  /**
63
- * Time Complexity: O(1) - Constant time, as it involves basic pointer adjustments.
64
- * Space Complexity: O(1) - Constant space, as it only creates a new node.
105
+ * Time Complexity: O(1)
106
+ * Space Complexity: O(1)
65
107
  *
66
108
  * The `push` function adds a new node with the given value to the end of a singly linked list.
67
109
  * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
@@ -69,12 +111,13 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
69
111
  */
70
112
  addLast(value: E): boolean;
71
113
  /**
72
- * Time Complexity: O(n) - Linear time in the worst case, as it may need to traverse the list to find the last element.
73
- * Space Complexity: O(1) - Constant space.
114
+ * Time Complexity: O(n)
115
+ * Space Complexity: O(1)
116
+ * Linear time in the worst case, as it may need to traverse the list to find the last element.
74
117
  */
75
118
  /**
76
- * Time Complexity: O(n) - Linear time in the worst case, as it may need to traverse the list to find the last element.
77
- * Space Complexity: O(1) - Constant space.
119
+ * Time Complexity: O(n)
120
+ * Space Complexity: O(1)
78
121
  *
79
122
  * The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
80
123
  * pointers accordingly.
@@ -83,12 +126,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
83
126
  */
84
127
  pop(): E | undefined;
85
128
  /**
86
- * Time Complexity: O(n) - Linear time in the worst case, as it may need to traverse the list to find the last element.
87
- * Space Complexity: O(1) - Constant space.
129
+ * Time Complexity: O(n)
130
+ * Space Complexity: O(1)
88
131
  */
89
132
  /**
90
- * Time Complexity: O(n) - Linear time in the worst case, as it may need to traverse the list to find the last element.
91
- * Space Complexity: O(1) - Constant space.
133
+ * Time Complexity: O(n)
134
+ * Space Complexity: O(1)
92
135
  *
93
136
  * The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
94
137
  * pointers accordingly.
@@ -97,36 +140,36 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
97
140
  */
98
141
  pollLast(): E | undefined;
99
142
  /**
100
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
101
- * Space Complexity: O(1) - Constant space.
143
+ * Time Complexity: O(1)
144
+ * Space Complexity: O(1)
102
145
  */
103
146
  /**
104
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
105
- * Space Complexity: O(1) - Constant space.
147
+ * Time Complexity: O(1)
148
+ * Space Complexity: O(1)
106
149
  *
107
150
  * The `shift()` function removes and returns the value of the first node in a linked list.
108
151
  * @returns The value of the node that is being removed from the beginning of the linked list.
109
152
  */
110
153
  shift(): E | undefined;
111
154
  /**
112
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
113
- * Space Complexity: O(1) - Constant space.
155
+ * Time Complexity: O(1)
156
+ * Space Complexity: O(1)
114
157
  */
115
158
  /**
116
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
117
- * Space Complexity: O(1) - Constant space.
159
+ * Time Complexity: O(1)
160
+ * Space Complexity: O(1)
118
161
  *
119
162
  * The `pollFirst()` function removes and returns the value of the first node in a linked list.
120
163
  * @returns The value of the node that is being removed from the beginning of the linked list.
121
164
  */
122
165
  pollFirst(): E | undefined;
123
166
  /**
124
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
125
- * Space Complexity: O(1) - Constant space.
167
+ * Time Complexity: O(1)
168
+ * Space Complexity: O(1)
126
169
  */
127
170
  /**
128
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
129
- * Space Complexity: O(1) - Constant space.
171
+ * Time Complexity: O(1)
172
+ * Space Complexity: O(1)
130
173
  *
131
174
  * The unshift function adds a new node with the given value to the beginning of a singly linked list.
132
175
  * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
@@ -134,12 +177,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
134
177
  */
135
178
  unshift(value: E): boolean;
136
179
  /**
137
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
138
- * Space Complexity: O(1) - Constant space.
180
+ * Time Complexity: O(1)
181
+ * Space Complexity: O(1)
139
182
  */
140
183
  /**
141
- * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
142
- * Space Complexity: O(1) - Constant space.
184
+ * Time Complexity: O(1)
185
+ * Space Complexity: O(1)
143
186
  *
144
187
  * The addFirst function adds a new node with the given value to the beginning of a singly linked list.
145
188
  * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
@@ -147,27 +190,28 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
147
190
  */
148
191
  addFirst(value: E): boolean;
149
192
  /**
150
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
151
- * Space Complexity: O(1) - Constant space.
193
+ * Time Complexity: O(n)
194
+ * Space Complexity: O(1)
195
+ * Linear time, where n is the index, as it may need to traverse the list to find the desired node.
152
196
  */
153
197
  /**
154
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
155
- * Space Complexity: O(1) - Constant space.
198
+ * Time Complexity: O(n)
199
+ * Space Complexity: O(1)
156
200
  *
157
- * The function `getAt` returns the value at a specified index in a linked list, or undefined if the index is out of range.
201
+ * The function `at` returns the value at a specified index in a linked list, or undefined if the index is out of range.
158
202
  * @param {number} index - The index parameter is a number that represents the position of the element we want to
159
203
  * retrieve from the list.
160
- * @returns The method `getAt(index: number): E | undefined` returns the value at the specified index in the linked list, or
204
+ * @returns The method `at(index: number): E | undefined` returns the value at the specified index in the linked list, or
161
205
  * `undefined` if the index is out of bounds.
162
206
  */
163
- getAt(index: number): E | undefined;
207
+ at(index: number): E | undefined;
164
208
  /**
165
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
166
- * Space Complexity: O(1) - Constant space.
209
+ * Time Complexity: O(n)
210
+ * Space Complexity: O(1)
167
211
  */
168
212
  /**
169
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
170
- * Space Complexity: O(1) - Constant space.
213
+ * Time Complexity: O(n)
214
+ * Space Complexity: O(1)
171
215
  *
172
216
  * The function `getNodeAt` returns the node at a given index in a singly linked list.
173
217
  * @param {number} index - The `index` parameter is a number that represents the position of the node we want to
@@ -177,12 +221,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
177
221
  */
178
222
  getNodeAt(index: number): SinglyLinkedListNode<E> | undefined;
179
223
  /**
180
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
181
- * Space Complexity: O(1) - Constant space.
224
+ * Time Complexity: O(n)
225
+ * Space Complexity: O(1)
182
226
  */
183
227
  /**
184
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
185
- * Space Complexity: O(1) - Constant space.
228
+ * Time Complexity: O(n)
229
+ * Space Complexity: O(1)
186
230
  *
187
231
  * The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
188
232
  * @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
@@ -192,12 +236,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
192
236
  */
193
237
  deleteAt(index: number): boolean;
194
238
  /**
195
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
196
- * Space Complexity: O(1) - Constant space.
239
+ * Time Complexity: O(n)
240
+ * Space Complexity: O(1)
197
241
  */
198
242
  /**
199
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
200
- * Space Complexity: O(1) - Constant space.
243
+ * Time Complexity: O(n)
244
+ * Space Complexity: O(1)
201
245
  *
202
246
  * The delete function removes a node with a specific value from a singly linked list.
203
247
  * @param {E | SinglyLinkedListNode<E>} valueOrNode - The `valueOrNode` parameter can accept either a value of type `E`
@@ -207,12 +251,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
207
251
  */
208
252
  delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined): boolean;
209
253
  /**
210
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
211
- * Space Complexity: O(1) - Constant space.
254
+ * Time Complexity: O(n)
255
+ * Space Complexity: O(1)
212
256
  */
213
257
  /**
214
- * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
215
- * Space Complexity: O(1) - Constant space.
258
+ * Time Complexity: O(n)
259
+ * Space Complexity: O(1)
216
260
  *
217
261
  * The `addAt` function inserts a value at a specified index in a singly linked list.
218
262
  * @param {number} index - The index parameter represents the position at which the new value should be inserted in the
@@ -234,51 +278,38 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
234
278
  */
235
279
  clear(): void;
236
280
  /**
237
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
238
- * Space Complexity: O(n) - Linear space, as it creates an array with the same length as the list.
281
+ * Time Complexity: O(n)
282
+ * Space Complexity: O(n)
283
+ * Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
284
+ * Linear space, as it creates an array with the same length as the list.
239
285
  */
240
286
  /**
241
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
242
- * Space Complexity: O(n) - Linear space, as it creates an array with the same length as the list.
287
+ * Time Complexity: O(n)
288
+ * Space Complexity: O(n)
243
289
  *
244
290
  * The `toArray` function converts a linked list into an array.
245
291
  * @returns The `toArray()` method is returning an array of type `E[]`.
246
292
  */
247
293
  toArray(): E[];
248
294
  /**
249
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
250
- * Space Complexity: O(1) - Constant space.
295
+ * Time Complexity: O(n)
296
+ * Space Complexity: O(1)
251
297
  */
252
298
  /**
253
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
254
- * Space Complexity: O(1) - Constant space.
299
+ * Time Complexity: O(n)
300
+ * Space Complexity: O(1)
255
301
  *
256
302
  * The `reverse` function reverses the order of the nodes in a singly linked list.
257
303
  * @returns The reverse() method does not return anything. It has a return type of void.
258
304
  */
259
305
  reverse(): this;
260
306
  /**
261
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
262
- * Space Complexity: O(1) - Constant space.
263
- */
264
- /**
265
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
266
- * Space Complexity: O(1) - Constant space.
267
- *
268
- * The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
269
- * @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
270
- * function is used to determine whether a particular value in the linked list satisfies a certain condition.
271
- * @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
272
- * the callback function. If no element satisfies the condition, it returns `undefined`.
273
- */
274
- find(callback: (value: E) => boolean): E | undefined;
275
- /**
276
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
277
- * Space Complexity: O(1) - Constant space.
307
+ * Time Complexity: O(n)
308
+ * Space Complexity: O(1)
278
309
  */
279
310
  /**
280
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
281
- * Space Complexity: O(1) - Constant space.
311
+ * Time Complexity: O(n)
312
+ * Space Complexity: O(1)
282
313
  *
283
314
  * The `indexOf` function returns the index of the first occurrence of a given value in a linked list.
284
315
  * @param {E} value - The value parameter is the value that you want to find the index of in the linked list.
@@ -287,12 +318,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
287
318
  */
288
319
  indexOf(value: E): number;
289
320
  /**
290
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
291
- * Space Complexity: O(1) - Constant space.
321
+ * Time Complexity: O(n)
322
+ * Space Complexity: O(1)
292
323
  */
293
324
  /**
294
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
295
- * Space Complexity: O(1) - Constant space.
325
+ * Time Complexity: O(n)
326
+ * Space Complexity: O(1)
296
327
  *
297
328
  * The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
298
329
  * undefined.
@@ -302,12 +333,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
302
333
  */
303
334
  getNode(value: E): SinglyLinkedListNode<E> | undefined;
304
335
  /**
305
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
306
- * Space Complexity: O(1) - Constant space.
336
+ * Time Complexity: O(n)
337
+ * Space Complexity: O(1)
307
338
  */
308
339
  /**
309
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
310
- * Space Complexity: O(1) - Constant space.
340
+ * Time Complexity: O(n)
341
+ * Space Complexity: O(1)
311
342
  *
312
343
  * The `addBefore` function inserts a new value before an existing value in a singly linked list.
313
344
  * @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node that you want to insert the
@@ -318,12 +349,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
318
349
  */
319
350
  addBefore(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
320
351
  /**
321
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
322
- * Space Complexity: O(1) - Constant space.
352
+ * Time Complexity: O(n)
353
+ * Space Complexity: O(1)
323
354
  */
324
355
  /**
325
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
326
- * Space Complexity: O(1) - Constant space.
356
+ * Time Complexity: O(n)
357
+ * Space Complexity: O(1)
327
358
  *
328
359
  * The `addAfter` function inserts a new node with a given value after an existing node in a singly linked list.
329
360
  * @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node in the linked list after which
@@ -334,18 +365,32 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
334
365
  */
335
366
  addAfter(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
336
367
  /**
337
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
338
- * Space Complexity: O(1) - Constant space.
368
+ * Time Complexity: O(n)
369
+ * Space Complexity: O(1)
339
370
  */
340
371
  /**
341
- * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
342
- * Space Complexity: O(1) - Constant space.
372
+ * Time Complexity: O(n)
373
+ * Space Complexity: O(1)
343
374
  *
344
375
  * The function counts the number of occurrences of a given value in a linked list.
345
376
  * @param {E} value - The value parameter is the value that you want to count the occurrences of in the linked list.
346
377
  * @returns The count of occurrences of the given value in the linked list.
347
378
  */
348
379
  countOccurrences(value: E): number;
380
+ /**
381
+ * Time Complexity: O(n)
382
+ * Space Complexity: O(n)
383
+ */
384
+ /**
385
+ * Time Complexity: O(n)
386
+ * Space Complexity: O(n)
387
+ *
388
+ * The `clone` function returns a new instance of the `SinglyLinkedList` class with the same values
389
+ * as the original list.
390
+ * @returns The `clone()` method is returning a new instance of the `SinglyLinkedList` class, which
391
+ * is a clone of the original list.
392
+ */
393
+ clone(): SinglyLinkedList<E>;
349
394
  /**
350
395
  * Time Complexity: O(n)
351
396
  * Space Complexity: O(n)
@@ -369,7 +414,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
369
414
  */
370
415
  filter(callback: ElementCallback<E, boolean>, thisArg?: any): SinglyLinkedList<E>;
371
416
  /**
372
- * Time Complexity: O(n), where n is the number of elements in the linked list.
417
+ * Time Complexity: O(n)
373
418
  * Space Complexity: O(n)
374
419
  */
375
420
  /**
@@ -387,5 +432,8 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
387
432
  * of applying the provided `callback` function to each element in the original list.
388
433
  */
389
434
  map<T>(callback: ElementCallback<E, T>, thisArg?: any): SinglyLinkedList<T>;
435
+ /**
436
+ * The function `_getIterator` returns an iterable iterator that yields the values of a linked list.
437
+ */
390
438
  protected _getIterator(): IterableIterator<E>;
391
439
  }