data-structure-typed 1.52.4 → 1.52.6

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 (183) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/README_zh-CN.md +216 -26
  4. package/benchmark/report.html +13 -13
  5. package/benchmark/report.json +158 -158
  6. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +1 -37
  7. package/dist/cjs/data-structures/base/iterable-element-base.js +1 -37
  8. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
  9. package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +2 -54
  10. package/dist/cjs/data-structures/base/iterable-entry-base.js +1 -49
  11. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
  13. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
  16. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -46
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
  19. package/dist/cjs/data-structures/binary-tree/binary-tree.js +300 -332
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/bst.d.ts +1 -40
  22. package/dist/cjs/data-structures/binary-tree/bst.js +12 -44
  23. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  24. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
  25. package/dist/cjs/data-structures/binary-tree/rb-tree.js +2 -50
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  27. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
  28. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +9 -41
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  30. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -75
  31. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -75
  32. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  33. package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -98
  34. package/dist/cjs/data-structures/graph/directed-graph.js +0 -98
  35. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  36. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -50
  37. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -50
  38. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  39. package/dist/cjs/data-structures/hash/hash-map.d.ts +5 -92
  40. package/dist/cjs/data-structures/hash/hash-map.js +27 -111
  41. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  42. package/dist/cjs/data-structures/heap/heap.d.ts +0 -32
  43. package/dist/cjs/data-structures/heap/heap.js +0 -32
  44. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  45. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
  46. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +5 -88
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  48. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
  49. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +2 -84
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  51. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
  52. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +1 -35
  53. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  54. package/dist/cjs/data-structures/queue/deque.d.ts +1 -98
  55. package/dist/cjs/data-structures/queue/deque.js +3 -99
  56. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  57. package/dist/cjs/data-structures/queue/queue.d.ts +1 -54
  58. package/dist/cjs/data-structures/queue/queue.js +0 -53
  59. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  60. package/dist/cjs/data-structures/stack/stack.d.ts +1 -34
  61. package/dist/cjs/data-structures/stack/stack.js +1 -34
  62. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  63. package/dist/cjs/data-structures/tree/tree.js +2 -1
  64. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  65. package/dist/cjs/data-structures/trie/trie.d.ts +0 -64
  66. package/dist/cjs/data-structures/trie/trie.js +0 -64
  67. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  68. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
  69. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +6 -0
  70. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
  71. package/dist/cjs/types/utils/utils.d.ts +13 -12
  72. package/dist/cjs/utils/number.d.ts +13 -0
  73. package/dist/cjs/utils/number.js +13 -0
  74. package/dist/cjs/utils/number.js.map +1 -1
  75. package/dist/cjs/utils/utils.d.ts +125 -3
  76. package/dist/cjs/utils/utils.js +177 -21
  77. package/dist/cjs/utils/utils.js.map +1 -1
  78. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +1 -37
  79. package/dist/mjs/data-structures/base/iterable-element-base.js +1 -37
  80. package/dist/mjs/data-structures/base/iterable-entry-base.d.ts +2 -54
  81. package/dist/mjs/data-structures/base/iterable-entry-base.js +1 -49
  82. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
  83. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
  84. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
  85. package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -46
  86. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
  87. package/dist/mjs/data-structures/binary-tree/binary-tree.js +299 -333
  88. package/dist/mjs/data-structures/binary-tree/bst.d.ts +1 -40
  89. package/dist/mjs/data-structures/binary-tree/bst.js +12 -44
  90. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
  91. package/dist/mjs/data-structures/binary-tree/rb-tree.js +2 -50
  92. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
  93. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +9 -41
  94. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -75
  95. package/dist/mjs/data-structures/graph/abstract-graph.js +0 -75
  96. package/dist/mjs/data-structures/graph/directed-graph.d.ts +0 -98
  97. package/dist/mjs/data-structures/graph/directed-graph.js +0 -98
  98. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +0 -50
  99. package/dist/mjs/data-structures/graph/undirected-graph.js +0 -50
  100. package/dist/mjs/data-structures/hash/hash-map.d.ts +5 -92
  101. package/dist/mjs/data-structures/hash/hash-map.js +27 -111
  102. package/dist/mjs/data-structures/heap/heap.d.ts +0 -32
  103. package/dist/mjs/data-structures/heap/heap.js +0 -32
  104. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
  105. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +5 -88
  106. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
  107. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +2 -84
  108. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
  109. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +1 -35
  110. package/dist/mjs/data-structures/queue/deque.d.ts +1 -98
  111. package/dist/mjs/data-structures/queue/deque.js +3 -99
  112. package/dist/mjs/data-structures/queue/queue.d.ts +1 -54
  113. package/dist/mjs/data-structures/queue/queue.js +0 -53
  114. package/dist/mjs/data-structures/stack/stack.d.ts +1 -34
  115. package/dist/mjs/data-structures/stack/stack.js +1 -34
  116. package/dist/mjs/data-structures/tree/tree.js +2 -1
  117. package/dist/mjs/data-structures/trie/trie.d.ts +0 -64
  118. package/dist/mjs/data-structures/trie/trie.js +0 -64
  119. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
  120. package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +5 -1
  121. package/dist/mjs/types/utils/utils.d.ts +13 -12
  122. package/dist/mjs/utils/number.d.ts +13 -0
  123. package/dist/mjs/utils/number.js +13 -0
  124. package/dist/mjs/utils/utils.d.ts +125 -3
  125. package/dist/mjs/utils/utils.js +177 -21
  126. package/dist/umd/data-structure-typed.js +411 -1475
  127. package/dist/umd/data-structure-typed.min.js +5 -4
  128. package/dist/umd/data-structure-typed.min.js.map +1 -1
  129. package/package.json +6 -6
  130. package/src/data-structures/base/iterable-element-base.ts +2 -42
  131. package/src/data-structures/base/iterable-entry-base.ts +3 -62
  132. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
  133. package/src/data-structures/binary-tree/avl-tree.ts +0 -57
  134. package/src/data-structures/binary-tree/binary-tree.ts +330 -359
  135. package/src/data-structures/binary-tree/bst.ts +11 -54
  136. package/src/data-structures/binary-tree/rb-tree.ts +2 -62
  137. package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
  138. package/src/data-structures/graph/abstract-graph.ts +0 -92
  139. package/src/data-structures/graph/directed-graph.ts +0 -122
  140. package/src/data-structures/graph/undirected-graph.ts +0 -62
  141. package/src/data-structures/hash/hash-map.ts +29 -133
  142. package/src/data-structures/heap/heap.ts +0 -40
  143. package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
  144. package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
  145. package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
  146. package/src/data-structures/queue/deque.ts +2 -125
  147. package/src/data-structures/queue/queue.ts +1 -68
  148. package/src/data-structures/stack/stack.ts +1 -43
  149. package/src/data-structures/tree/tree.ts +1 -1
  150. package/src/data-structures/trie/trie.ts +0 -80
  151. package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
  152. package/src/types/utils/utils.ts +17 -15
  153. package/src/utils/number.ts +13 -0
  154. package/src/utils/utils.ts +174 -18
  155. package/test/config.ts +8 -0
  156. package/test/integration/all-in-one.test.ts +1 -1
  157. package/test/integration/avl-tree.test.ts +1 -1
  158. package/test/integration/bst.test.ts +2 -2
  159. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +13 -13
  160. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +18 -13
  161. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +577 -167
  162. package/test/unit/data-structures/binary-tree/bst.test.ts +167 -23
  163. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  164. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +136 -13
  165. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +18 -13
  166. package/test/unit/data-structures/graph/directed-graph.test.ts +46 -32
  167. package/test/unit/data-structures/graph/map-graph.test.ts +24 -2
  168. package/test/unit/data-structures/graph/undirected-graph.test.ts +24 -24
  169. package/test/unit/data-structures/hash/hash-map.test.ts +225 -35
  170. package/test/unit/data-structures/heap/heap.test.ts +47 -39
  171. package/test/unit/data-structures/heap/min-heap.test.ts +5 -5
  172. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +34 -4
  173. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +32 -0
  174. package/test/unit/data-structures/matrix/matrix.test.ts +35 -5
  175. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +31 -0
  176. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +18 -0
  177. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +17 -0
  178. package/test/unit/data-structures/queue/deque.test.ts +288 -47
  179. package/test/unit/data-structures/queue/queue.test.ts +62 -37
  180. package/test/unit/data-structures/stack/stack.test.ts +30 -5
  181. package/test/unit/data-structures/tree/tree.test.ts +58 -0
  182. package/test/unit/data-structures/trie/trie.test.ts +46 -5
  183. package/test/unit/utils/utils.test.ts +169 -0
