min-heap-typed 1.42.8 → 1.42.9

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 (49) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +88 -23
  2. package/dist/data-structures/binary-tree/avl-tree.js +88 -23
  3. package/dist/data-structures/binary-tree/binary-tree.d.ts +180 -74
  4. package/dist/data-structures/binary-tree/binary-tree.js +388 -201
  5. package/dist/data-structures/binary-tree/bst.d.ts +121 -66
  6. package/dist/data-structures/binary-tree/bst.js +121 -67
  7. package/dist/data-structures/binary-tree/rb-tree.d.ts +72 -5
  8. package/dist/data-structures/binary-tree/rb-tree.js +95 -18
  9. package/dist/data-structures/binary-tree/tree-multimap.d.ts +82 -43
  10. package/dist/data-structures/binary-tree/tree-multimap.js +82 -43
  11. package/dist/data-structures/graph/abstract-graph.d.ts +139 -36
  12. package/dist/data-structures/graph/abstract-graph.js +147 -36
  13. package/dist/data-structures/graph/directed-graph.d.ts +126 -0
  14. package/dist/data-structures/graph/directed-graph.js +126 -0
  15. package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
  16. package/dist/data-structures/graph/undirected-graph.js +63 -0
  17. package/dist/data-structures/heap/heap.d.ts +175 -12
  18. package/dist/data-structures/heap/heap.js +175 -12
  19. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
  20. package/dist/data-structures/linked-list/doubly-linked-list.js +203 -0
  21. package/dist/data-structures/linked-list/singly-linked-list.d.ts +182 -0
  22. package/dist/data-structures/linked-list/singly-linked-list.js +182 -0
  23. package/dist/data-structures/linked-list/skip-linked-list.d.ts +64 -0
  24. package/dist/data-structures/linked-list/skip-linked-list.js +64 -0
  25. package/dist/data-structures/queue/deque.d.ts +113 -3
  26. package/dist/data-structures/queue/deque.js +113 -3
  27. package/dist/data-structures/queue/queue.d.ts +87 -0
  28. package/dist/data-structures/queue/queue.js +87 -0
  29. package/dist/data-structures/stack/stack.d.ts +42 -0
  30. package/dist/data-structures/stack/stack.js +42 -0
  31. package/dist/data-structures/trie/trie.d.ts +76 -0
  32. package/dist/data-structures/trie/trie.js +76 -1
  33. package/package.json +2 -2
  34. package/src/data-structures/binary-tree/avl-tree.ts +97 -23
  35. package/src/data-structures/binary-tree/binary-tree.ts +419 -204
  36. package/src/data-structures/binary-tree/bst.ts +130 -68
  37. package/src/data-structures/binary-tree/rb-tree.ts +106 -19
  38. package/src/data-structures/binary-tree/tree-multimap.ts +88 -44
  39. package/src/data-structures/graph/abstract-graph.ts +133 -7
  40. package/src/data-structures/graph/directed-graph.ts +145 -1
  41. package/src/data-structures/graph/undirected-graph.ts +72 -0
  42. package/src/data-structures/heap/heap.ts +201 -12
  43. package/src/data-structures/linked-list/doubly-linked-list.ts +232 -0
  44. package/src/data-structures/linked-list/singly-linked-list.ts +208 -0
  45. package/src/data-structures/linked-list/skip-linked-list.ts +74 -0
  46. package/src/data-structures/queue/deque.ts +127 -3
  47. package/src/data-structures/queue/queue.ts +99 -0
  48. package/src/data-structures/stack/stack.ts +48 -0
  49. package/src/data-structures/trie/trie.ts +87 -4
