data-structure-typed 1.42.8 → 1.43.0

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 (108) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +18 -18
  3. package/benchmark/report.html +12 -12
  4. package/benchmark/report.json +106 -106
  5. package/dist/cjs/src/data-structures/binary-tree/avl-tree.d.ts +88 -23
  6. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js +88 -23
  7. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +180 -74
  9. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +415 -236
  10. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
  11. package/dist/cjs/src/data-structures/binary-tree/bst.d.ts +121 -66
  12. package/dist/cjs/src/data-structures/binary-tree/bst.js +121 -67
  13. package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +72 -5
  15. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +95 -18
  16. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
  17. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.d.ts +82 -43
  18. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +82 -43
  19. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
  20. package/dist/cjs/src/data-structures/graph/abstract-graph.d.ts +139 -36
  21. package/dist/cjs/src/data-structures/graph/abstract-graph.js +147 -36
  22. package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
  23. package/dist/cjs/src/data-structures/graph/directed-graph.d.ts +126 -0
  24. package/dist/cjs/src/data-structures/graph/directed-graph.js +126 -0
  25. package/dist/cjs/src/data-structures/graph/directed-graph.js.map +1 -1
  26. package/dist/cjs/src/data-structures/graph/undirected-graph.d.ts +63 -0
  27. package/dist/cjs/src/data-structures/graph/undirected-graph.js +63 -0
  28. package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +1 -1
  29. package/dist/cjs/src/data-structures/heap/heap.d.ts +175 -12
  30. package/dist/cjs/src/data-structures/heap/heap.js +175 -12
  31. package/dist/cjs/src/data-structures/heap/heap.js.map +1 -1
  32. package/dist/cjs/src/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
  33. package/dist/cjs/src/data-structures/linked-list/doubly-linked-list.js +203 -0
  34. package/dist/cjs/src/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  35. package/dist/cjs/src/data-structures/linked-list/singly-linked-list.d.ts +182 -0
  36. package/dist/cjs/src/data-structures/linked-list/singly-linked-list.js +182 -0
  37. package/dist/cjs/src/data-structures/linked-list/singly-linked-list.js.map +1 -1
  38. package/dist/cjs/src/data-structures/linked-list/skip-linked-list.d.ts +64 -0
  39. package/dist/cjs/src/data-structures/linked-list/skip-linked-list.js +64 -0
  40. package/dist/cjs/src/data-structures/linked-list/skip-linked-list.js.map +1 -1
  41. package/dist/cjs/src/data-structures/queue/deque.d.ts +113 -3
  42. package/dist/cjs/src/data-structures/queue/deque.js +113 -3
  43. package/dist/cjs/src/data-structures/queue/deque.js.map +1 -1
  44. package/dist/cjs/src/data-structures/queue/queue.d.ts +87 -0
  45. package/dist/cjs/src/data-structures/queue/queue.js +87 -0
  46. package/dist/cjs/src/data-structures/queue/queue.js.map +1 -1
  47. package/dist/cjs/src/data-structures/stack/stack.d.ts +42 -0
  48. package/dist/cjs/src/data-structures/stack/stack.js +42 -0
  49. package/dist/cjs/src/data-structures/stack/stack.js.map +1 -1
  50. package/dist/cjs/src/data-structures/trie/trie.d.ts +76 -0
  51. package/dist/cjs/src/data-structures/trie/trie.js +76 -1
  52. package/dist/cjs/src/data-structures/trie/trie.js.map +1 -1
  53. package/dist/mjs/src/data-structures/binary-tree/avl-tree.d.ts +88 -23
  54. package/dist/mjs/src/data-structures/binary-tree/avl-tree.js +88 -23
  55. package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +180 -74
  56. package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +415 -236
  57. package/dist/mjs/src/data-structures/binary-tree/bst.d.ts +121 -66
  58. package/dist/mjs/src/data-structures/binary-tree/bst.js +121 -67
  59. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +72 -5
  60. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +95 -18
  61. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +82 -43
  62. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +82 -43
  63. package/dist/mjs/src/data-structures/graph/abstract-graph.d.ts +139 -36
  64. package/dist/mjs/src/data-structures/graph/abstract-graph.js +147 -36
  65. package/dist/mjs/src/data-structures/graph/directed-graph.d.ts +126 -0
  66. package/dist/mjs/src/data-structures/graph/directed-graph.js +126 -0
  67. package/dist/mjs/src/data-structures/graph/undirected-graph.d.ts +63 -0
  68. package/dist/mjs/src/data-structures/graph/undirected-graph.js +63 -0
  69. package/dist/mjs/src/data-structures/heap/heap.d.ts +175 -12
  70. package/dist/mjs/src/data-structures/heap/heap.js +175 -12
  71. package/dist/mjs/src/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
  72. package/dist/mjs/src/data-structures/linked-list/doubly-linked-list.js +203 -0
  73. package/dist/mjs/src/data-structures/linked-list/singly-linked-list.d.ts +182 -0
  74. package/dist/mjs/src/data-structures/linked-list/singly-linked-list.js +182 -0
  75. package/dist/mjs/src/data-structures/linked-list/skip-linked-list.d.ts +64 -0
  76. package/dist/mjs/src/data-structures/linked-list/skip-linked-list.js +64 -0
  77. package/dist/mjs/src/data-structures/queue/deque.d.ts +113 -3
  78. package/dist/mjs/src/data-structures/queue/deque.js +113 -3
  79. package/dist/mjs/src/data-structures/queue/queue.d.ts +87 -0
  80. package/dist/mjs/src/data-structures/queue/queue.js +87 -0
  81. package/dist/mjs/src/data-structures/stack/stack.d.ts +42 -0
  82. package/dist/mjs/src/data-structures/stack/stack.js +42 -0
  83. package/dist/mjs/src/data-structures/trie/trie.d.ts +76 -0
  84. package/dist/mjs/src/data-structures/trie/trie.js +76 -1
  85. package/dist/umd/data-structure-typed.min.js +1 -1
  86. package/dist/umd/data-structure-typed.min.js.map +1 -1
  87. package/package.json +1 -1
  88. package/src/data-structures/binary-tree/avl-tree.ts +97 -23
  89. package/src/data-structures/binary-tree/binary-tree.ts +465 -256
  90. package/src/data-structures/binary-tree/bst.ts +130 -68
  91. package/src/data-structures/binary-tree/rb-tree.ts +106 -19
  92. package/src/data-structures/binary-tree/tree-multimap.ts +88 -44
  93. package/src/data-structures/graph/abstract-graph.ts +133 -7
  94. package/src/data-structures/graph/directed-graph.ts +145 -1
  95. package/src/data-structures/graph/undirected-graph.ts +72 -0
  96. package/src/data-structures/heap/heap.ts +201 -12
  97. package/src/data-structures/linked-list/doubly-linked-list.ts +232 -0
  98. package/src/data-structures/linked-list/singly-linked-list.ts +208 -0
  99. package/src/data-structures/linked-list/skip-linked-list.ts +74 -0
  100. package/src/data-structures/queue/deque.ts +127 -3
  101. package/src/data-structures/queue/queue.ts +99 -0
  102. package/src/data-structures/stack/stack.ts +48 -0
  103. package/src/data-structures/trie/trie.ts +87 -4
  104. package/test/integration/index.html +24 -2
  105. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -1
  106. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +73 -5
  107. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +0 -1
  108. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -1