@@ -72,12 +72,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
72
72
  * @returns The size of the object, which is a number.
73
73
  */
74
74
  get size(): number;
75
- /**
76
- * Time Complexity: O(n)
77
- * Space Complexity: O(n)
78
- * Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
79
- * Linear space, as it creates a new node for each element in the array.
80
- */
81
75
  /**
82
76
  * Time Complexity: O(n)
83
77
  * Space Complexity: O(n)
@@ -88,10 +82,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
88
82
  * @returns The `fromArray` function returns a `SinglyLinkedList` object.
89
83
  */
90
84
  static fromArray<E>(data: E[]): SinglyLinkedList<E, any>;
91
- /**
92
- * Time Complexity: O(1)
93
- * Space Complexity: O(1)
94
- */
95
85
  /**
96
86
  * Time Complexity: O(1)
97
87
  * Space Complexity: O(1)
@@ -102,11 +92,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
102
92
  * @returns The `push` method is returning a boolean value, `true`.
103
93
  */
104
94
  push(element: E): boolean;
105
- /**
106
- * Time Complexity: O(n)
107
- * Space Complexity: O(1)
108
- * Linear time in the worst case, as it may need to traverse the list to find the last element.
109
- */
110
95
  /**
111
96
  * Time Complexity: O(n)
112
97
  * Space Complexity: O(1)
@@ -116,10 +101,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
116
101
  * list.
117
102
  */