@@ -25,37 +25,86 @@ export declare class ObjectDeque<E = number> {
25
25
  protected _size: number;
26
26
  get size(): number;
27
27
  /**
28
+ * Time Complexity: O(1)
29
+ * Space Complexity: O(1)
30
+ */
31
+ /**
32
+ * Time Complexity: O(1)
33
+ * Space Complexity: O(1)
34
+ *
28
35
  * The "addFirst" function adds a value to the beginning of an array-like data structure.
29
36
  * @param {E} value - The `value` parameter represents the value that you want to add to the beginning of the data
30
37
  * structure.
31
38
  */
32
39
  addFirst(value: E): void;
33
40
  /**
41
+ * Time Complexity: O(1)
42
+ * Space Complexity: O(1)
43
+ */
44
+ /**
45
+ * Time Complexity: O(1)
46
+ * Space Complexity: O(1)
47
+ *
34
48
  * The addLast function adds a value to the end of an array-like data structure.
35
49
  * @param {E} value - The `value` parameter represents the value that you want to add to the end of the data structure.
36
50
  */
37
51
  addLast(value: E): void;
38
52
  /**
53
+ * Time Complexity: O(1)
54
+ * Space Complexity: O(1)
55
+ */
56
+ /**
57
+ * Time Complexity: O(1)
58
+ * Space Complexity: O(1)
59
+ *
39
60
  * The function `popFirst()` removes and returns the first element in a data structure.
40
61
  * @returns The value of the first element in the data structure.
41
62
  */
42
63
  popFirst(): E | undefined;
43
64
  /**
65
+ * Time Complexity: O(1)
66
+ * Space Complexity: O(1)
67
+ */
68
+ /**
69
+ * Time Complexity: O(1)
70
+ * Space Complexity: O(1)
71
+ *
44
72
  * The `getFirst` function returns the first element in an array-like data structure if it exists.
45
73
  * @returns The element at the first position of the `_nodes` array.
46
74
  */
47
75
  getFirst(): E | undefined;
48
76
  /**
77
+ * Time Complexity: O(1)
78
+ * Space Complexity: O(1)
79
+ */
80
+ /**
81
+ * Time Complexity: O(1)
82
+ * Space Complexity: O(1)
83
+ *
49
84
  * The `popLast()` function removes and returns the last element in a data structure.
50
85
  * @returns The value that was removed from the data structure.
51
86
  */
52
87
  popLast(): E | undefined;
53
88
  /**
89
+ * Time Complexity: O(1)
90
+ * Space Complexity: O(1)
91
+ */
92
+ /**
93
+ * Time Complexity: O(1)
94
+ * Space Complexity: O(1)
95
+ *
54
96
  * The `getLast()` function returns the last element in an array-like data structure.
55
97
  * @returns The last element in the array "_nodes" is being returned.
56
98
  */
57
99
  getLast(): E | undefined;
58
100
  /**
101
+ * Time Complexity: O(1)
102
+ * Space Complexity: O(1)
103
+ */
104
+ /**
105
+ * Time Complexity: O(1)
106
+ * Space Complexity: O(1)
107
+ *
59
108
  * The get function returns the element at the specified index in an array-like data structure.
60
109
  * @param {number} index - The index parameter is a number that represents the position of the element you want to
61
110
  * retrieve from the array.
@@ -74,29 +123,51 @@ export declare class ArrayDeque<E> {
74
123
  get nodes(): E[];
75
124
  get size(): number;
76
125
  /**
77
- * O(n) time complexity of adding at the beginning and the end
126
+ * Time Complexity: O(1)
127
+ * Space Complexity: O(1)
78
128
  */
79
129
  /**
130
+ * Time Complexity: O(1)
131
+ * Space Complexity: O(1)
132
+ *
80
133
  * The function "addLast" adds a value to the end of an array.
81
134
  * @param {E} value - The value parameter represents the value that you want to add to the end of the array.
82
135
  * @returns The return value is the new length of the array after the value has been added.
83
136
  */
84
137
  addLast(value: E): number;
85
138
  /**
139
+ * Time Complexity: O(1)
140
+ * Space Complexity: O(1)
141
+ */
142
+ /**
143
+ * Time Complexity: O(1)
144
+ * Space Complexity: O(1)
145
+ *
86
146
  * The function "popLast" returns and removes the last element from an array, or returns null if the array is empty.
87
147
  * @returns The method `popLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
88
148
  */
89
149
  popLast(): E | null;
90
150
  /**
151
+ * Time Complexity: O(n)
152
+ * Space Complexity: O(1)
153
+ */
154
+ /**
155
+ * Time Complexity: O(n)
156
+ * Space Complexity: O(1)
157
+ *
91
158
  * The `popFirst` function removes and returns the first element from an array, or returns null if the array is empty.
92
159
  * @returns The `popFirst()` function returns the first element of the `_nodes` array, or `null` if the array is
93
160
  * empty.
94
161
  */
95
162
  popFirst(): E | null;
96
163
  /**
97
- * O(n) time complexity of adding at the beginning and the end
164
+ * Time Complexity: O(n)
165
+ * Space Complexity: O(1)
98
166
  */
99
167
  /**
168
+ * Time Complexity: O(n)
169
+ * Space Complexity: O(1)
170
+ *
100
171
  * The function "addFirst" adds a value to the beginning of an array.
101
172
  * @param {E} value - The value parameter represents the value that you want to add to the beginning of the array.
102
173
  * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
@@ -104,20 +175,38 @@ export declare class ArrayDeque<E> {
104
175
  */
105
176
  addFirst(value: E): number;
106
177
  /**
178
+ * Time Complexity: O(1)
179
+ * Space Complexity: O(1)
180
+ */
181
+ /**
182
+ * Time Complexity: O(1)
183
+ * Space Complexity: O(1)
184
+ *
107
185
  * The `getFirst` function returns the first element of an array or null if the array is empty.
108
186
  * @returns The function `getFirst()` is returning the first element (`E`) of the `_nodes` array. If the array is
109
187
  * empty, it will return `null`.
110
188
  */
111
189
  getFirst(): E | null;
112
190
  /**
191
+ * Time Complexity: O(1)
192
+ * Space Complexity: O(1)
193
+ */
194
+ /**
195
+ * Time Complexity: O(1)
196
+ * Space Complexity: O(1)
197
+ *
113
198
  * The `getLast` function returns the last element of an array or null if the array is empty.
114
199
  * @returns The method `getLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
115
200
  */
116
201
  getLast(): E | null;
117
202
  /**
118
- * O(1) time complexity of obtaining the value
203
+ * Time Complexity: O(1)
204
+ * Space Complexity: O(1)
119
205
  */
120
206
  /**
207
+ * Time Complexity: O(1)
208
+ * Space Complexity: O(1)
209
+ *
121
210
  * The get function returns the element at the specified index in an array, or null if the index is out of bounds.
122
211
  * @param {number} index - The index parameter is a number that represents the position of the element you want to
123
212
  * retrieve from the array.
@@ -126,6 +215,13 @@ export declare class ArrayDeque<E> {
126
215
  */
127
216
  get(index: number): E | null;
128
217
  /**
218
+ * Time Complexity: O(1)
219
+ * Space Complexity: O(1)
220
+ */
221
+ /**
222
+ * Time Complexity: O(1)
223
+ * Space Complexity: O(1)
224
+ *
129
225
  * The set function assigns a value to a specific index in an array.
130
226
  * @param {number} index - The index parameter is a number that represents the position of the element in the array
131
227
  * that you want to set a new value for.
@@ -135,6 +231,13 @@ export declare class ArrayDeque<E> {
135
231
  */
136
232
  set(index: number, value: E): E;
137
233
  /**
234
+ * Time Complexity: O(n)
235
+ * Space Complexity: O(1)
236
+ */
237
+ /**
238
+ * Time Complexity: O(n)
239
+ * Space Complexity: O(1)
240
+ *
138
241
  * The insert function adds a value at a specified index in an array.
139
242
  * @param {number} index - The index parameter specifies the position at which the value should be inserted in the
140
243
  * array. It is a number that represents the index of the array where the value should be inserted. The index starts
@@ -146,6 +249,13 @@ export declare class ArrayDeque<E> {
146
249
  */
147
250
  insert(index: number, value: E): E[];
148
251
  /**
252
+ * Time Complexity: O(n)
253
+ * Space Complexity: O(1)
254
+ */
255
+ /**
256
+ * Time Complexity: O(n)
257
+ * Space Complexity: O(1)
258
+ *
149
259
  * The delete function removes an element from an array at a specified index.
150
260
  * @param {number} index - The index parameter specifies the position of the element to be removed from the array. It
151
261
  * is a number that represents the index of the element to be removed.
@@ -43,6 +43,13 @@ class ObjectDeque {
43
43
  return this._size;
44
44
  }
45
45
  /**
46
+ * Time Complexity: O(1)
47
+ * Space Complexity: O(1)
48
+ */
49
+ /**
50
+ * Time Complexity: O(1)
51
+ * Space Complexity: O(1)
52
+ *
46
53
  * The "addFirst" function adds a value to the beginning of an array-like data structure.
47
54
  * @param {E} value - The `value` parameter represents the value that you want to add to the beginning of the data
48
55
  * structure.
@@ -60,6 +67,13 @@ class ObjectDeque {
60
67
  this._size++;
61
68
  }
62
69
  /**
70
+ * Time Complexity: O(1)
71
+ * Space Complexity: O(1)
72
+ */
73
+ /**
74
+ * Time Complexity: O(1)
75
+ * Space Complexity: O(1)
76
+ *
63
77
  * The addLast function adds a value to the end of an array-like data structure.
64
78
  * @param {E} value - The `value` parameter represents the value that you want to add to the end of the data structure.
65
79
  */
@@ -76,6 +90,13 @@ class ObjectDeque {
76
90
  this._size++;
77
91
  }
78
92
  /**
93
+ * Time Complexity: O(1)
94
+ * Space Complexity: O(1)
95
+ */
96
+ /**
97
+ * Time Complexity: O(1)
98
+ * Space Complexity: O(1)
99
+ *
79
100
  * The function `popFirst()` removes and returns the first element in a data structure.
80
101
  * @returns The value of the first element in the data structure.
81
102
  */
@@ -89,6 +110,13 @@ class ObjectDeque {
89
110
  return value;
90
111
  }
91
112
  /**
113
+ * Time Complexity: O(1)
114
+ * Space Complexity: O(1)
115
+ */
116
+ /**
117
+ * Time Complexity: O(1)
118
+ * Space Complexity: O(1)
119
+ *
92
120
  * The `getFirst` function returns the first element in an array-like data structure if it exists.
93
121
  * @returns The element at the first position of the `_nodes` array.
94
122
  */
@@ -97,6 +125,13 @@ class ObjectDeque {
97
125
  return this.nodes[this.first];
98
126
  }
99
127
  /**
128
+ * Time Complexity: O(1)
129
+ * Space Complexity: O(1)
130
+ */
131
+ /**
132
+ * Time Complexity: O(1)
133
+ * Space Complexity: O(1)
134
+ *
100
135
  * The `popLast()` function removes and returns the last element in a data structure.
101
136
  * @returns The value that was removed from the data structure.
102
137
  */
@@ -110,6 +145,13 @@ class ObjectDeque {
110
145
  return value;
111
146
  }
112
147
  /**
148
+ * Time Complexity: O(1)
149
+ * Space Complexity: O(1)
150
+ */
151
+ /**
152
+ * Time Complexity: O(1)
153
+ * Space Complexity: O(1)
154
+ *
113
155
  * The `getLast()` function returns the last element in an array-like data structure.
114
156
  * @returns The last element in the array "_nodes" is being returned.
115
157
  */
@@ -118,6 +160,13 @@ class ObjectDeque {
118
160
  return this.nodes[this.last];
119
161
  }
120
162
  /**
163
+ * Time Complexity: O(1)
164
+ * Space Complexity: O(1)
165
+ */
166
+ /**
167
+ * Time Complexity: O(1)
168
+ * Space Complexity: O(1)
169
+ *
121
170
  * The get function returns the element at the specified index in an array-like data structure.
122
171
  * @param {number} index - The index parameter is a number that represents the position of the element you want to
123
172
  * retrieve from the array.
@@ -149,9 +198,13 @@ class ArrayDeque {
149
198
  return this.nodes.length;
150
199
  }
151
200
  /**
152
- * O(n) time complexity of adding at the beginning and the end
201
+ * Time Complexity: O(1)
202
+ * Space Complexity: O(1)
153
203
  */
154
204
  /**
205
+ * Time Complexity: O(1)
206
+ * Space Complexity: O(1)
207
+ *
155
208
  * The function "addLast" adds a value to the end of an array.
156
209
  * @param {E} value - The value parameter represents the value that you want to add to the end of the array.
157
210
  * @returns The return value is the new length of the array after the value has been added.
@@ -160,6 +213,13 @@ class ArrayDeque {
160
213
  return this.nodes.push(value);
161
214
  }
162
215
  /**
216
+ * Time Complexity: O(1)
217
+ * Space Complexity: O(1)
218
+ */
219
+ /**
220
+ * Time Complexity: O(1)
221
+ * Space Complexity: O(1)
222
+ *
163
223
  * The function "popLast" returns and removes the last element from an array, or returns null if the array is empty.
164
224
  * @returns The method `popLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
165
225
  */
@@ -168,6 +228,13 @@ class ArrayDeque {
168
228
  return (_a = this.nodes.pop()) !== null && _a !== void 0 ? _a : null;
169
229
  }
170
230
  /**
231
+ * Time Complexity: O(n)
232
+ * Space Complexity: O(1)
233
+ */
234
+ /**
235
+ * Time Complexity: O(n)
236
+ * Space Complexity: O(1)
237
+ *
171
238
  * The `popFirst` function removes and returns the first element from an array, or returns null if the array is empty.
172
239
  * @returns The `popFirst()` function returns the first element of the `_nodes` array, or `null` if the array is
173
240
  * empty.
@@ -177,9 +244,13 @@ class ArrayDeque {
177
244
  return (_a = this.nodes.shift()) !== null && _a !== void 0 ? _a : null;
178
245
  }
179
246
  /**
180
- * O(n) time complexity of adding at the beginning and the end
247
+ * Time Complexity: O(n)
248
+ * Space Complexity: O(1)
181
249
  */
182
250
  /**
251
+ * Time Complexity: O(n)
252
+ * Space Complexity: O(1)
253
+ *
183
254
  * The function "addFirst" adds a value to the beginning of an array.
184
255
  * @param {E} value - The value parameter represents the value that you want to add to the beginning of the array.
185
256
  * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
@@ -189,6 +260,13 @@ class ArrayDeque {
189
260
  return this.nodes.unshift(value);
190
261
  }
191
262
  /**
263
+ * Time Complexity: O(1)
264
+ * Space Complexity: O(1)
265
+ */
266
+ /**
267
+ * Time Complexity: O(1)
268
+ * Space Complexity: O(1)
269
+ *
192
270
  * The `getFirst` function returns the first element of an array or null if the array is empty.
193
271
  * @returns The function `getFirst()` is returning the first element (`E`) of the `_nodes` array. If the array is
194
272
  * empty, it will return `null`.
@@ -198,6 +276,13 @@ class ArrayDeque {
198
276
  return (_a = this.nodes[0]) !== null && _a !== void 0 ? _a : null;
199
277
  }
200
278
  /**
279
+ * Time Complexity: O(1)
280
+ * Space Complexity: O(1)
281
+ */
282
+ /**
283
+ * Time Complexity: O(1)
284
+ * Space Complexity: O(1)
285
+ *
201
286
  * The `getLast` function returns the last element of an array or null if the array is empty.
202
287
  * @returns The method `getLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
203
288
  */
@@ -206,9 +291,13 @@ class ArrayDeque {
206
291
  return (_a = this.nodes[this.nodes.length - 1]) !== null && _a !== void 0 ? _a : null;
207
292
  }
208
293
  /**
209
- * O(1) time complexity of obtaining the value
294
+ * Time Complexity: O(1)
295
+ * Space Complexity: O(1)
210
296
  */
211
297
  /**
298
+ * Time Complexity: O(1)
299
+ * Space Complexity: O(1)
300
+ *
212
301
  * The get function returns the element at the specified index in an array, or null if the index is out of bounds.
213
302
  * @param {number} index - The index parameter is a number that represents the position of the element you want to
214
303
  * retrieve from the array.
@@ -220,6 +309,13 @@ class ArrayDeque {
220
309
  return (_a = this.nodes[index]) !== null && _a !== void 0 ? _a : null;
221
310
  }
222
311
  /**
312
+ * Time Complexity: O(1)
313
+ * Space Complexity: O(1)
314
+ */
315
+ /**
316
+ * Time Complexity: O(1)
317
+ * Space Complexity: O(1)
318
+ *
223
319
  * The set function assigns a value to a specific index in an array.
224
320
  * @param {number} index - The index parameter is a number that represents the position of the element in the array
225
321
  * that you want to set a new value for.
@@ -231,6 +327,13 @@ class ArrayDeque {
231
327
  return (this.nodes[index] = value);
232
328
  }
233
329
  /**
330
+ * Time Complexity: O(n)
331
+ * Space Complexity: O(1)
332
+ */
333
+ /**
334
+ * Time Complexity: O(n)
335
+ * Space Complexity: O(1)
336
+ *
234
337
  * The insert function adds a value at a specified index in an array.
235
338
  * @param {number} index - The index parameter specifies the position at which the value should be inserted in the
236
339
  * array. It is a number that represents the index of the array where the value should be inserted. The index starts
@@ -244,6 +347,13 @@ class ArrayDeque {
244
347
  return this.nodes.splice(index, 0, value);
245
348
  }
246
349
  /**
350
+ * Time Complexity: O(n)
351
+ * Space Complexity: O(1)
352
+ */
353
+ /**
354
+ * Time Complexity: O(n)
355
+ * Space Complexity: O(1)
356
+ *
247
357
  * The delete function removes an element from an array at a specified index.
248
358
  * @param {number} index - The index parameter specifies the position of the element to be removed from the array. It
249
359
  * is a number that represents the index of the element to be removed.
@@ -53,58 +53,138 @@ export declare class Queue<E = any> {
53
53
  */
54
54
  static fromArray<E>(elements: E[]): Queue<E>;
55
55
  /**
56
+ * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
57
+ * Space Complexity: O(1) - no additional space is used.
58
+ */
59
+ /**
60
+ * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
61
+ * Space Complexity: O(1) - no additional space is used.
62
+ *
56
63
  * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
57
64
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
58
65
  * @returns The `add` method is returning a `Queue<E>` object.
59
66
  */
60
67
  push(element: E): Queue<E>;
61
68
  /**
69
+ * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
70
+ * Space Complexity: O(1) - no additional space is used.
71
+ */
72
+ /**
73
+ * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
74
+ * Space Complexity: O(1) - no additional space is used.
75
+ *
62
76
  * The `shift` function removes and returns the first element in the queue, and adjusts the internal data structure if
63
77
  * necessary to optimize performance.
64
78
  * @returns The function `shift()` returns either the first element in the queue or `null` if the queue is empty.
65
79
  */
66
80
  shift(): E | undefined;
67
81
  /**
82
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
83
+ * Space Complexity: O(1) - no additional space is used.
84
+ */
85
+ /**
86
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
87
+ * Space Complexity: O(1) - no additional space is used.
88
+ *
68
89
  * The `getFirst` function returns the first element of the array `_nodes` if it exists, otherwise it returns `null`.
69
90
  * @returns The `getFirst()` method returns the first element of the data structure, represented by the `_nodes` array at
70
91
  * the `_offset` index. If the data structure is empty (size is 0), it returns `null`.
71
92
  */
72
93
  getFirst(): E | undefined;
73
94
  /**
95
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
96
+ * Space Complexity: O(1) - no additional space is used.
97
+ */
98
+ /**
99
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
100
+ * Space Complexity: O(1) - no additional space is used.
101
+ *
74
102
  * The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `null`.
75
103
  * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at
76
104
  * the `_offset` index. If the data structure is empty (size is 0), it returns `null`.
77
105
  */
78
106
  peek(): E | undefined;
79
107
  /**
108
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
109
+ * Space Complexity: O(1) - no additional space is used.
110
+ */
111
+ /**
112
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
113
+ * Space Complexity: O(1) - no additional space is used.
114
+ *
80
115
  * The `getLast` function returns the last element in an array-like data structure, or null if the structure is empty.
81
116
  * @returns The method `getLast()` returns the last element of the `_nodes` array if the array is not empty. If the
82
117
  * array is empty, it returns `null`.
83
118
  */
84
119
  getLast(): E | undefined;
85
120
  /**
121
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
122
+ * Space Complexity: O(1) - no additional space is used.
123
+ */
124
+ /**
125
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
126
+ * Space Complexity: O(1) - no additional space is used.
127
+ *
86
128
  * The `peekLast` function returns the last element in an array-like data structure, or null if the structure is empty.
87
129
  * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the
88
130
  * array is empty, it returns `null`.
89
131
  */
90
132
  peekLast(): E | undefined;
91
133
  /**
134
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
135
+ * Space Complexity: O(1) - no additional space is used.
136
+ */
137
+ /**
138
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
139
+ * Space Complexity: O(1) - no additional space is used.
140
+ *
92
141
  * The enqueue function adds a value to the end of a queue.
93
142
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
94
143
  */
95
144
  enqueue(value: E): void;
96
145
  /**
146
+ * Time Complexity: O(n) - same as shift().
147
+ * Space Complexity: O(1) - same as shift().
148
+ */
149
+ /**
150
+ * Time Complexity: O(n) - same as shift().
151
+ * Space Complexity: O(1) - same as shift().
152
+ *
97
153
  * The `dequeue` function removes and returns the first element from a queue, or returns null if the queue is empty.
98
154
  * @returns The method is returning a value of type E or null.
99
155
  */
100
156
  dequeue(): E | undefined;
157
+ /**
158
+ * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
159
+ * Space Complexity: O(1) - no additional space is used.
160
+ */
161
+ /**
162
+ * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
163
+ * Space Complexity: O(1) - no additional space is used.
164
+ *
165
+ * @param index
166
+ */
101
167
  getAt(index: number): E | undefined;
102
168
  /**
169
+ * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
170
+ * Space Complexity: O(1) - no additional space is used.
171
+ */
172
+ /**
173
+ * Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
174
+ * Space Complexity: O(1) - no additional space is used.
175
+ *
103
176
  * The function checks if a data structure is empty by comparing its size to zero.
104
177
  * @returns {boolean} A boolean value indicating whether the size of the object is 0 or not.
105
178
  */
106
179
  isEmpty(): boolean;
107
180
  /**
181
+ * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
182
+ * Space Complexity: O(n) - where n is the number of elements in the queue.
183
+ */
184
+ /**
185
+ * Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
186
+ * Space Complexity: O(n) - where n is the number of elements in the queue.
187
+ *
108
188
  * The toArray() function returns an array of elements from the current offset to the end of the _nodes array.
109
189
  * @returns An array of type E is being returned.
110
190
  */
@@ -114,6 +194,13 @@ export declare class Queue<E = any> {
114
194
  */
115
195
  clear(): void;
116
196
  /**
197
+ * Time Complexity: O(n) - where n is the number of elements in the queue. It creates a shallow copy of the internal array.
198
+ * Space Complexity: O(n) - the space required is proportional to the number of elements in the queue.
199
+ */
200
+ /**
201
+ * Time Complexity: O(n) - where n is the number of elements in the queue. It creates a shallow copy of the internal array.
202
+ * Space Complexity: O(n) - the space required is proportional to the number of elements in the queue.
203
+ *
117
204
  * The `clone()` function returns a new Queue object with the same elements as the original Queue.
118
205
  * @returns The `clone()` method is returning a new instance of the `Queue` class.
119
206
  */