@@ -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.
@@ -147,9 +196,13 @@ class ArrayDeque {
147
196
  return this.nodes.length;
148
197
  }
149
198
  /**
150
- * O(n) time complexity of adding at the beginning and the end
199
+ * Time Complexity: O(1)
200
+ * Space Complexity: O(1)
151
201
  */
152
202
  /**
203
+ * Time Complexity: O(1)
204
+ * Space Complexity: O(1)
205
+ *
153
206
  * The function "addLast" adds a value to the end of an array.
154
207
  * @param {E} value - The value parameter represents the value that you want to add to the end of the array.
155
208
  * @returns The return value is the new length of the array after the value has been added.
@@ -158,6 +211,13 @@ class ArrayDeque {
158
211
  return this.nodes.push(value);
159
212
  }
160
213
  /**
214
+ * Time Complexity: O(1)
215
+ * Space Complexity: O(1)
216
+ */
217
+ /**
218
+ * Time Complexity: O(1)
219
+ * Space Complexity: O(1)
220
+ *
161
221
  * The function "popLast" returns and removes the last element from an array, or returns null if the array is empty.
162
222
  * @returns The method `popLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
163
223
  */
@@ -165,6 +225,13 @@ class ArrayDeque {
165
225
  return this.nodes.pop() ?? null;
166
226
  }