118
103
  pop(): E | undefined;
119
- /**
120
- * Time Complexity: O(1)
121
- * Space Complexity: O(1)
122
- */
123
104
  /**
124
105
  * Time Complexity: O(1)
125
106
  * Space Complexity: O(1)
@@ -128,10 +109,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
128
109
  * @returns The value of the removed node.
129
110
  */
130
111
  shift(): E | undefined;
131
- /**
132
- * Time Complexity: O(1)
133
- * Space Complexity: O(1)
134
- */
135
112
  /**
136
113
  * Time Complexity: O(1)
137
114
  * Space Complexity: O(1)
@@ -142,10 +119,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
142
119
  * @returns The `unshift` method is returning a boolean value, `true`.
143
120
  */
144
121
  unshift(element: E): boolean;
145
- /**
146
- * Time Complexity: O(n)
147
- * Space Complexity: O(1)
148
- */
149
122
  /**
150
123
  * Time Complexity: O(n)
151
124
  * Space Complexity: O(1)
@@ -157,10 +130,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
157
130
  * `undefined` if the index is out of bounds.
158
131
  */
159
132
  at(index: number): E | undefined;
160
- /**
161
- * Time Complexity: O(n)
162
- * Space Complexity: O(1)
163
- */
164
133
  /**
165
134
  * Time Complexity: O(n)
166
135
  * Space Complexity: O(1)
@@ -172,10 +141,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
172
141
  * specified index exists, or `undefined` if the index is out of bounds.
173
142
  */
174
143
  getNodeAt(index: number): SinglyLinkedListNode<E> | undefined;
175
- /**
176
- * Time Complexity: O(n)
177
- * Space Complexity: O(1)
178
- */
179
144
  /**
180
145
  * Time Complexity: O(n)
181
146
  * Space Complexity: O(1)
@@ -187,10 +152,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
187
152
  * bounds.
188
153
  */
189
154
  deleteAt(index: number): boolean;
190
- /**
191
- * Time Complexity: O(n)
192
- * Space Complexity: O(1)
193
- */
194
155
  /**
195
156
  * Time Complexity: O(n)
196
157
  * Space Complexity: O(1)
@@ -202,10 +163,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
202
163
  * successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
203
164
  */
204
165
  delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined): boolean;
205
- /**
206
- * Time Complexity: O(n)
207
- * Space Complexity: O(1)
208
- */
209
166
  /**
210
167
  * Time Complexity: O(n)
211
168
  * Space Complexity: O(1)
@@ -229,12 +186,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
229
186
  * The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
230
187
  */
231
188
  clear(): void;
232
- /**
233
- * Time Complexity: O(n)
234
- * Space Complexity: O(n)
235
- * Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
236
- * Linear space, as it creates an array with the same length as the list.
237
- */
238
189
  /**
239
190
  * Time Complexity: O(n)
240
191
  * Space Complexity: O(n)
@@ -243,10 +194,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
243
194
  * @returns The `toArray()` method is returning an array of type `E[]`.
244
195
  */
245
196
  toArray(): E[];
246
- /**
247
- * Time Complexity: O(n)
248
- * Space Complexity: O(1)
249
- */
250
197
  /**
251
198
  * Time Complexity: O(n)
252
199
  * Space Complexity: O(1)
@@ -255,10 +202,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
255
202
  * @returns The reverse() method does not return anything. It has a return type of void.
256
203
  */
257
204
  reverse(): this;
258
- /**
259
- * Time Complexity: O(n)
260
- * Space Complexity: O(1)
261
- */
262
205
  /**
263
206
  * Time Complexity: O(n)
264
207
  * Space Complexity: O(1)
@@ -269,10 +212,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
269
212
  * value is not found, it returns -1.
270
213
  */
271
214
  indexOf(value: E): number;
272
- /**
273
- * Time Complexity: O(n)
274
- * Space Complexity: O(1)
275
- */
276
215
  /**
277
216
  * Time Complexity: O(n)
278
217
  * Space Complexity: O(1)
@@ -284,10 +223,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
284
223
  * the specified value is found, the function returns `undefined`.
285
224
  */
286
225
  getNode(value: E): SinglyLinkedListNode<E> | undefined;
287
- /**
288
- * Time Complexity: O(n)
289
- * Space Complexity: O(1)
290
- */
291
226
  /**
292
227
  * Time Complexity: O(n)
293
228
  * Space Complexity: O(1)
@@ -300,10 +235,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
300
235
  * inserted before the existing value, and `false` otherwise.
301
236
  */