167
227
  /**
228
+ * Time Complexity: O(n)
229
+ * Space Complexity: O(1)
230
+ */
231
+ /**
232
+ * Time Complexity: O(n)
233
+ * Space Complexity: O(1)
234
+ *
168
235
  * The `popFirst` function removes and returns the first element from an array, or returns null if the array is empty.
169
236
  * @returns The `popFirst()` function returns the first element of the `_nodes` array, or `null` if the array is
170
237
  * empty.
@@ -173,9 +240,13 @@ class ArrayDeque {
173
240
  return this.nodes.shift() ?? null;
174
241
  }
175
242
  /**
176
- * O(n) time complexity of adding at the beginning and the end
243
+ * Time Complexity: O(n)
244
+ * Space Complexity: O(1)
177
245
  */
178
246
  /**
247
+ * Time Complexity: O(n)
248
+ * Space Complexity: O(1)
249
+ *
179
250
  * The function "addFirst" adds a value to the beginning of an array.
180
251
  * @param {E} value - The value parameter represents the value that you want to add to the beginning of the array.
181
252
  * @returns The return value of the `addFirst` function is the new length of the array `_nodes` after adding the
@@ -185,6 +256,13 @@ class ArrayDeque {
185
256
  return this.nodes.unshift(value);
186
257
  }
187
258
  /**
259
+ * Time Complexity: O(1)
260
+ * Space Complexity: O(1)
261
+ */
262
+ /**
263
+ * Time Complexity: O(1)
264
+ * Space Complexity: O(1)
265
+ *
188
266
  * The `getFirst` function returns the first element of an array or null if the array is empty.
189
267
  * @returns The function `getFirst()` is returning the first element (`E`) of the `_nodes` array. If the array is
190
268
  * empty, it will return `null`.
@@ -193,6 +271,13 @@ class ArrayDeque {
193
271
  return this.nodes[0] ?? null;
194
272
  }
195
273
  /**
274
+ * Time Complexity: O(1)
275
+ * Space Complexity: O(1)
276
+ */
277
+ /**
278
+ * Time Complexity: O(1)
279
+ * Space Complexity: O(1)
280
+ *
196
281
  * The `getLast` function returns the last element of an array or null if the array is empty.
197
282
  * @returns The method `getLast()` returns the last element of the `_nodes` array, or `null` if the array is empty.
198
283
  */
@@ -200,9 +285,13 @@ class ArrayDeque {
200
285
  return this.nodes[this.nodes.length - 1] ?? null;
201
286
  }
202
287
  /**
203
- * O(1) time complexity of obtaining the value
288
+ * Time Complexity: O(1)
289
+ * Space Complexity: O(1)
204
290
  */
205
291
  /**
292
+ * Time Complexity: O(1)
293
+ * Space Complexity: O(1)
294
+ *
206
295
  * The get function returns the element at the specified index in an array, or null if the index is out of bounds.
207
296
  * @param {number} index - The index parameter is a number that represents the position of the element you want to
208
297
  * retrieve from the array.
@@ -213,6 +302,13 @@ class ArrayDeque {
213
302
  return this.nodes[index] ?? null;
214
303
  }
215
304
  /**
305
+ * Time Complexity: O(1)
306
+ * Space Complexity: O(1)
307
+ */
308
+ /**
309
+ * Time Complexity: O(1)
310
+ * Space Complexity: O(1)
311
+ *
216
312
  * The set function assigns a value to a specific index in an array.
217
313
  * @param {number} index - The index parameter is a number that represents the position of the element in the array
218
314
  * that you want to set a new value for.
@@ -224,6 +320,13 @@ class ArrayDeque {
224
320
  return (this.nodes[index] = value);
225
321
  }
226
322
  /**
323
+ * Time Complexity: O(n)
324
+ * Space Complexity: O(1)
325
+ */
326
+ /**
327
+ * Time Complexity: O(n)
328
+ * Space Complexity: O(1)
329
+ *
227
330
  * The insert function adds a value at a specified index in an array.
228
331
  * @param {number} index - The index parameter specifies the position at which the value should be inserted in the
229
332
  * array. It is a number that represents the index of the array where the value should be inserted. The index starts
@@ -237,6 +340,13 @@ class ArrayDeque {
237
340
  return this.nodes.splice(index, 0, value);
238
341
  }
239
342
  /**
343
+ * Time Complexity: O(n)
344
+ * Space Complexity: O(1)
345
+ */
346
+ /**
347
+ * Time Complexity: O(n)
348
+ * Space Complexity: O(1)
349
+ *
240
350
  * The delete function removes an element from an array at a specified index.
241
351
  * @param {number} index - The index parameter specifies the position of the element to be removed from the array. It
242
352
  * 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
  */