302
237
  addBefore(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
303
- /**
304
- * Time Complexity: O(n)
305
- * Space Complexity: O(1)
306
- */
307
238
  /**
308
239
  * Time Complexity: O(n)
309
240
  * Space Complexity: O(1)
@@ -316,10 +247,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
316
247
  * existing value or node, and false if the existing value or node was not found in the linked list.
317
248
  */
318
249
  addAfter(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
319
- /**
320
- * Time Complexity: O(n)
321
- * Space Complexity: O(1)
322
- */
323
250
  /**
324
251
  * Time Complexity: O(n)
325
252
  * Space Complexity: O(1)
@@ -329,10 +256,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
329
256
  * @returns The count of occurrences of the given value in the linked list.
330
257
  */
331
258
  countOccurrences(value: E): number;
332
- /**
333
- * Time Complexity: O(n)
334
- * Space Complexity: O(n)
335
- */
336
259
  /**
337
260
  * Time Complexity: O(n)
338
261
  * Space Complexity: O(n)
@@ -343,10 +266,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
343
266
  * is a clone of the original list.
344
267
  */
345
268
  clone(): SinglyLinkedList<E, R>;
346
- /**
347
- * Time Complexity: O(n)
348
- * Space Complexity: O(n)
349
- */
350
269
  /**
351
270
  * Time Complexity: O(n)
352
271
  * Space Complexity: O(n)
@@ -368,8 +287,7 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
368
287
  /**
369
288
  * Time Complexity: O(n)
370
289
  * Space Complexity: O(n)
371
- */
372
- /**
290
+ *
373
291
  * The `map` function takes a callback function and returns a new SinglyLinkedList with the results
374
292
  * of applying the callback to each element in the original list.
375
293
  * @param callback - The `callback` parameter is a function that will be called for each element in
@@ -97,12 +97,6 @@ export class SinglyLinkedList extends IterableElementBase {
97
97
  get size() {
98
98
  return this._size;
99
99
  }
100
- /**
101
- * Time Complexity: O(n)
102
- * Space Complexity: O(n)
103
- * Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
104
- * Linear space, as it creates a new node for each element in the array.
105
- */
106
100
  /**
107
101
  * Time Complexity: O(n)
108
102
  * Space Complexity: O(n)
@@ -119,10 +113,6 @@ export class SinglyLinkedList extends IterableElementBase {
119
113
  }
120
114
  return singlyLinkedList;
121
115
  }
122
- /**
123
- * Time Complexity: O(1)
124
- * Space Complexity: O(1)
125
- */
126
116
  /**
127
117
  * Time Complexity: O(1)
128
118
  * Space Complexity: O(1)
@@ -145,11 +135,6 @@ export class SinglyLinkedList extends IterableElementBase {
145
135
  this._size++;
146
136
  return true;
147
137
  }
148
- /**
149
- * Time Complexity: O(n)
150
- * Space Complexity: O(1)
151
- * Linear time in the worst case, as it may need to traverse the list to find the last element.
152
- */
153
138
  /**
154
139
  * Time Complexity: O(n)
155
140
  * Space Complexity: O(1)
@@ -178,10 +163,6 @@ export class SinglyLinkedList extends IterableElementBase {
178
163
  this._size--;
179
164
  return value;
180
165
  }
181
- /**
182
- * Time Complexity: O(1)
183
- * Space Complexity: O(1)
184
- */
185
166
  /**
186
167
  * Time Complexity: O(1)
187
168
  * Space Complexity: O(1)
@@ -197,10 +178,6 @@ export class SinglyLinkedList extends IterableElementBase {
197
178
  this._size--;
198
179
  return removedNode.value;
199
180
  }
200
- /**
201
- * Time Complexity: O(1)
202
- * Space Complexity: O(1)
203
- */
204
181
  /**
205
182
  * Time Complexity: O(1)
206
183
  * Space Complexity: O(1)
@@ -223,10 +200,6 @@ export class SinglyLinkedList extends IterableElementBase {
223
200
  this._size++;
224
201
  return true;
225
202
  }
226
- /**
227
- * Time Complexity: O(n)
228
- * Space Complexity: O(1)
229
- */
230
203
  /**
231
204
  * Time Complexity: O(n)
232
205
  * Space Complexity: O(1)
@@ -246,10 +219,6 @@ export class SinglyLinkedList extends IterableElementBase {
246
219
  }
247
220
  return current.value;
248
221
  }
249
- /**
250
- * Time Complexity: O(n)
251
- * Space Complexity: O(1)
252
- */
253
222
  /**
254
223
  * Time Complexity: O(n)
255
224
  * Space Complexity: O(1)
@@ -267,10 +236,6 @@ export class SinglyLinkedList extends IterableElementBase {
267
236
  }
268
237
  return current;
269
238
  }
270
- /**
271
- * Time Complexity: O(n)
272
- * Space Complexity: O(1)
273
- */
274
239
  /**
275
240
  * Time Complexity: O(n)
276
241
  * Space Complexity: O(1)
@@ -298,10 +263,6 @@ export class SinglyLinkedList extends IterableElementBase {
298
263
  this._size--;
299
264
  return true;
300
265
  }
301
- /**
302
- * Time Complexity: O(n)
303
- * Space Complexity: O(1)
304
- */
305
266
  /**
306
267
  * Time Complexity: O(n)
307
268
  * Space Complexity: O(1)
@@ -313,7 +274,7 @@ export class SinglyLinkedList extends IterableElementBase {
313
274
  * successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
314
275
  */
315
276
  delete(valueOrNode) {
316
- if (!valueOrNode)
277
+ if (valueOrNode === undefined)
317
278
  return false;
318
279
  let value;
319
280
  if (valueOrNode instanceof SinglyLinkedListNode) {
@@ -345,10 +306,6 @@ export class SinglyLinkedList extends IterableElementBase {
345
306
  }
346
307
  return false;
347
308
  }
348
- /**
349
- * Time Complexity: O(n)
350
- * Space Complexity: O(1)
351
- */
352
309
  /**
353
310
  * Time Complexity: O(n)
354
311
  * Space Complexity: O(1)
@@ -395,12 +352,6 @@ export class SinglyLinkedList extends IterableElementBase {
395
352
  this._tail = undefined;
396
353
  this._size = 0;
397
354
  }
398
- /**
399
- * Time Complexity: O(n)
400
- * Space Complexity: O(n)
401
- * Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
402
- * Linear space, as it creates an array with the same length as the list.
403
- */
404
355
  /**
405
356
  * Time Complexity: O(n)
406
357
  * Space Complexity: O(n)
@@ -417,10 +368,6 @@ export class SinglyLinkedList extends IterableElementBase {
417
368
  }
418
369
  return array;
419
370
  }
420
- /**
421
- * Time Complexity: O(n)
422
- * Space Complexity: O(1)
423
- */
424
371
  /**
425
372
  * Time Complexity: O(n)
426
373
  * Space Complexity: O(1)
@@ -443,10 +390,6 @@ export class SinglyLinkedList extends IterableElementBase {
443
390
  [this._head, this._tail] = [this.tail, this.head];
444
391
  return this;
445
392
  }
446
- /**
447
- * Time Complexity: O(n)
448
- * Space Complexity: O(1)
449
- */
450
393
  /**
451
394
  * Time Complexity: O(n)
452
395
  * Space Complexity: O(1)
@@ -468,10 +411,6 @@ export class SinglyLinkedList extends IterableElementBase {
468
411
  }
469
412
  return -1;
470
413
  }
471
- /**
472
- * Time Complexity: O(n)
473
- * Space Complexity: O(1)
474
- */
475
414
  /**
476
415
  * Time Complexity: O(n)
477
416
  * Space Complexity: O(1)
@@ -492,10 +431,6 @@ export class SinglyLinkedList extends IterableElementBase {
492
431
  }
493
432
  return undefined;
494
433
  }
495
- /**
496
- * Time Complexity: O(n)
497
- * Space Complexity: O(1)
498
- */
499
434
  /**
500
435
  * Time Complexity: O(n)
501
436
  * Space Complexity: O(1)
@@ -534,10 +469,6 @@ export class SinglyLinkedList extends IterableElementBase {
534
469
  }
535
470
  return false;
536
471
  }
537
- /**
538
- * Time Complexity: O(n)
539
- * Space Complexity: O(1)
540
- */
541
472
  /**
542
473
  * Time Complexity: O(n)
543
474
  * Space Complexity: O(1)
@@ -569,10 +500,6 @@ export class SinglyLinkedList extends IterableElementBase {
569
500
  }
570
501
  return false;
571
502
  }
572
- /**
573
- * Time Complexity: O(n)
574
- * Space Complexity: O(1)
575
- */
576
503
  /**
577
504
  * Time Complexity: O(n)
578
505
  * Space Complexity: O(1)
@@ -592,10 +519,6 @@ export class SinglyLinkedList extends IterableElementBase {
592
519
  }
593
520
  return count;
594
521
  }
595
- /**
596
- * Time Complexity: O(n)
597
- * Space Complexity: O(n)
598
- */
599
522
  /**
600
523
  * Time Complexity: O(n)
601
524
  * Space Complexity: O(n)
@@ -608,10 +531,6 @@ export class SinglyLinkedList extends IterableElementBase {
608
531
  clone() {
609
532
  return new SinglyLinkedList(this, { toElementFn: this.toElementFn });
610
533
  }
611
- /**
612
- * Time Complexity: O(n)
613
- * Space Complexity: O(n)
614
- */
615
534
  /**
616
535
  * Time Complexity: O(n)
617
536
  * Space Complexity: O(n)
@@ -643,8 +562,7 @@ export class SinglyLinkedList extends IterableElementBase {
643
562
  /**
644
563
  * Time Complexity: O(n)
645
564
  * Space Complexity: O(n)
646
- */
647
- /**
565
+ *
648
566
  * The `map` function takes a callback function and returns a new SinglyLinkedList with the results
649
567
  * of applying the callback to each element in the original list.
650
568
  * @param callback - The `callback` parameter is a function that will be called for each element in
@@ -46,10 +46,6 @@ export declare class SkipList<K, V> {
46
46
  * @returns The probability value stored in the protected variable `_probability` is being returned.
47
47
  */
48
48
  get probability(): number;
49
- /**
50
- * Time Complexity: O(log n)
51
- * Space Complexity: O(1)
52
- */
53
49
  /**
54
50
  * Time Complexity: O(1)
55
51
  * Space Complexity: O(1)
@@ -58,10 +54,6 @@ export declare class SkipList<K, V> {
58
54
  * @returns The value of the first element, or undefined if the Skip List is empty.
59
55
  */
60
56
  get first(): V | undefined;
61
- /**
62
- * Time Complexity: O(log n)
63
- * Space Complexity: O(1)
64
- */
65
57
  /**
66
58
  * Time Complexity: O(log n)
67
59
  * Space Complexity: O(1)
@@ -70,10 +62,6 @@ export declare class SkipList<K, V> {
70
62
  * @returns The value of the last element, or undefined if the Skip List is empty.
71
63
  */
72
64
  get last(): V | undefined;
73
- /**
74
- * Time Complexity: O(log n)
75
- * Space Complexity: O(1)
76
- */
77
65
  /**
78
66
  * Time Complexity: O(log n)
79
67
  * Space Complexity: O(1)
@@ -84,10 +72,6 @@ export declare class SkipList<K, V> {
84
72
  * List.
85
73
  */
86
74
  add(key: K, value: V): void;
87
- /**
88
- * Time Complexity: O(log n)
89
- * Space Complexity: O(1)
90
- */
91
75
  /**
92
76
  * Time Complexity: O(log n)
93
77
  * Space Complexity: O(1)
@@ -101,18 +85,13 @@ export declare class SkipList<K, V> {
101
85
  /**
102
86
  * Time Complexity: O(log n)
103
87
  * Space Complexity: O(1)
104
- */
105
- /**
88
+ *
106
89
  * The function checks if a key exists in a data structure.
107
90
  * @param {K} key - The parameter "key" is of type K, which represents the type of the key being
108
91
  * checked.
109
92
  * @returns a boolean value.
110
93
  */
111
94
  has(key: K): boolean;
112
- /**
113
- * Time Complexity: O(log n)
114
- * Space Complexity: O(1)
115
- */
116
95
  /**
117
96
  * Time Complexity: O(log n)
118
97
  * Space Complexity: O(1)
@@ -123,10 +102,6 @@ export declare class SkipList<K, V> {
123
102
  * skip list, and `false` if the key was not found in the skip list.
124
103
  */
125
104
  delete(key: K): boolean;
126
- /**
127
- * Time Complexity: O(log n)
128
- * Space Complexity: O(1)
129
- */
130
105
  /**
131
106
  * Time Complexity: O(log n)
132
107
  * Space Complexity: O(1)
@@ -136,10 +111,6 @@ export declare class SkipList<K, V> {
136
111
  * @returns The value of the first element greater than the given key, or undefined if there is no such element.
137
112
  */
138
113
  higher(key: K): V | undefined;
139
- /**
140
- * Time Complexity: O(log n)
141
- * Space Complexity: O(1)
142
- */
143
114
  /**
144
115
  * Time Complexity: O(log n)
145
116
  * Space Complexity: O(1)
@@ -149,11 +120,6 @@ export declare class SkipList<K, V> {
149
120
  * @returns The value of the last element less than the given key, or undefined if there is no such element.
150
121
  */
151
122
  lower(key: K): V | undefined;
152
- /**
153
- * Time Complexity: O(maxLevel)
154
- * Space Complexity: O(1)
155
- * where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
156
- */
157
123
  /**
158
124
  * Time Complexity: O(maxLevel)
159
125
  * Space Complexity: O(1)
@@ -62,10 +62,6 @@ export class SkipList {
62
62
  get probability() {
63
63
  return this._probability;
64
64
  }
65
- /**
66
- * Time Complexity: O(log n)
67
- * Space Complexity: O(1)
68
- */
69
65
  /**
70
66
  * Time Complexity: O(1)
71
67
  * Space Complexity: O(1)
@@ -77,10 +73,6 @@ export class SkipList {
77
73
  const firstNode = this.head.forward[0];
78
74
  return firstNode ? firstNode.value : undefined;
79
75
  }
80
- /**
81
- * Time Complexity: O(log n)
82
- * Space Complexity: O(1)
83
- */
84
76
  /**
85
77
  * Time Complexity: O(log n)
86
78
  * Space Complexity: O(1)
@@ -97,10 +89,6 @@ export class SkipList {
97
89
  }
98
90
  return current.value;
99
91
  }
100
- /**
101
- * Time Complexity: O(log n)
102
- * Space Complexity: O(1)
103
- */
104
92
  /**
105
93
  * Time Complexity: O(log n)
106
94
  * Space Complexity: O(1)
@@ -128,10 +116,6 @@ export class SkipList {
128
116
  this._level = Math.max(this.level, newNode.forward.length);
129
117
  }
130
118
  }
131
- /**
132
- * Time Complexity: O(log n)
133
- * Space Complexity: O(1)
134
- */
135
119
  /**
136
120
  * Time Complexity: O(log n)
137
121
  * Space Complexity: O(1)
@@ -157,8 +141,7 @@ export class SkipList {
157
141
  /**
158
142
  * Time Complexity: O(log n)
159
143
  * Space Complexity: O(1)
160
- */
161
- /**
144
+ *
162
145
  * The function checks if a key exists in a data structure.
163
146
  * @param {K} key - The parameter "key" is of type K, which represents the type of the key being
164
147
  * checked.
@@ -167,10 +150,6 @@ export class SkipList {
167
150
  has(key) {
168
151
  return this.get(key) !== undefined;
169
152
  }
170
- /**
171
- * Time Complexity: O(log n)
172
- * Space Complexity: O(1)
173
- */
174
153
  /**
175
154
  * Time Complexity: O(log n)
176
155
  * Space Complexity: O(1)
@@ -204,10 +183,6 @@ export class SkipList {
204
183
  }
205
184
  return false;
206
185
  }
207
- /**
208
- * Time Complexity: O(log n)
209
- * Space Complexity: O(1)
210
- */
211
186
  /**
212
187
  * Time Complexity: O(log n)
213
188
  * Space Complexity: O(1)
@@ -226,10 +201,6 @@ export class SkipList {
226
201
  const nextNode = current.forward[0];
227
202
  return nextNode ? nextNode.value : undefined;
228
203
  }
229
- /**
230
- * Time Complexity: O(log n)
231
- * Space Complexity: O(1)
232
- */
233
204
  /**
234
205
  * Time Complexity: O(log n)
235
206
  * Space Complexity: O(1)
@@ -251,11 +222,6 @@ export class SkipList {
251
222
  }
252
223
  return lastLess ? lastLess.value : undefined;
253
224
  }
254
- /**
255
- * Time Complexity: O(maxLevel)
256
- * Space Complexity: O(1)
257
- * where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
258
- */
259
225
  /**
260
226
  * Time Complexity: O(maxLevel)
261
227
  * Space Complexity: O(1)