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
@@ -114,6 +114,7 @@ var dataStructureTyped = (() => {
114
114
  BinaryTree: () => BinaryTree,
115
115
  BinaryTreeNode: () => BinaryTreeNode,
116
116
  Character: () => Character,
117
+ DFSOperation: () => DFSOperation,
117
118
  Deque: () => Deque,
118
119
  DirectedEdge: () => DirectedEdge,
119
120
  DirectedGraph: () => DirectedGraph,
@@ -196,10 +197,6 @@ var dataStructureTyped = (() => {
196
197
  *[Symbol.iterator](...args) {
197
198
  yield* __yieldStar(this._getIterator(...args));
198
199
  }
199
- /**
200
- * Time Complexity: O(n)
201
- * Space Complexity: O(n)
202
- */
203
200
  /**
204
201
  * Time Complexity: O(n)
205
202
  * Space Complexity: O(n)
@@ -212,10 +209,6 @@ var dataStructureTyped = (() => {
212
209
  yield item;
213
210
  }
214
211
  }
215
- /**
216
- * Time Complexity: O(n)
217
- * Space Complexity: O(n)
218
- */
219
212
  /**
220
213
  * Time Complexity: O(n)
221
214
  * Space Complexity: O(n)
@@ -227,10 +220,6 @@ var dataStructureTyped = (() => {
227
220
  yield item[0];
228
221
  }
229
222
  }
230
- /**
231
- * Time Complexity: O(n)
232
- * Space Complexity: O(n)
233
- */
234
223
  /**
235
224
  * Time Complexity: O(n)
236
225
  * Space Complexity: O(n)
@@ -242,10 +231,6 @@ var dataStructureTyped = (() => {
242
231
  yield item[1];
243
232
  }
244
233
  }
245
- /**
246
- * Time Complexity: O(n)
247
- * Space Complexity: O(1)
248
- */
249
234
  /**
250
235
  * Time Complexity: O(n)
251
236
  * Space Complexity: O(1)
@@ -269,10 +254,6 @@ var dataStructureTyped = (() => {
269
254
  }
270
255
  return true;
271
256
  }
272
- /**
273
- * Time Complexity: O(n)
274
- * Space Complexity: O(1)
275
- */
276
257
  /**
277
258
  * Time Complexity: O(n)
278
259
  * Space Complexity: O(1)
@@ -297,14 +278,6 @@ var dataStructureTyped = (() => {
297
278
  }
298
279
  return false;
299
280
  }
300
- /**
301
- * Time Complexity: O(n)
302
- * Space Complexity: O(1)
303
- */
304
- /**
305
- * Time Complexity: O(n)
306
- * Space Complexity: O(1)
307
- */
308
281
  /**
309
282
  * Time Complexity: O(n)
310
283
  * Space Complexity: O(1)
@@ -325,10 +298,6 @@ var dataStructureTyped = (() => {
325
298
  callbackfn.call(thisArg, value, key, index++, this);
326
299
  }
327
300
  }
328
- /**
329
- * Time Complexity: O(n)
330
- * Space Complexity: O(1)
331
- */
332
301
  /**
333
302
  * Time Complexity: O(n)
334
303
  * Space Complexity: O(1)
@@ -355,10 +324,6 @@ var dataStructureTyped = (() => {
355
324
  }
356
325
  return;
357
326
  }
358
- /**
359
- * Time Complexity: O(n)
360
- * Space Complexity: O(1)
361
- */
362
327
  /**
363
328
  * Time Complexity: O(n)
364
329
  * Space Complexity: O(1)
@@ -377,10 +342,6 @@ var dataStructureTyped = (() => {
377
342
  }
378
343
  return false;
379
344
  }
380
- /**
381
- * Time Complexity: O(n)
382
- * Space Complexity: O(1)
383
- */
384
345
  /**
385
346
  * Time Complexity: O(n)
386
347
  * Space Complexity: O(1)
@@ -397,10 +358,6 @@ var dataStructureTyped = (() => {
397
358
  }
398
359
  return false;
399
360
  }
400
- /**
401
- * Time Complexity: O(n)
402
- * Space Complexity: O(1)
403
- */
404
361
  /**
405
362
  * Time Complexity: O(n)
406
363
  * Space Complexity: O(1)
@@ -444,10 +401,6 @@ var dataStructureTyped = (() => {
444
401
  }
445
402
  return accumulator;
446
403
  }
447
- /**
448
- * Time Complexity: O(n)
449
- * Space Complexity: O(n)
450
- */
451
404
  /**
452
405
  * Time Complexity: O(n)
453
406
  * Space Complexity: O(n)
@@ -455,7 +408,7 @@ var dataStructureTyped = (() => {
455
408
  * The print function logs the elements of an array to the console.
456
409
  */
457
410
  print() {
458
- console.log([...this]);
411
+ return [...this];
459
412
  }
460
413
  };
461
414
 
@@ -486,10 +439,6 @@ var dataStructureTyped = (() => {
486
439
  get toElementFn() {
487
440
  return this._toElementFn;
488
441
  }
489
- /**
490
- * Time Complexity: O(n)
491
- * Space Complexity: O(1)
492
- */
493
442
  /**
494
443
  * Time Complexity: O(n)
495
444
  * Space Complexity: O(1)
@@ -502,10 +451,6 @@ var dataStructureTyped = (() => {
502
451
  *[Symbol.iterator](...args) {
503
452
  yield* __yieldStar(this._getIterator(...args));
504
453
  }
505
- /**
506
- * Time Complexity: O(n)
507
- * Space Complexity: O(n)
508
- */
509
454
  /**
510
455
  * Time Complexity: O(n)
511
456
  * Space Complexity: O(n)
@@ -517,10 +462,6 @@ var dataStructureTyped = (() => {
517
462
  yield item;
518
463
  }
519
464
  }
520
- /**
521
- * Time Complexity: O(n)
522
- * Space Complexity: O(1)
523
- */
524
465
  /**
525
466
  * Time Complexity: O(n)
526
467
  * Space Complexity: O(1)
@@ -544,14 +485,6 @@ var dataStructureTyped = (() => {
544
485
  }
545
486
  return true;
546
487
  }
547
- /**
548
- * Time Complexity: O(n)
549
- * Space Complexity: O(1)
550
- */
551
- /**
552
- * Time Complexity: O(n)
553
- * Space Complexity: O(1)
554
- */
555
488
  /**
556
489
  * Time Complexity: O(n)
557
490
  * Space Complexity: O(1)
@@ -575,10 +508,6 @@ var dataStructureTyped = (() => {
575
508
  }
576
509
  return false;
577
510
  }
578
- /**
579
- * Time Complexity: O(n)
580
- * Space Complexity: O(1)
581
- */
582
511
  /**
583
512
  * Time Complexity: O(n)
584
513
  * Space Complexity: O(1)
@@ -598,10 +527,6 @@ var dataStructureTyped = (() => {
598
527
  callbackfn.call(thisArg, item, index++, this);
599
528
  }
600
529
  }
601
- /**
602
- * Time Complexity: O(n)
603
- * Space Complexity: O(1)
604
- */
605
530
  /**
606
531
  * Time Complexity: O(n)
607
532
  * Space Complexity: O(1)
@@ -643,10 +568,6 @@ var dataStructureTyped = (() => {
643
568
  }
644
569
  return false;
645
570
  }
646
- /**
647
- * Time Complexity: O(n)
648
- * Space Complexity: O(1)
649
- */
650
571
  /**
651
572
  * Time Complexity: O(n)
652
573
  * Space Complexity: O(1)
@@ -668,10 +589,6 @@ var dataStructureTyped = (() => {
668
589
  }
669
590
  return accumulator;
670
591
  }
671
- /**
672
- * Time Complexity: O(n)
673
- * Space Complexity: O(n)
674
- */
675
592
  /**
676
593
  * Time Complexity: O(n)
677
594
  * Space Complexity: O(n)
@@ -679,7 +596,7 @@ var dataStructureTyped = (() => {
679
596
  * The print function logs the elements of an array to the console.
680
597
  */
681
598
  print() {
682
- console.log([...this]);
599
+ return [...this];
683
600
  }
684
601
  };
685
602
 
@@ -760,28 +677,44 @@ var dataStructureTyped = (() => {
760
677
  const multiplier = Math.pow(10, digit);
761
678
  return Math.round(num * multiplier) / multiplier;
762
679
  };
763
- function isComparable(key) {
764
- const keyType = typeof key;
765
- if (keyType === "number")
766
- return !isNaN(key);
767
- if (keyType === "string")
768
- return true;
769
- if (keyType === "bigint")
770
- return true;
771
- if (keyType === "boolean")
772
- return true;
773
- if (keyType === "symbol")
680
+ function isPrimitiveComparable(value) {
681
+ const valueType = typeof value;
682
+ if (valueType === "number")
683
+ return !Number.isNaN(value);
684
+ return valueType === "bigint" || valueType === "string" || valueType === "boolean";
685
+ }
686
+ function tryObjectToPrimitive(obj) {
687
+ if (typeof obj.valueOf === "function") {
688
+ const valueOfResult = obj.valueOf();
689
+ if (valueOfResult !== obj) {
690
+ if (isPrimitiveComparable(valueOfResult))
691
+ return valueOfResult;
692
+ if (typeof valueOfResult === "object" && valueOfResult !== null)
693
+ return tryObjectToPrimitive(valueOfResult);
694
+ }
695
+ }
696
+ if (typeof obj.toString === "function") {
697
+ const stringResult = obj.toString();
698
+ if (stringResult !== "[object Object]")
699
+ return stringResult;
700
+ }
701
+ return null;
702
+ }
703
+ function isComparable(value, isForceObjectComparable = false) {
704
+ if (value === null || value === void 0)
774
705
  return false;
775
- if (keyType === "undefined")
706
+ if (isPrimitiveComparable(value))
707
+ return true;
708
+ if (typeof value !== "object")
776
709
  return false;
777
- if (keyType === "function")
778
- return isComparable(key());
779
- if (keyType === "object") {
780
- if (key === null)
781
- return true;
710
+ if (value instanceof Date)
711
+ return !Number.isNaN(value.getTime());
712
+ if (isForceObjectComparable)
713
+ return true;
714
+ const comparableValue = tryObjectToPrimitive(value);
715
+ if (comparableValue === null || comparableValue === void 0)
782
716
  return false;
783
- }
784
- return false;
717
+ return isPrimitiveComparable(comparableValue);
785
718
  }
786
719
 
787
720
  // src/utils/number.ts
@@ -920,8 +853,8 @@ var dataStructureTyped = (() => {
920
853
  if (this.isEntry(rawEle)) {
921
854
  key = rawEle[0];
922
855
  value = rawEle[1];
923
- } else if (this.toEntryFn) {
924
- const item = this.toEntryFn(rawEle);
856
+ } else if (this._toEntryFn) {
857
+ const item = this._toEntryFn(rawEle);
925
858
  key = item[0];
926
859
  value = item[1];
927
860
  }
@@ -987,8 +920,7 @@ var dataStructureTyped = (() => {
987
920
  /**
988
921
  * Time Complexity: O(n)
989
922
  * Space Complexity: O(n)
990
- */
991
- /**
923
+ *
992
924
  * The clone function creates a new HashMap with the same key-value pairs as
993
925
  * this one. The clone function is useful for creating a copy of an existing
994
926
  * HashMap, and then modifying that copy without affecting the original.
@@ -996,12 +928,8 @@ var dataStructureTyped = (() => {
996
928
  * @return A new hashmap with the same values as this one
997
929
  */
998
930
  clone() {
999
- return new _HashMap(this, { hashFn: this.hashFn, toEntryFn: this.toEntryFn });
931
+ return new _HashMap(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
1000
932
  }
1001
- /**
1002
- * Time Complexity: O(n)
1003
- * Space Complexity: O(n)
1004
- */
1005
933
  /**
1006
934
  * Time Complexity: O(n)
1007
935
  * Space Complexity: O(n)
@@ -1050,17 +978,6 @@ var dataStructureTyped = (() => {
1050
978
  }
1051
979
  return filteredMap;
1052
980
  }
1053
- /**
1054
- * The put function sets a value in a data structure using a specified key.
1055
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
1056
- * to the function.
1057
- * @param {V} value - The value parameter represents the value that you want to associate with the
1058
- * specified key in the data structure.
1059
- * @returns The method is returning a boolean value.
1060
- */
1061
- put(key, value) {
1062
- return this.set(key, value);
1063
- }
1064
981
  /**
1065
982
  * The function returns an iterator that yields key-value pairs from both an object store and an
1066
983
  * object map.
@@ -1093,7 +1010,7 @@ var dataStructureTyped = (() => {
1093
1010
  const keyType = typeof key;
1094
1011
  let strKey;
1095
1012
  if (keyType !== "string" && keyType !== "number" && keyType !== "symbol") {
1096
- strKey = this.hashFn(key);
1013
+ strKey = this._hashFn(key);
1097
1014
  } else {
1098
1015
  if (keyType === "number") {
1099
1016
  strKey = key;
@@ -1146,10 +1063,7 @@ var dataStructureTyped = (() => {
1146
1063
  }
1147
1064
  }
1148
1065
  if (entryOrRawElements) {
1149
- for (const el of entryOrRawElements) {
1150
- const [key, value] = this.toEntryFn(el);
1151
- this.set(key, value);
1152
- }
1066
+ this.setMany(entryOrRawElements);
1153
1067
  }
1154
1068
  }
1155
1069
  /**
@@ -1211,10 +1125,6 @@ var dataStructureTyped = (() => {
1211
1125
  get size() {
1212
1126
  return this._size;
1213
1127
  }
1214
- /**
1215
- * Time Complexity: O(1)
1216
- * Space Complexity: O(1)
1217
- */
1218
1128
  /**
1219
1129
  * Time Complexity: O(1)
1220
1130
  * Space Complexity: O(1)
@@ -1228,10 +1138,6 @@ var dataStructureTyped = (() => {
1228
1138
  return;
1229
1139
  return [this.head.key, this.head.value];
1230
1140
  }
1231
- /**
1232
- * Time Complexity: O(1)
1233
- * Space Complexity: O(1)
1234
- */
1235
1141
  /**
1236
1142
  * Time Complexity: O(1)
1237
1143
  * Space Complexity: O(1)
@@ -1266,10 +1172,6 @@ var dataStructureTyped = (() => {
1266
1172
  node = node.prev;
1267
1173
  }
1268
1174
  }
1269
- /**
1270
- * Time Complexity: O(1)
1271
- * Space Complexity: O(1)
1272
- */
1273
1175
  /**
1274
1176
  * Time Complexity: O(1)
1275
1177
  * Space Complexity: O(1)
@@ -1286,7 +1188,7 @@ var dataStructureTyped = (() => {
1286
1188
  let node;
1287
1189
  const isNewKey = !this.has(key);
1288
1190
  if (isWeakKey(key)) {
1289
- const hash = this.objHashFn(key);
1191
+ const hash = this._objHashFn(key);
1290
1192
  node = this.objMap.get(hash);
1291
1193
  if (!node && isNewKey) {
1292
1194
  node = { key: hash, value, prev: this.tail, next: this._sentinel };
@@ -1295,7 +1197,7 @@ var dataStructureTyped = (() => {
1295
1197
  node.value = value;
1296
1198
  }
1297
1199
  } else {
1298
- const hash = this.hashFn(key);
1200
+ const hash = this._hashFn(key);
1299
1201
  node = this.noObjMap[hash];
1300
1202
  if (!node && isNewKey) {
1301
1203
  this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
@@ -1328,8 +1230,17 @@ var dataStructureTyped = (() => {
1328
1230
  setMany(entryOrRawElements) {
1329
1231
  const results = [];
1330
1232
  for (const rawEle of entryOrRawElements) {
1331
- const [key, value] = this.toEntryFn(rawEle);
1332
- results.push(this.set(key, value));
1233
+ let key, value;
1234
+ if (this.isEntry(rawEle)) {
1235
+ key = rawEle[0];
1236
+ value = rawEle[1];
1237
+ } else if (this._toEntryFn) {
1238
+ const item = this._toEntryFn(rawEle);
1239
+ key = item[0];
1240
+ value = item[1];
1241
+ }
1242
+ if (key !== void 0 && value !== void 0)
1243
+ results.push(this.set(key, value));
1333
1244
  }
1334
1245
  return results;
1335
1246
  }
@@ -1341,17 +1252,13 @@ var dataStructureTyped = (() => {
1341
1252
  */
1342
1253
  has(key) {
1343
1254
  if (isWeakKey(key)) {
1344
- const hash = this.objHashFn(key);
1255
+ const hash = this._objHashFn(key);
1345
1256
  return this.objMap.has(hash);
1346
1257
  } else {
1347
- const hash = this.hashFn(key);
1258
+ const hash = this._hashFn(key);
1348
1259
  return hash in this.noObjMap;
1349
1260
  }
1350
1261
  }
1351
- /**
1352
- * Time Complexity: O(1)
1353
- * Space Complexity: O(1)
1354
- */
1355
1262
  /**
1356
1263
  * Time Complexity: O(1)
1357
1264
  * Space Complexity: O(1)
@@ -1367,19 +1274,15 @@ var dataStructureTyped = (() => {
1367
1274
  */
1368
1275
  get(key) {
1369
1276
  if (isWeakKey(key)) {
1370
- const hash = this.objHashFn(key);
1277
+ const hash = this._objHashFn(key);
1371
1278
  const node = this.objMap.get(hash);
1372
1279
  return node ? node.value : void 0;
1373
1280
  } else {
1374
- const hash = this.hashFn(key);
1281
+ const hash = this._hashFn(key);
1375
1282
  const node = this.noObjMap[hash];
1376
1283
  return node ? node.value : void 0;
1377
1284
  }
1378
1285
  }
1379
- /**
1380
- * Time Complexity: O(n)
1381
- * Space Complexity: O(1)
1382
- */
1383
1286
  /**
1384
1287
  * Time Complexity: O(n)
1385
1288
  * Space Complexity: O(1)
@@ -1399,10 +1302,6 @@ var dataStructureTyped = (() => {
1399
1302
  }
1400
1303
  return node.value;
1401
1304
  }
1402
- /**
1403
- * Time Complexity: O(1)
1404
- * Space Complexity: O(1)
1405
- */
1406
1305
  /**
1407
1306
  * Time Complexity: O(1)
1408
1307
  * Space Complexity: O(1)
@@ -1416,14 +1315,14 @@ var dataStructureTyped = (() => {
1416
1315
  delete(key) {
1417
1316
  let node;
1418
1317
  if (isWeakKey(key)) {
1419
- const hash = this.objHashFn(key);
1318
+ const hash = this._objHashFn(key);
1420
1319
  node = this.objMap.get(hash);
1421
1320
  if (!node) {
1422
1321
  return false;
1423
1322
  }
1424
1323
  this.objMap.delete(hash);
1425
1324
  } else {
1426
- const hash = this.hashFn(key);
1325
+ const hash = this._hashFn(key);
1427
1326
  node = this.noObjMap[hash];
1428
1327
  if (!node) {
1429
1328
  return false;
@@ -1433,10 +1332,6 @@ var dataStructureTyped = (() => {
1433
1332
  this._deleteNode(node);
1434
1333
  return true;
1435
1334
  }
1436
- /**
1437
- * Time Complexity: O(n)
1438
- * Space Complexity: O(1)
1439
- */
1440
1335
  /**
1441
1336
  * Time Complexity: O(n)
1442
1337
  * Space Complexity: O(1)
@@ -1454,10 +1349,6 @@ var dataStructureTyped = (() => {
1454
1349
  }
1455
1350
  return this._deleteNode(node);
1456
1351
  }
1457
- /**
1458
- * Time Complexity: O(1)
1459
- * Space Complexity: O(1)
1460
- */
1461
1352
  /**
1462
1353
  * Time Complexity: O(1)
1463
1354
  * Space Complexity: O(1)
@@ -1478,10 +1369,6 @@ var dataStructureTyped = (() => {
1478
1369
  isEntry(rawElement) {
1479
1370
  return Array.isArray(rawElement) && rawElement.length === 2;
1480
1371
  }
1481
- /**
1482
- * Time Complexity: O(1)
1483
- * Space Complexity: O(1)
1484
- */
1485
1372
  /**
1486
1373
  * Time Complexity: O(1)
1487
1374
  * Space Complexity: O(1)
@@ -1493,10 +1380,6 @@ var dataStructureTyped = (() => {
1493
1380
  this._size = 0;
1494
1381
  this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
1495
1382
  }
1496
- /**
1497
- * Time Complexity: O(n)
1498
- * Space Complexity: O(n)
1499
- */
1500
1383
  /**
1501
1384
  * Time Complexity: O(n)
1502
1385
  * Space Complexity: O(n)
@@ -1507,17 +1390,13 @@ var dataStructureTyped = (() => {
1507
1390
  * of the original `LinkedHashMap` object.
1508
1391
  */
1509
1392
  clone() {
1510
- const cloned = new _LinkedHashMap([], { hashFn: this.hashFn, objHashFn: this.objHashFn });
1393
+ const cloned = new _LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
1511
1394
  for (const entry of this) {
1512
1395
  const [key, value] = entry;
1513
1396
  cloned.set(key, value);
1514
1397
  }
1515
1398
  return cloned;
1516
1399
  }
1517
- /**
1518
- * Time Complexity: O(n)
1519
- * Space Complexity: O(n)
1520
- */
1521
1400
  /**
1522
1401
  * Time Complexity: O(n)
1523
1402
  * Space Complexity: O(n)
@@ -1544,10 +1423,6 @@ var dataStructureTyped = (() => {
1544
1423
  }
1545
1424
  return filteredMap;
1546
1425
  }
1547
- /**
1548
- * Time Complexity: O(n)
1549
- * Space Complexity: O(n)
1550
- */
1551
1426
  /**
1552
1427
  * Time Complexity: O(n)
1553
1428
  * Space Complexity: O(n)
@@ -1575,29 +1450,6 @@ var dataStructureTyped = (() => {
1575
1450
  }
1576
1451
  return mappedMap;
1577
1452
  }
1578
- /**
1579
- * Time Complexity: O(1)
1580
- * Space Complexity: O(1)
1581
- */
1582
- /**
1583
- * Time Complexity: O(1)
1584
- * Space Complexity: O(1)
1585
- *
1586
- * The put function sets a value in a data structure using a specified key.
1587
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
1588
- * to the function.
1589
- * @param {V} value - The value parameter represents the value that you want to associate with the
1590
- * specified key in the data structure.
1591
- * @returns The method is returning a boolean value.
1592
- */
1593
- put(key, value) {
1594
- return this.set(key, value);
1595
- }
1596
- /**
1597
- * Time Complexity: O(n)
1598
- * Space Complexity: O(1)
1599
- * where n is the number of entries in the LinkedHashMap.
1600
- */
1601
1453
  /**
1602
1454
  * Time Complexity: O(n)
1603
1455
  * Space Complexity: O(1)
@@ -1612,10 +1464,6 @@ var dataStructureTyped = (() => {
1612
1464
  node = node.next;
1613
1465
  }
1614
1466
  }
1615
- /**
1616
- * Time Complexity: O(1)
1617
- * Space Complexity: O(1)
1618
- */
1619
1467
  /**
1620
1468
  * Time Complexity: O(1)
1621
1469
  * Space Complexity: O(1)
@@ -1741,12 +1589,6 @@ var dataStructureTyped = (() => {
1741
1589
  get size() {
1742
1590
  return this._size;
1743
1591
  }
1744
- /**
1745
- * Time Complexity: O(n)
1746
- * Space Complexity: O(n)
1747
- * Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
1748
- * Linear space, as it creates a new node for each element in the array.
1749
- */
1750
1592
  /**
1751
1593
  * Time Complexity: O(n)
1752
1594
  * Space Complexity: O(n)
@@ -1763,10 +1605,6 @@ var dataStructureTyped = (() => {
1763
1605
  }
1764
1606
  return singlyLinkedList;
1765
1607
  }
1766
- /**
1767
- * Time Complexity: O(1)
1768
- * Space Complexity: O(1)
1769
- */
1770
1608
  /**
1771
1609
  * Time Complexity: O(1)
1772
1610
  * Space Complexity: O(1)
@@ -1788,11 +1626,6 @@ var dataStructureTyped = (() => {
1788
1626
  this._size++;
1789
1627
  return true;
1790
1628
  }
1791
- /**
1792
- * Time Complexity: O(n)
1793
- * Space Complexity: O(1)
1794
- * Linear time in the worst case, as it may need to traverse the list to find the last element.
1795
- */
1796
1629
  /**
1797
1630
  * Time Complexity: O(n)
1798
1631
  * Space Complexity: O(1)
@@ -1821,10 +1654,6 @@ var dataStructureTyped = (() => {
1821
1654
  this._size--;
1822
1655
  return value;
1823
1656
  }
1824
- /**
1825
- * Time Complexity: O(1)
1826
- * Space Complexity: O(1)
1827
- */
1828
1657
  /**
1829
1658
  * Time Complexity: O(1)
1830
1659
  * Space Complexity: O(1)
@@ -1840,10 +1669,6 @@ var dataStructureTyped = (() => {
1840
1669
  this._size--;
1841
1670
  return removedNode.value;
1842
1671
  }
1843
- /**
1844
- * Time Complexity: O(1)
1845
- * Space Complexity: O(1)
1846
- */
1847
1672
  /**
1848
1673
  * Time Complexity: O(1)
1849
1674
  * Space Complexity: O(1)
@@ -1865,10 +1690,6 @@ var dataStructureTyped = (() => {
1865
1690
  this._size++;
1866
1691
  return true;
1867
1692
  }
1868
- /**
1869
- * Time Complexity: O(n)
1870
- * Space Complexity: O(1)
1871
- */
1872
1693
  /**
1873
1694
  * Time Complexity: O(n)
1874
1695
  * Space Complexity: O(1)
@@ -1888,10 +1709,6 @@ var dataStructureTyped = (() => {
1888
1709
  }
1889
1710
  return current.value;
1890
1711
  }
1891
- /**
1892
- * Time Complexity: O(n)
1893
- * Space Complexity: O(1)
1894
- */
1895
1712
  /**
1896
1713
  * Time Complexity: O(n)
1897
1714
  * Space Complexity: O(1)
@@ -1909,10 +1726,6 @@ var dataStructureTyped = (() => {
1909
1726
  }
1910
1727
  return current;
1911
1728
  }
1912
- /**
1913
- * Time Complexity: O(n)
1914
- * Space Complexity: O(1)
1915
- */
1916
1729
  /**
1917
1730
  * Time Complexity: O(n)
1918
1731
  * Space Complexity: O(1)
@@ -1940,10 +1753,6 @@ var dataStructureTyped = (() => {
1940
1753
  this._size--;
1941
1754
  return true;
1942
1755
  }
1943
- /**
1944
- * Time Complexity: O(n)
1945
- * Space Complexity: O(1)
1946
- */
1947
1756
  /**
1948
1757
  * Time Complexity: O(n)
1949
1758
  * Space Complexity: O(1)
@@ -1955,7 +1764,7 @@ var dataStructureTyped = (() => {
1955
1764
  * successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
1956
1765
  */
1957
1766
  delete(valueOrNode) {
1958
- if (!valueOrNode)
1767
+ if (valueOrNode === void 0)
1959
1768
  return false;
1960
1769
  let value;
1961
1770
  if (valueOrNode instanceof SinglyLinkedListNode) {
@@ -1985,10 +1794,6 @@ var dataStructureTyped = (() => {
1985
1794
  }
1986
1795
  return false;
1987
1796
  }
1988
- /**
1989
- * Time Complexity: O(n)
1990
- * Space Complexity: O(1)
1991
- */
1992
1797
  /**
1993
1798
  * Time Complexity: O(n)
1994
1799
  * Space Complexity: O(1)
@@ -2035,12 +1840,6 @@ var dataStructureTyped = (() => {
2035
1840
  this._tail = void 0;
2036
1841
  this._size = 0;
2037
1842
  }
2038
- /**
2039
- * Time Complexity: O(n)
2040
- * Space Complexity: O(n)
2041
- * Linear time, where n is the length of the list, as it needs to traverse the entire list to convert it to an array.
2042
- * Linear space, as it creates an array with the same length as the list.
2043
- */
2044
1843
  /**
2045
1844
  * Time Complexity: O(n)
2046
1845
  * Space Complexity: O(n)
@@ -2057,10 +1856,6 @@ var dataStructureTyped = (() => {
2057
1856
  }
2058
1857
  return array;
2059
1858
  }
2060
- /**
2061
- * Time Complexity: O(n)
2062
- * Space Complexity: O(1)
2063
- */
2064
1859
  /**
2065
1860
  * Time Complexity: O(n)
2066
1861
  * Space Complexity: O(1)
@@ -2083,10 +1878,6 @@ var dataStructureTyped = (() => {
2083
1878
  [this._head, this._tail] = [this.tail, this.head];
2084
1879
  return this;
2085
1880
  }
2086
- /**
2087
- * Time Complexity: O(n)
2088
- * Space Complexity: O(1)
2089
- */
2090
1881
  /**
2091
1882
  * Time Complexity: O(n)
2092
1883
  * Space Complexity: O(1)
@@ -2108,10 +1899,6 @@ var dataStructureTyped = (() => {
2108
1899
  }
2109
1900
  return -1;
2110
1901
  }
2111
- /**
2112
- * Time Complexity: O(n)
2113
- * Space Complexity: O(1)
2114
- */
2115
1902
  /**
2116
1903
  * Time Complexity: O(n)
2117
1904
  * Space Complexity: O(1)
@@ -2132,10 +1919,6 @@ var dataStructureTyped = (() => {
2132
1919
  }
2133
1920
  return void 0;
2134
1921
  }
2135
- /**
2136
- * Time Complexity: O(n)
2137
- * Space Complexity: O(1)
2138
- */
2139
1922
  /**
2140
1923
  * Time Complexity: O(n)
2141
1924
  * Space Complexity: O(1)
@@ -2173,10 +1956,6 @@ var dataStructureTyped = (() => {
2173
1956
  }
2174
1957
  return false;
2175
1958
  }
2176
- /**
2177
- * Time Complexity: O(n)
2178
- * Space Complexity: O(1)
2179
- */
2180
1959
  /**
2181
1960
  * Time Complexity: O(n)
2182
1961
  * Space Complexity: O(1)
@@ -2207,10 +1986,6 @@ var dataStructureTyped = (() => {
2207
1986
  }
2208
1987
  return false;
2209
1988
  }
2210
- /**
2211
- * Time Complexity: O(n)
2212
- * Space Complexity: O(1)
2213
- */
2214
1989
  /**
2215
1990
  * Time Complexity: O(n)
2216
1991
  * Space Complexity: O(1)
@@ -2230,10 +2005,6 @@ var dataStructureTyped = (() => {
2230
2005
  }
2231
2006
  return count;
2232
2007
  }
2233
- /**
2234
- * Time Complexity: O(n)
2235
- * Space Complexity: O(n)
2236
- */
2237
2008
  /**
2238
2009
  * Time Complexity: O(n)
2239
2010
  * Space Complexity: O(n)
@@ -2246,10 +2017,6 @@ var dataStructureTyped = (() => {
2246
2017
  clone() {
2247
2018
  return new _SinglyLinkedList(this, { toElementFn: this.toElementFn });
2248
2019
  }
2249
- /**
2250
- * Time Complexity: O(n)
2251
- * Space Complexity: O(n)
2252
- */
2253
2020
  /**
2254
2021
  * Time Complexity: O(n)
2255
2022
  * Space Complexity: O(n)
@@ -2281,8 +2048,7 @@ var dataStructureTyped = (() => {
2281
2048
  /**
2282
2049
  * Time Complexity: O(n)
2283
2050
  * Space Complexity: O(n)
2284
- */
2285
- /**
2051
+ *
2286
2052
  * The `map` function takes a callback function and returns a new SinglyLinkedList with the results
2287
2053
  * of applying the callback to each element in the original list.
2288
2054
  * @param callback - The `callback` parameter is a function that will be called for each element in
@@ -2424,11 +2190,6 @@ var dataStructureTyped = (() => {
2424
2190
  get size() {
2425
2191
  return this._size;
2426
2192
  }
2427
- /**
2428
- * Time Complexity: O(1)
2429
- * Space Complexity: O(1)
2430
- * where n is the number of elements in the linked list.
2431
- */
2432
2193
  /**
2433
2194
  * Time Complexity: O(1)
2434
2195
  * Space Complexity: O(1)
@@ -2440,10 +2201,6 @@ var dataStructureTyped = (() => {
2440
2201
  var _a;
2441
2202
  return (_a = this.head) == null ? void 0 : _a.value;
2442
2203
  }
2443
- /**
2444
- * Time Complexity: O(1)
2445
- * Space Complexity: O(1)
2446
- */
2447
2204
  /**
2448
2205
  * Time Complexity: O(1)
2449
2206
  * Space Complexity: O(1)
@@ -2455,10 +2212,6 @@ var dataStructureTyped = (() => {
2455
2212
  var _a;
2456
2213
  return (_a = this.tail) == null ? void 0 : _a.value;
2457
2214
  }
2458
- /**
2459
- * Time Complexity: O(n)
2460
- * Space Complexity: O(n)
2461
- */
2462
2215
  /**
2463
2216
  * Time Complexity: O(n)
2464
2217
  * Space Complexity: O(n)
@@ -2474,8 +2227,7 @@ var dataStructureTyped = (() => {
2474
2227
  /**
2475
2228
  * Time Complexity: O(1)
2476
2229
  * Space Complexity: O(1)
2477
- */
2478
- /**
2230
+ *
2479
2231
  * The push function adds a new element to the end of a doubly linked list.
2480
2232
  * @param {E} element - The "element" parameter represents the value that you want to add to the
2481
2233
  * doubly linked list.
@@ -2497,8 +2249,7 @@ var dataStructureTyped = (() => {
2497
2249
  /**
2498
2250
  * Time Complexity: O(1)
2499
2251
  * Space Complexity: O(1)
2500
- */
2501
- /**
2252
+ *
2502
2253
  * The `pop()` function removes and returns the value of the last element in a linked list.
2503
2254
  * @returns The method is returning the value of the removed node.
2504
2255
  */
@@ -2519,8 +2270,7 @@ var dataStructureTyped = (() => {
2519
2270
  /**
2520
2271
  * Time Complexity: O(1)
2521
2272
  * Space Complexity: O(1)
2522
- */
2523
- /**
2273
+ *
2524
2274
  * The `shift()` function removes and returns the value of the first element in a doubly linked list.
2525
2275
  * @returns The value of the removed node.
2526
2276
  */
@@ -2541,8 +2291,7 @@ var dataStructureTyped = (() => {
2541
2291
  /**
2542
2292
  * Time Complexity: O(1)
2543
2293
  * Space Complexity: O(1)
2544
- */
2545
- /**
2294
+ *
2546
2295
  * The unshift function adds a new element to the beginning of a doubly linked list.
2547
2296
  * @param {E} element - The "element" parameter represents the value of the element that you want to
2548
2297
  * add to the beginning of the doubly linked list.
@@ -2561,10 +2310,6 @@ var dataStructureTyped = (() => {
2561
2310
  this._size++;
2562
2311
  return true;
2563
2312
  }
2564
- /**
2565
- * Time Complexity: O(n)
2566
- * Space Complexity: O(1)
2567
- */
2568
2313
  /**
2569
2314
  * Time Complexity: O(n)
2570
2315
  * Space Complexity: O(1)
@@ -2584,10 +2329,6 @@ var dataStructureTyped = (() => {
2584
2329
  }
2585
2330
  return current.value;
2586
2331
  }
2587
- /**
2588
- * Time Complexity: O(n)
2589
- * Space Complexity: O(1)
2590
- */
2591
2332
  /**
2592
2333
  * Time Complexity: O(n)
2593
2334
  * Space Complexity: O(1)
@@ -2608,10 +2349,6 @@ var dataStructureTyped = (() => {
2608
2349
  }
2609
2350
  return current;
2610
2351
  }
2611
- /**
2612
- * Time Complexity: O(n)
2613
- * Space Complexity: O(1)
2614
- */
2615
2352
  /**
2616
2353
  * Time Complexity: O(n)
2617
2354
  * Space Complexity: O(1)
@@ -2632,10 +2369,6 @@ var dataStructureTyped = (() => {
2632
2369
  }
2633
2370
  return void 0;
2634
2371
  }
2635
- /**
2636
- * Time Complexity: O(n)
2637
- * Space Complexity: O(1)
2638
- */
2639
2372
  /**
2640
2373
  * Time Complexity: O(n)
2641
2374
  * Space Complexity: O(1)
@@ -2669,11 +2402,6 @@ var dataStructureTyped = (() => {
2669
2402
  this._size++;
2670
2403
  return true;
2671
2404
  }
2672
- /**
2673
- * Time Complexity: O(1) or O(n)
2674
- * Space Complexity: O(1)
2675
- * where n is the number of elements in the linked list.
2676
- */
2677
2405
  /**
2678
2406
  * Time Complexity: O(1) or O(n)
2679
2407
  * Space Complexity: O(1)
@@ -2710,10 +2438,6 @@ var dataStructureTyped = (() => {
2710
2438
  }
2711
2439
  return false;
2712
2440
  }
2713
- /**
2714
- * Time Complexity: O(1) or O(n)
2715
- * Space Complexity: O(1)
2716
- */
2717
2441
  /**
2718
2442
  * Time Complexity: O(1) or O(n)
2719
2443
  * Space Complexity: O(1)
@@ -2778,10 +2502,6 @@ var dataStructureTyped = (() => {
2778
2502
  this._size--;
2779
2503
  return true;
2780
2504
  }
2781
- /**
2782
- * Time Complexity: O(1) or O(n)
2783
- * Space Complexity: O(1)
2784
- */
2785
2505
  /**
2786
2506
  * Time Complexity: O(1) or O(n)
2787
2507
  * Space Complexity: O(1)
@@ -2815,10 +2535,6 @@ var dataStructureTyped = (() => {
2815
2535
  }
2816
2536
  return false;
2817
2537
  }
2818
- /**
2819
- * Time Complexity: O(1)
2820
- * Space Complexity: O(1)
2821
- */
2822
2538
  /**
2823
2539
  * Time Complexity: O(1)
2824
2540
  * Space Complexity: O(1)
@@ -2829,10 +2545,6 @@ var dataStructureTyped = (() => {
2829
2545
  isEmpty() {
2830
2546
  return this.size === 0;
2831
2547
  }
2832
- /**
2833
- * Time Complexity: O(1)
2834
- * Space Complexity: O(1)
2835
- */
2836
2548
  /**
2837
2549
  * Time Complexity: O(1)
2838
2550
  * Space Complexity: O(1)
@@ -2844,10 +2556,6 @@ var dataStructureTyped = (() => {
2844
2556
  this._tail = void 0;
2845
2557
  this._size = 0;
2846
2558
  }
2847
- /**
2848
- * Time Complexity: O(n)
2849
- * Space Complexity: O(1)
2850
- */
2851
2559
  /**
2852
2560
  * Time Complexity: O(n)
2853
2561
  * Space Complexity: O(1)
@@ -2870,10 +2578,6 @@ var dataStructureTyped = (() => {
2870
2578
  }
2871
2579
  return -1;
2872
2580
  }
2873
- /**
2874
- * Time Complexity: O(n)
2875
- * Space Complexity: O(1)
2876
- */
2877
2581
  /**
2878
2582
  * Time Complexity: O(n)
2879
2583
  * Space Complexity: O(1)
@@ -2895,10 +2599,6 @@ var dataStructureTyped = (() => {
2895
2599
  }
2896
2600
  return void 0;
2897
2601
  }
2898
- /**
2899
- * Time Complexity: O(n)
2900
- * Space Complexity: O(1)
2901
- */
2902
2602
  /**
2903
2603
  * Time Complexity: O(n)
2904
2604
  * Space Complexity: O(1)
@@ -2915,10 +2615,6 @@ var dataStructureTyped = (() => {
2915
2615
  }
2916
2616
  return this;
2917
2617
  }
2918
- /**
2919
- * Time Complexity: O(n)
2920
- * Space Complexity: O(n)
2921
- */
2922
2618
  /**
2923
2619
  * Time Complexity: O(n)
2924
2620
  * Space Complexity: O(n)
@@ -2935,10 +2631,6 @@ var dataStructureTyped = (() => {
2935
2631
  }
2936
2632
  return array;
2937
2633
  }
2938
- /**
2939
- * Time Complexity: O(n)
2940
- * Space Complexity: O(n)
2941
- */
2942
2634
  /**
2943
2635
  * Time Complexity: O(n)
2944
2636
  * Space Complexity: O(n)
@@ -2955,10 +2647,6 @@ var dataStructureTyped = (() => {
2955
2647
  }
2956
2648
  return array;
2957
2649
  }
2958
- /**
2959
- * Time Complexity: O(n)
2960
- * Space Complexity: O(n)
2961
- */
2962
2650
  /**
2963
2651
  * Time Complexity: O(n)
2964
2652
  * Space Complexity: O(n)
@@ -2971,10 +2659,6 @@ var dataStructureTyped = (() => {
2971
2659
  clone() {
2972
2660
  return new _DoublyLinkedList(this);
2973
2661
  }
2974
- /**
2975
- * Time Complexity: O(n)
2976
- * Space Complexity: O(n)
2977
- */
2978
2662
  /**
2979
2663
  * Time Complexity: O(n)
2980
2664
  * Space Complexity: O(n)
@@ -3006,8 +2690,7 @@ var dataStructureTyped = (() => {
3006
2690
  /**
3007
2691
  * Time Complexity: O(n)
3008
2692
  * Space Complexity: O(n)
3009
- */
3010
- /**
2693
+ *
3011
2694
  * The `map` function takes a callback function and returns a new DoublyLinkedList with the results
3012
2695
  * of applying the callback to each element in the original list.
3013
2696
  * @param callback - The callback parameter is a function that will be called for each element in the
@@ -3110,10 +2793,6 @@ var dataStructureTyped = (() => {
3110
2793
  get probability() {
3111
2794
  return this._probability;
3112
2795
  }
3113
- /**
3114
- * Time Complexity: O(log n)
3115
- * Space Complexity: O(1)
3116
- */
3117
2796
  /**
3118
2797
  * Time Complexity: O(1)
3119
2798
  * Space Complexity: O(1)
@@ -3125,10 +2804,6 @@ var dataStructureTyped = (() => {
3125
2804
  const firstNode = this.head.forward[0];
3126
2805
  return firstNode ? firstNode.value : void 0;
3127
2806
  }
3128
- /**
3129
- * Time Complexity: O(log n)
3130
- * Space Complexity: O(1)
3131
- */
3132
2807
  /**
3133
2808
  * Time Complexity: O(log n)
3134
2809
  * Space Complexity: O(1)
@@ -3145,10 +2820,6 @@ var dataStructureTyped = (() => {
3145
2820
  }
3146
2821
  return current.value;
3147
2822
  }
3148
- /**
3149
- * Time Complexity: O(log n)
3150
- * Space Complexity: O(1)
3151
- */
3152
2823
  /**
3153
2824
  * Time Complexity: O(log n)
3154
2825
  * Space Complexity: O(1)
@@ -3176,10 +2847,6 @@ var dataStructureTyped = (() => {
3176
2847
  this._level = Math.max(this.level, newNode.forward.length);
3177
2848
  }
3178
2849
  }
3179
- /**
3180
- * Time Complexity: O(log n)
3181
- * Space Complexity: O(1)
3182
- */
3183
2850
  /**
3184
2851
  * Time Complexity: O(log n)
3185
2852
  * Space Complexity: O(1)
@@ -3205,8 +2872,7 @@ var dataStructureTyped = (() => {
3205
2872
  /**
3206
2873
  * Time Complexity: O(log n)
3207
2874
  * Space Complexity: O(1)
3208
- */
3209
- /**
2875
+ *
3210
2876
  * The function checks if a key exists in a data structure.
3211
2877
  * @param {K} key - The parameter "key" is of type K, which represents the type of the key being
3212
2878
  * checked.
@@ -3215,10 +2881,6 @@ var dataStructureTyped = (() => {
3215
2881
  has(key) {
3216
2882
  return this.get(key) !== void 0;
3217
2883
  }
3218
- /**
3219
- * Time Complexity: O(log n)
3220
- * Space Complexity: O(1)
3221
- */
3222
2884
  /**
3223
2885
  * Time Complexity: O(log n)
3224
2886
  * Space Complexity: O(1)
@@ -3252,10 +2914,6 @@ var dataStructureTyped = (() => {
3252
2914
  }
3253
2915
  return false;
3254
2916
  }
3255
- /**
3256
- * Time Complexity: O(log n)
3257
- * Space Complexity: O(1)
3258
- */
3259
2917
  /**
3260
2918
  * Time Complexity: O(log n)
3261
2919
  * Space Complexity: O(1)
@@ -3274,10 +2932,6 @@ var dataStructureTyped = (() => {
3274
2932
  const nextNode = current.forward[0];
3275
2933
  return nextNode ? nextNode.value : void 0;
3276
2934
  }
3277
- /**
3278
- * Time Complexity: O(log n)
3279
- * Space Complexity: O(1)
3280
- */
3281
2935
  /**
3282
2936
  * Time Complexity: O(log n)
3283
2937
  * Space Complexity: O(1)
@@ -3299,11 +2953,6 @@ var dataStructureTyped = (() => {
3299
2953
  }
3300
2954
  return lastLess ? lastLess.value : void 0;
3301
2955
  }
3302
- /**
3303
- * Time Complexity: O(maxLevel)
3304
- * Space Complexity: O(1)
3305
- * where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
3306
- */
3307
2956
  /**
3308
2957
  * Time Complexity: O(maxLevel)
3309
2958
  * Space Complexity: O(1)
@@ -3372,10 +3021,6 @@ var dataStructureTyped = (() => {
3372
3021
  isEmpty() {
3373
3022
  return this.elements.length === 0;
3374
3023
  }
3375
- /**
3376
- * Time Complexity: O(1)
3377
- * Space Complexity: O(1)
3378
- */
3379
3024
  /**
3380
3025
  * Time Complexity: O(1)
3381
3026
  * Space Complexity: O(1)
@@ -3388,10 +3033,6 @@ var dataStructureTyped = (() => {
3388
3033
  return void 0;
3389
3034
  return this.elements[this.elements.length - 1];
3390
3035
  }
3391
- /**
3392
- * Time Complexity: O(1)
3393
- * Space Complexity: O(1)
3394
- */
3395
3036
  /**
3396
3037
  * Time Complexity: O(1)
3397
3038
  * Space Complexity: O(1)
@@ -3404,10 +3045,6 @@ var dataStructureTyped = (() => {
3404
3045
  this.elements.push(element);
3405
3046
  return true;
3406
3047
  }
3407
- /**
3408
- * Time Complexity: O(1)
3409
- * Space Complexity: O(1)
3410
- */
3411
3048
  /**
3412
3049
  * Time Complexity: O(1)
3413
3050
  * Space Complexity: O(1)
@@ -3439,10 +3076,6 @@ var dataStructureTyped = (() => {
3439
3076
  const spliced = this.elements.splice(index, 1);
3440
3077
  return spliced.length === 1;
3441
3078
  }
3442
- /**
3443
- * Time Complexity: O(n)
3444
- * Space Complexity: O(n)
3445
- */
3446
3079
  /**
3447
3080
  * Time Complexity: O(n)
3448
3081
  * Space Complexity: O(n)
@@ -3453,10 +3086,6 @@ var dataStructureTyped = (() => {
3453
3086
  toArray() {
3454
3087
  return this.elements.slice();
3455
3088
  }
3456
- /**
3457
- * Time Complexity: O(1)
3458
- * Space Complexity: O(1)
3459
- */
3460
3089
  /**
3461
3090
  * Time Complexity: O(1)
3462
3091
  * Space Complexity: O(1)
@@ -3466,10 +3095,6 @@ var dataStructureTyped = (() => {
3466
3095
  clear() {
3467
3096
  this._elements = [];
3468
3097
  }
3469
- /**
3470
- * Time Complexity: O(n)
3471
- * Space Complexity: O(n)
3472
- */
3473
3098
  /**
3474
3099
  * Time Complexity: O(n)
3475
3100
  * Space Complexity: O(n)
@@ -3480,10 +3105,6 @@ var dataStructureTyped = (() => {
3480
3105
  clone() {
3481
3106
  return new _Stack(this, { toElementFn: this.toElementFn });
3482
3107
  }
3483
- /**
3484
- * Time Complexity: O(n)
3485
- * Space Complexity: O(n)
3486
- */
3487
3108
  /**
3488
3109
  * Time Complexity: O(n)
3489
3110
  * Space Complexity: O(n)
@@ -3514,8 +3135,7 @@ var dataStructureTyped = (() => {
3514
3135
  /**
3515
3136
  * Time Complexity: O(n)
3516
3137
  * Space Complexity: O(n)
3517
- */
3518
- /**
3138
+ *
3519
3139
  * The `map` function takes a callback function and applies it to each element in the stack,
3520
3140
  * returning a new stack with the results.
3521
3141
  * @param callback - The callback parameter is a function that will be called for each element in the
@@ -3538,10 +3158,6 @@ var dataStructureTyped = (() => {
3538
3158
  }
3539
3159
  return newStack;
3540
3160
  }
3541
- /**
3542
- * Time Complexity: O(n)
3543
- * Space Complexity: O(n)
3544
- */
3545
3161
  /**
3546
3162
  * Time Complexity: O(n)
3547
3163
  * Space Complexity: O(n)
@@ -3597,10 +3213,6 @@ var dataStructureTyped = (() => {
3597
3213
  get size() {
3598
3214
  return this.elements.length - this.offset;
3599
3215
  }
3600
- /**
3601
- * Time Complexity: O(1)
3602
- * Space Complexity: O(1)
3603
- */
3604
3216
  /**
3605
3217
  * Time Complexity: O(1)
3606
3218
  * Space Complexity: O(1)
@@ -3612,10 +3224,6 @@ var dataStructureTyped = (() => {
3612
3224
  get first() {
3613
3225
  return this.size > 0 ? this.elements[this.offset] : void 0;
3614
3226
  }
3615
- /**
3616
- * Time Complexity: O(1)
3617
- * Space Complexity: O(1)
3618
- */
3619
3227
  /**
3620
3228
  * Time Complexity: O(1)
3621
3229
  * Space Complexity: O(1)
@@ -3642,10 +3250,6 @@ var dataStructureTyped = (() => {
3642
3250
  set autoCompactRatio(v) {
3643
3251
  this._autoCompactRatio = v;
3644
3252
  }
3645
- /**
3646
- * Time Complexity: O(n)
3647
- * Space Complexity: O(n)
3648
- */
3649
3253
  /**
3650
3254
  * Time Complexity: O(n)
3651
3255
  * Space Complexity: O(n)
@@ -3659,10 +3263,6 @@ var dataStructureTyped = (() => {
3659
3263
  static fromArray(elements) {
3660
3264
  return new _Queue(elements);
3661
3265
  }
3662
- /**
3663
- * Time Complexity: O(1)
3664
- * Space Complexity: O(1)
3665
- */
3666
3266
  /**
3667
3267
  * Time Complexity: O(1)
3668
3268
  * Space Complexity: O(1)
@@ -3675,10 +3275,6 @@ var dataStructureTyped = (() => {
3675
3275
  this.elements.push(element);
3676
3276
  return true;
3677
3277
  }
3678
- /**
3679
- * Time Complexity: O(1)
3680
- * Space Complexity: O(1)
3681
- */
3682
3278
  /**
3683
3279
  * Time Complexity: O(1)
3684
3280
  * Space Complexity: O(1)
@@ -3714,10 +3310,6 @@ var dataStructureTyped = (() => {
3714
3310
  const spliced = this.elements.splice(index, 1);
3715
3311
  return spliced.length === 1;
3716
3312
  }
3717
- /**
3718
- * Time Complexity: O(1)
3719
- * Space Complexity: O(1)
3720
- */
3721
3313
  /**
3722
3314
  * Time Complexity: O(1)
3723
3315
  * Space Complexity: O(1)
@@ -3727,10 +3319,6 @@ var dataStructureTyped = (() => {
3727
3319
  at(index) {
3728
3320
  return this.elements[index + this._offset];
3729
3321
  }
3730
- /**
3731
- * Time Complexity: O(1)
3732
- * Space Complexity: O(1)
3733
- */
3734
3322
  /**
3735
3323
  * Time Complexity: O(1)
3736
3324
  * Space Complexity: O(1)
@@ -3741,10 +3329,6 @@ var dataStructureTyped = (() => {
3741
3329
  isEmpty() {
3742
3330
  return this.size === 0;
3743
3331
  }
3744
- /**
3745
- * Time Complexity: O(1)
3746
- * Space Complexity: O(n)
3747
- */
3748
3332
  /**
3749
3333
  * Time Complexity: O(1)
3750
3334
  * Space Complexity: O(n)
@@ -3755,10 +3339,6 @@ var dataStructureTyped = (() => {
3755
3339
  toArray() {
3756
3340
  return this.elements.slice(this.offset);
3757
3341
  }
3758
- /**
3759
- * Time Complexity: O(1)
3760
- * Space Complexity: O(1)
3761
- */
3762
3342
  /**
3763
3343
  * Time Complexity: O(1)
3764
3344
  * Space Complexity: O(1)
@@ -3779,11 +3359,6 @@ var dataStructureTyped = (() => {
3779
3359
  this._offset = 0;
3780
3360
  return true;
3781
3361
  }
3782
- /**
3783
- * Time Complexity: O(n)
3784
- * Space Complexity: O(n)
3785
- * where n is the number of elements in the queue. It creates a shallow copy of the internal array. the space required is proportional to the number of elements in the queue.
3786
- */
3787
3362
  /**
3788
3363
  * Time Complexity: O(n)
3789
3364
  * Space Complexity: O(n)
@@ -3794,10 +3369,6 @@ var dataStructureTyped = (() => {
3794
3369
  clone() {
3795
3370
  return new _Queue(this.elements.slice(this.offset), { toElementFn: this.toElementFn });
3796
3371
  }
3797
- /**
3798
- * Time Complexity: O(n)
3799
- * Space Complexity: O(n)
3800
- */
3801
3372
  /**
3802
3373
  * Time Complexity: O(n)
3803
3374
  * Space Complexity: O(n)
@@ -3838,10 +3409,6 @@ var dataStructureTyped = (() => {
3838
3409
  }
3839
3410
  return newDeque;
3840
3411
  }
3841
- /**
3842
- * Time Complexity: O(n)
3843
- * Space Complexity: O(n)
3844
- */
3845
3412
  /**
3846
3413
  * Time Complexity: O(n)
3847
3414
  * Space Complexity: O(n)
@@ -3855,10 +3422,6 @@ var dataStructureTyped = (() => {
3855
3422
  }
3856
3423
  };
3857
3424
  var LinkedListQueue = class _LinkedListQueue extends SinglyLinkedList {
3858
- /**
3859
- * Time Complexity: O(n)
3860
- * Space Complexity: O(n)
3861
- */
3862
3425
  /**
3863
3426
  * Time Complexity: O(n)
3864
3427
  * Space Complexity: O(n)
@@ -4016,10 +3579,6 @@ var dataStructureTyped = (() => {
4016
3579
  return;
4017
3580
  return this._buckets[this._bucketLast][this._lastInBucket];
4018
3581
  }
4019
- /**
4020
- * Time Complexity - Amortized O(1) (possible reallocation)
4021
- * Space Complexity - O(n) (due to potential resizing).
4022
- */
4023
3582
  /**
4024
3583
  * Time Complexity - Amortized O(1) (possible reallocation),
4025
3584
  * Space Complexity - O(n) (due to potential resizing).
@@ -4049,10 +3608,6 @@ var dataStructureTyped = (() => {
4049
3608
  this.shift();
4050
3609
  return true;
4051
3610
  }
4052
- /**
4053
- * Time Complexity: O(1)
4054
- * Space Complexity: O(1)
4055
- */
4056
3611
  /**
4057
3612
  * Time Complexity: O(1)
4058
3613
  * Space Complexity: O(1)
@@ -4079,10 +3634,6 @@ var dataStructureTyped = (() => {
4079
3634
  this._size -= 1;
4080
3635
  return element;
4081
3636
  }
4082
- /**
4083
- * Time Complexity: Amortized O(1)
4084
- * Space Complexity: O(n)
4085
- */
4086
3637
  /**
4087
3638
  * Time Complexity: Amortized O(1)
4088
3639
  * Space Complexity: O(n)
@@ -4113,10 +3664,6 @@ var dataStructureTyped = (() => {
4113
3664
  this.pop();
4114
3665
  return true;
4115
3666
  }
4116
- /**
4117
- * Time Complexity: O(1)
4118
- * Space Complexity: O(1)
4119
- */
4120
3667
  /**
4121
3668
  * Time Complexity: O(1)
4122
3669
  * Space Complexity: O(1)
@@ -4144,10 +3691,6 @@ var dataStructureTyped = (() => {
4144
3691
  this._size -= 1;
4145
3692
  return element;
4146
3693
  }
4147
- /**
4148
- * Time Complexity: O(1)
4149
- * Space Complexity: O(1)
4150
- */
4151
3694
  /**
4152
3695
  * Time Complexity: O(1)
4153
3696
  * Space Complexity: O(1)
@@ -4158,10 +3701,6 @@ var dataStructureTyped = (() => {
4158
3701
  isEmpty() {
4159
3702
  return this.size === 0;
4160
3703
  }
4161
- /**
4162
- * Time Complexity: O(1)
4163
- * Space Complexity: O(1)
4164
- */
4165
3704
  /**
4166
3705
  * Time Complexity: O(1)
4167
3706
  * Space Complexity: O(1)
@@ -4196,10 +3735,6 @@ var dataStructureTyped = (() => {
4196
3735
  index--;
4197
3736
  }
4198
3737
  }
4199
- /**
4200
- * Time Complexity: O(1)
4201
- * Space Complexity: O(1)
4202
- */
4203
3738
  /**
4204
3739
  * Time Complexity: O(1)
4205
3740
  * Space Complexity: O(1)
@@ -4215,10 +3750,6 @@ var dataStructureTyped = (() => {
4215
3750
  const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
4216
3751
  return this._buckets[bucketIndex][indexInBucket];
4217
3752
  }
4218
- /**
4219
- * Time Complexity: O(1)
4220
- * Space Complexity: O(1)
4221
- */
4222
3753
  /**
4223
3754
  * Time Complexity: O(1)
4224
3755
  * Space Complexity: O(1)
@@ -4235,10 +3766,6 @@ var dataStructureTyped = (() => {
4235
3766
  this._buckets[bucketIndex][indexInBucket] = element;
4236
3767
  return true;
4237
3768
  }
4238
- /**
4239
- * Time Complexity: O(n)
4240
- * Space Complexity: O(n)
4241
- */
4242
3769
  /**
4243
3770
  * Time Complexity: O(n)
4244
3771
  * Space Complexity: O(n)
@@ -4276,10 +3803,6 @@ var dataStructureTyped = (() => {
4276
3803
  }
4277
3804
  return true;
4278
3805
  }
4279
- /**
4280
- * Time Complexity: O(1)
4281
- * Space Complexity: O(1)
4282
- */
4283
3806
  /**
4284
3807
  * Time Complexity: O(1)
4285
3808
  * Space Complexity: O(1)
@@ -4310,10 +3833,6 @@ var dataStructureTyped = (() => {
4310
3833
  return newDeque;
4311
3834
  }
4312
3835
  }
4313
- /**
4314
- * Time Complexity: O(1)
4315
- * Space Complexity: O(1) or O(n)
4316
- */
4317
3836
  /**
4318
3837
  * Time Complexity: O(1)
4319
3838
  * Space Complexity: O(1) or O(n)
@@ -4332,7 +3851,6 @@ var dataStructureTyped = (() => {
4332
3851
  cutRest(pos, isCutSelf = false) {
4333
3852
  if (isCutSelf) {
4334
3853
  if (pos < 0) {
4335
- this.clear();
4336
3854
  return this;
4337
3855
  }
4338
3856
  const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
@@ -4342,16 +3860,14 @@ var dataStructureTyped = (() => {
4342
3860
  return this;
4343
3861
  } else {
4344
3862
  const newDeque = new _Deque([], { bucketSize: this._bucketSize });
3863
+ if (pos < 0)
3864
+ pos = 0;
4345
3865
  for (let i = pos; i < this.size; i++) {
4346
3866
  newDeque.push(this.at(i));
4347
3867
  }
4348
3868
  return newDeque;
4349
3869
  }
4350
3870
  }
4351
- /**
4352
- * Time Complexity: O(n)
4353
- * Space Complexity: O(1) or O(n)
4354
- */
4355
3871
  /**
4356
3872
  * Time Complexity: O(n)
4357
3873
  * Space Complexity: O(1) or O(n)
@@ -4382,10 +3898,6 @@ var dataStructureTyped = (() => {
4382
3898
  }
4383
3899
  return true;
4384
3900
  }
4385
- /**
4386
- * Time Complexity: O(n)
4387
- * Space Complexity: O(1)
4388
- */
4389
3901
  /**
4390
3902
  * Time Complexity: O(n)
4391
3903
  * Space Complexity: O(1)
@@ -4413,10 +3925,6 @@ var dataStructureTyped = (() => {
4413
3925
  this.cut(index - 1, true);
4414
3926
  return true;
4415
3927
  }
4416
- /**
4417
- * Time Complexity: O(n)
4418
- * Space Complexity: O(1)
4419
- */
4420
3928
  /**
4421
3929
  * Time Complexity: O(n)
4422
3930
  * Space Complexity: O(1)
@@ -4437,10 +3945,6 @@ var dataStructureTyped = (() => {
4437
3945
  this._lastInBucket = this._bucketSize - _firstInBucket - 1;
4438
3946
  return this;
4439
3947
  }
4440
- /**
4441
- * Time Complexity: O(n)
4442
- * Space Complexity: O(1)
4443
- */
4444
3948
  /**
4445
3949
  * Time Complexity: O(n)
4446
3950
  * Space Complexity: O(1)
@@ -4465,10 +3969,6 @@ var dataStructureTyped = (() => {
4465
3969
  this.cut(index - 1, true);
4466
3970
  return this;
4467
3971
  }
4468
- /**
4469
- * Time Complexity: O(n log n)
4470
- * Space Complexity: O(n)
4471
- */
4472
3972
  /**
4473
3973
  * Time Complexity: O(n log n)
4474
3974
  * Space Complexity: O(n)
@@ -4490,10 +3990,6 @@ var dataStructureTyped = (() => {
4490
3990
  }
4491
3991
  return this;
4492
3992
  }
4493
- /**
4494
- * Time Complexity: O(n)
4495
- * Space Complexity: O(n)
4496
- */
4497
3993
  /**
4498
3994
  * Time Complexity: O(n)
4499
3995
  * Space Complexity: O(n)
@@ -4525,10 +4021,6 @@ var dataStructureTyped = (() => {
4525
4021
  this._bucketLast = newBuckets.length - 1;
4526
4022
  this._buckets = newBuckets;
4527
4023
  }
4528
- /**
4529
- * Time Complexity: O(n)
4530
- * Space Complexity: O(1)
4531
- */
4532
4024
  /**
4533
4025
  * Time Complexity: O(n)
4534
4026
  * Space Complexity: O(1)
@@ -4548,10 +4040,6 @@ var dataStructureTyped = (() => {
4548
4040
  }
4549
4041
  return -1;
4550
4042
  }
4551
- /**
4552
- * Time Complexity: O(n)
4553
- * Space Complexity: O(n)
4554
- */
4555
4043
  /**
4556
4044
  * Time Complexity: O(n)
4557
4045
  * Space Complexity: O(n)
@@ -4562,10 +4050,6 @@ var dataStructureTyped = (() => {
4562
4050
  toArray() {
4563
4051
  return [...this];
4564
4052
  }
4565
- /**
4566
- * Time Complexity: O(n)
4567
- * Space Complexity: O(n)
4568
- */
4569
4053
  /**
4570
4054
  * Time Complexity: O(n)
4571
4055
  * Space Complexity: O(n)
@@ -4578,10 +4062,6 @@ var dataStructureTyped = (() => {
4578
4062
  clone() {
4579
4063
  return new _Deque(this, { bucketSize: this.bucketSize, toElementFn: this.toElementFn });
4580
4064
  }
4581
- /**
4582
- * Time Complexity: O(n)
4583
- * Space Complexity: O(n)
4584
- */
4585
4065
  /**
4586
4066
  * Time Complexity: O(n)
4587
4067
  * Space Complexity: O(n)
@@ -4612,8 +4092,7 @@ var dataStructureTyped = (() => {
4612
4092
  /**
4613
4093
  * Time Complexity: O(n)
4614
4094
  * Space Complexity: O(n)
4615
- */
4616
- /**
4095
+ *
4617
4096
  * The `map` function takes a callback function and applies it to each element in the deque,
4618
4097
  * returning a new deque with the results.
4619
4098
  * @param callback - The callback parameter is a function that will be called for each element in the
@@ -4637,10 +4116,6 @@ var dataStructureTyped = (() => {
4637
4116
  }
4638
4117
  return newDeque;
4639
4118
  }
4640
- /**
4641
- * Time Complexity: O(n)
4642
- * Space Complexity: O(1)
4643
- */
4644
4119
  /**
4645
4120
  * Time Complexity: O(n)
4646
4121
  * Space Complexity: O(1)
@@ -4653,10 +4128,6 @@ var dataStructureTyped = (() => {
4653
4128
  yield this.at(i);
4654
4129
  }
4655
4130
  }
4656
- /**
4657
- * Time Complexity: O(n)
4658
- * Space Complexity: O(n)
4659
- */
4660
4131
  /**
4661
4132
  * Time Complexity: O(n)
4662
4133
  * Space Complexity: O(n)
@@ -4687,10 +4158,6 @@ var dataStructureTyped = (() => {
4687
4158
  this._buckets = newBuckets;
4688
4159
  this._bucketCount = newBuckets.length;
4689
4160
  }
4690
- /**
4691
- * Time Complexity: O(1)
4692
- * Space Complexity: O(1)
4693
- */
4694
4161
  /**
4695
4162
  * Time Complexity: O(1)
4696
4163
  * Space Complexity: O(1)
@@ -5212,10 +4679,6 @@ var dataStructureTyped = (() => {
5212
4679
  peek() {
5213
4680
  return this.min ? this.min.element : void 0;
5214
4681
  }
5215
- /**
5216
- * Time Complexity: O(n), where n is the number of elements in the linked list.
5217
- * Space Complexity: O(1)
5218
- */
5219
4682
  /**
5220
4683
  * Time Complexity: O(n), where n is the number of elements in the linked list.
5221
4684
  * Space Complexity: O(1)
@@ -5260,10 +4723,6 @@ var dataStructureTyped = (() => {
5260
4723
  parent.child.right = node;
5261
4724
  }
5262
4725
  }
5263
- /**
5264
- * Time Complexity: O(log n)
5265
- * Space Complexity: O(1)
5266
- */
5267
4726
  /**
5268
4727
  * Time Complexity: O(log n)
5269
4728
  * Space Complexity: O(1)
@@ -5274,10 +4733,6 @@ var dataStructureTyped = (() => {
5274
4733
  poll() {
5275
4734
  return this.pop();
5276
4735
  }
5277
- /**
5278
- * Time Complexity: O(log n)
5279
- * Space Complexity: O(1)
5280
- */
5281
4736
  /**
5282
4737
  * Time Complexity: O(log n)
5283
4738
  * Space Complexity: O(1)
@@ -5307,10 +4762,6 @@ var dataStructureTyped = (() => {
5307
4762
  this._size--;
5308
4763
  return z.element;
5309
4764
  }
5310
- /**
5311
- * Time Complexity: O(1)
5312
- * Space Complexity: O(1)
5313
- */
5314
4765
  /**
5315
4766
  * Time Complexity: O(1)
5316
4767
  * Space Complexity: O(1)
@@ -5359,10 +4810,6 @@ var dataStructureTyped = (() => {
5359
4810
  return 1;
5360
4811
  return 0;
5361
4812
  }
5362
- /**
5363
- * Time Complexity: O(1)
5364
- * Space Complexity: O(1)
5365
- */
5366
4813
  /**
5367
4814
  * Time Complexity: O(1)
5368
4815
  * Space Complexity: O(1)
@@ -5380,10 +4827,6 @@ var dataStructureTyped = (() => {
5380
4827
  this.root.right = node;
5381
4828
  }
5382
4829
  }
5383
- /**
5384
- * Time Complexity: O(1)
5385
- * Space Complexity: O(1)
5386
- */
5387
4830
  /**
5388
4831
  * Time Complexity: O(1)
5389
4832
  * Space Complexity: O(1)
@@ -5400,10 +4843,6 @@ var dataStructureTyped = (() => {
5400
4843
  if (node.right)
5401
4844
  node.right.left = node.left;
5402
4845
  }
5403
- /**
5404
- * Time Complexity: O(1)
5405
- * Space Complexity: O(1)
5406
- */
5407
4846
  /**
5408
4847
  * Time Complexity: O(1)
5409
4848
  * Space Complexity: O(1)
@@ -5421,10 +4860,6 @@ var dataStructureTyped = (() => {
5421
4860
  x.degree++;
5422
4861
  y.parent = x;
5423
4862
  }
5424
- /**
5425
- * Time Complexity: O(n log n)
5426
- * Space Complexity: O(n)
5427
- */
5428
4863
  /**
5429
4864
  * Time Complexity: O(n log n)
5430
4865
  * Space Complexity: O(n)
@@ -5675,10 +5110,6 @@ var dataStructureTyped = (() => {
5675
5110
  get size() {
5676
5111
  return this._vertexMap.size;
5677
5112
  }
5678
- /**
5679
- * Time Complexity: O(1) - Constant time for Map lookup.
5680
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5681
- */
5682
5113
  /**
5683
5114
  * Time Complexity: O(1) - Constant time for Map lookup.
5684
5115
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -5692,10 +5123,6 @@ var dataStructureTyped = (() => {
5692
5123
  getVertex(vertexKey) {
5693
5124
  return this._vertexMap.get(vertexKey) || void 0;
5694
5125
  }
5695
- /**
5696
- * Time Complexity: O(1) - Constant time for Map lookup.
5697
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5698
- */
5699
5126
  /**
5700
5127
  * Time Complexity: O(1) - Constant time for Map lookup.
5701
5128
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -5724,10 +5151,6 @@ var dataStructureTyped = (() => {
5724
5151
  const potentialKeyType = typeof potentialKey;
5725
5152
  return potentialKeyType === "string" || potentialKeyType === "number";
5726
5153
  }
5727
- /**
5728
- * Time Complexity: O(K), where K is the number of vertexMap to be removed.
5729
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5730
- */
5731
5154
  /**
5732
5155
  * Time Complexity: O(K), where K is the number of vertexMap to be removed.
5733
5156
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -5745,10 +5168,6 @@ var dataStructureTyped = (() => {
5745
5168
  }
5746
5169
  return removed.length > 0;
5747
5170
  }
5748
- /**
5749
- * Time Complexity: O(1) - Depends on the implementation in the concrete class.
5750
- * Space Complexity: O(1) - Depends on the implementation in the concrete class.
5751
- */
5752
5171
  /**
5753
5172
  * Time Complexity: O(1) - Depends on the implementation in the concrete class.
5754
5173
  * Space Complexity: O(1) - Depends on the implementation in the concrete class.
@@ -5786,10 +5205,6 @@ var dataStructureTyped = (() => {
5786
5205
  }
5787
5206
  }
5788
5207
  }
5789
- /**
5790
- * Time Complexity: O(1) - Constant time for Map and Edge operations.
5791
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5792
- */
5793
5208
  /**
5794
5209
  * Time Complexity: O(1) - Constant time for Map and Edge operations.
5795
5210
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -5813,10 +5228,6 @@ var dataStructureTyped = (() => {
5813
5228
  return false;
5814
5229
  }
5815
5230
  }
5816
- /**
5817
- * Time Complexity: O(P), where P is the number of paths found (in the worst case, exploring all paths).
5818
- * Space Complexity: O(P) - Linear space, where P is the number of paths found.
5819
- */
5820
5231
  /**
5821
5232
  * Time Complexity: O(P), where P is the number of paths found (in the worst case, exploring all paths).
5822
5233
  * Space Complexity: O(P) - Linear space, where P is the number of paths found.
@@ -5854,10 +5265,6 @@ var dataStructureTyped = (() => {
5854
5265
  }
5855
5266
  return paths;
5856
5267
  }
5857
- /**
5858
- * Time Complexity: O(L), where L is the length of the path.
5859
- * Space Complexity: O(1) - Constant space.
5860
- */
5861
5268
  /**
5862
5269
  * Time Complexity: O(L), where L is the length of the path.
5863
5270
  * Space Complexity: O(1) - Constant space.
@@ -5874,10 +5281,6 @@ var dataStructureTyped = (() => {
5874
5281
  }
5875
5282
  return sum;
5876
5283
  }
5877
- /**
5878
- * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5879
- * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5880
- */
5881
5284
  /**
5882
5285
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5883
5286
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
@@ -5936,10 +5339,6 @@ var dataStructureTyped = (() => {
5936
5339
  return void 0;
5937
5340
  }
5938
5341
  }
5939
- /**
5940
- * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
5941
- * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
5942
- */
5943
5342
  /**
5944
5343
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
5945
5344
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
@@ -6007,13 +5406,6 @@ var dataStructureTyped = (() => {
6007
5406
  return minPath;
6008
5407
  }
6009
5408
  }
6010
- /**
6011
- * Dijkstra algorithm time: O(VE) space: O(VO + EO)
6012
- */
6013
- /**
6014
- * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
6015
- * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
6016
- */
6017
5409
  /**
6018
5410
  * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
6019
5411
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
@@ -6127,18 +5519,6 @@ var dataStructureTyped = (() => {
6127
5519
  genPaths && getPaths(minDest);
6128
5520
  return { distMap, preMap, seen, paths, minDist, minPath };
6129
5521
  }
6130
- /**
6131
- * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
6132
- *
6133
- * Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
6134
- * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
6135
- * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
6136
- *
6137
- */
6138
- /**
6139
- * Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
6140
- * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
6141
- */
6142
5522
  /**
6143
5523
  * Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
6144
5524
  * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
@@ -6250,11 +5630,6 @@ var dataStructureTyped = (() => {
6250
5630
  }
6251
5631
  return { distMap, preMap, seen, paths, minDist, minPath };
6252
5632
  }
6253
- /**
6254
- * Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).
6255
- * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
6256
- * one to rest pairs
6257
- */
6258
5633
  /**
6259
5634
  * Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).
6260
5635
  * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
@@ -6370,13 +5745,6 @@ var dataStructureTyped = (() => {
6370
5745
  * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
6371
5746
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
6372
5747
  */
6373
- /**
6374
- * Time Complexity: O(V^3) - Cubic time (Floyd-Warshall algorithm).
6375
- * Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
6376
- * Not support graph with negative weight cycle
6377
- * all pairs
6378
- * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
6379
- */
6380
5748
  /**
6381
5749
  * Time Complexity: O(V^3) - Cubic time (Floyd-Warshall algorithm).
6382
5750
  * Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
@@ -6457,10 +5825,6 @@ var dataStructureTyped = (() => {
6457
5825
  }
6458
5826
  return [...uniqueCycles].map((cycleString) => cycleString[1]);
6459
5827
  }
6460
- /**
6461
- * Time Complexity: O(n)
6462
- * Space Complexity: O(n)
6463
- */
6464
5828
  /**
6465
5829
  * Time Complexity: O(n)
6466
5830
  * Space Complexity: O(n)
@@ -6488,10 +5852,6 @@ var dataStructureTyped = (() => {
6488
5852
  }
6489
5853
  return filtered;
6490
5854
  }
6491
- /**
6492
- * Time Complexity: O(n)
6493
- * Space Complexity: O(n)
6494
- */
6495
5855
  /**
6496
5856
  * Time Complexity: O(n)
6497
5857
  * Space Complexity: O(n)
@@ -6589,10 +5949,6 @@ var dataStructureTyped = (() => {
6589
5949
  set inEdgeMap(v) {
6590
5950
  this._inEdgeMap = v;
6591
5951
  }
6592
- /**
6593
- * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
6594
- * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
6595
- */
6596
5952
  /**
6597
5953
  * The function creates a new vertex with an optional value and returns it.
6598
5954
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
@@ -6605,10 +5961,6 @@ var dataStructureTyped = (() => {
6605
5961
  createVertex(key, value) {
6606
5962
  return new DirectedVertex(key, value);
6607
5963
  }
6608
- /**
6609
- * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
6610
- * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
6611
- */
6612
5964
  /**
6613
5965
  * The function creates a directed edge between two vertexMap with an optional weight and value.
6614
5966
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
@@ -6622,10 +5974,6 @@ var dataStructureTyped = (() => {
6622
5974
  createEdge(src, dest, weight, value) {
6623
5975
  return new DirectedEdge(src, dest, weight != null ? weight : 1, value);
6624
5976
  }
6625
- /**
6626
- * Time Complexity: O(|V|) where |V| is the number of vertexMap
6627
- * Space Complexity: O(1)
6628
- */
6629
5977
  /**
6630
5978
  * Time Complexity: O(|V|) where |V| is the number of vertexMap
6631
5979
  * Space Complexity: O(1)
@@ -6651,10 +5999,6 @@ var dataStructureTyped = (() => {
6651
5999
  }
6652
6000
  return edgeMap[0] || void 0;
6653
6001
  }
6654
- /**
6655
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
6656
- * Space Complexity: O(1)
6657
- */
6658
6002
  /**
6659
6003
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
6660
6004
  * Space Complexity: O(1)
@@ -6681,10 +6025,6 @@ var dataStructureTyped = (() => {
6681
6025
  }
6682
6026
  return removed;
6683
6027
  }
6684
- /**
6685
- * Time Complexity: O(E) where E is the number of edgeMap
6686
- * Space Complexity: O(1)
6687
- */
6688
6028
  /**
6689
6029
  * Time Complexity: O(E) where E is the number of edgeMap
6690
6030
  * Space Complexity: O(1)
@@ -6724,10 +6064,6 @@ var dataStructureTyped = (() => {
6724
6064
  }
6725
6065
  return removed;
6726
6066
  }
6727
- /**
6728
- * Time Complexity: O(1) - Constant time for Map operations.
6729
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
6730
- */
6731
6067
  /**
6732
6068
  * Time Complexity: O(1) - Constant time for Map operations.
6733
6069
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -6757,10 +6093,6 @@ var dataStructureTyped = (() => {
6757
6093
  }
6758
6094
  return this._vertexMap.delete(vertexKey);
6759
6095
  }
6760
- /**
6761
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
6762
- * Space Complexity: O(1)
6763
- */
6764
6096
  /**
6765
6097
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
6766
6098
  * Space Complexity: O(1)
@@ -6782,10 +6114,6 @@ var dataStructureTyped = (() => {
6782
6114
  }
6783
6115
  return removed;
6784
6116
  }
6785
- /**
6786
- * Time Complexity: O(1)
6787
- * Space Complexity: O(1)
6788
- */
6789
6117
  /**
6790
6118
  * Time Complexity: O(1)
6791
6119
  * Space Complexity: O(1)
@@ -6802,10 +6130,6 @@ var dataStructureTyped = (() => {
6802
6130
  }
6803
6131
  return [];
6804
6132
  }
6805
- /**
6806
- * Time Complexity: O(1)
6807
- * Space Complexity: O(1)
6808
- */
6809
6133
  /**
6810
6134
  * Time Complexity: O(1)
6811
6135
  * Space Complexity: O(1)
@@ -6822,10 +6146,6 @@ var dataStructureTyped = (() => {
6822
6146
  }
6823
6147
  return [];
6824
6148
  }
6825
- /**
6826
- * Time Complexity: O(1)
6827
- * Space Complexity: O(1)
6828
- */
6829
6149
  /**
6830
6150
  * Time Complexity: O(1)
6831
6151
  * Space Complexity: O(1)
@@ -6837,10 +6157,6 @@ var dataStructureTyped = (() => {
6837
6157
  degreeOf(vertexOrKey) {
6838
6158
  return this.outDegreeOf(vertexOrKey) + this.inDegreeOf(vertexOrKey);
6839
6159
  }
6840
- /**
6841
- * Time Complexity: O(1)
6842
- * Space Complexity: O(1)
6843
- */
6844
6160
  /**
6845
6161
  * Time Complexity: O(1)
6846
6162
  * Space Complexity: O(1)
@@ -6852,10 +6168,6 @@ var dataStructureTyped = (() => {
6852
6168
  inDegreeOf(vertexOrKey) {
6853
6169
  return this.incomingEdgesOf(vertexOrKey).length;
6854
6170
  }
6855
- /**
6856
- * Time Complexity: O(1)
6857
- * Space Complexity: O(1)
6858
- */
6859
6171
  /**
6860
6172
  * Time Complexity: O(1)
6861
6173
  * Space Complexity: O(1)
@@ -6867,10 +6179,6 @@ var dataStructureTyped = (() => {
6867
6179
  outDegreeOf(vertexOrKey) {
6868
6180
  return this.outgoingEdgesOf(vertexOrKey).length;
6869
6181
  }
6870
- /**
6871
- * Time Complexity: O(1)
6872
- * Space Complexity: O(1)
6873
- */
6874
6182
  /**
6875
6183
  * Time Complexity: O(1)
6876
6184
  * Space Complexity: O(1)
@@ -6882,10 +6190,6 @@ var dataStructureTyped = (() => {
6882
6190
  edgesOf(vertexOrKey) {
6883
6191
  return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
6884
6192
  }
6885
- /**
6886
- * Time Complexity: O(1)
6887
- * Space Complexity: O(1)
6888
- */
6889
6193
  /**
6890
6194
  * Time Complexity: O(1)
6891
6195
  * Space Complexity: O(1)
@@ -6897,10 +6201,6 @@ var dataStructureTyped = (() => {
6897
6201
  getEdgeSrc(e) {
6898
6202
  return this._getVertex(e.src);
6899
6203
  }
6900
- /**
6901
- * Time Complexity: O(1)
6902
- * Space Complexity: O(1)
6903
- */
6904
6204
  /**
6905
6205
  * Time Complexity: O(1)
6906
6206
  * Space Complexity: O(1)
@@ -6912,10 +6212,6 @@ var dataStructureTyped = (() => {
6912
6212
  getEdgeDest(e) {
6913
6213
  return this._getVertex(e.dest);
6914
6214
  }
6915
- /**
6916
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
6917
- * Space Complexity: O(1)
6918
- */
6919
6215
  /**
6920
6216
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
6921
6217
  * Space Complexity: O(1)
@@ -6939,10 +6235,6 @@ var dataStructureTyped = (() => {
6939
6235
  }
6940
6236
  return destinations;
6941
6237
  }
6942
- /**
6943
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
6944
- * Space Complexity: O(|V|)
6945
- */
6946
6238
  /**
6947
6239
  * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
6948
6240
  * Space Complexity: O(|V|)
@@ -6987,10 +6279,6 @@ var dataStructureTyped = (() => {
6987
6279
  sorted = sorted.map((vertex) => vertex instanceof DirectedVertex ? vertex.key : vertex);
6988
6280
  return sorted.reverse();
6989
6281
  }
6990
- /**
6991
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
6992
- * Space Complexity: O(|E|)
6993
- */
6994
6282
  /**
6995
6283
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
6996
6284
  * Space Complexity: O(|E|)
@@ -7005,10 +6293,6 @@ var dataStructureTyped = (() => {
7005
6293
  });
7006
6294
  return edgeMap;
7007
6295
  }
7008
- /**
7009
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
7010
- * Space Complexity: O(1)
7011
- */
7012
6296
  /**
7013
6297
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
7014
6298
  * Space Complexity: O(1)
@@ -7032,10 +6316,6 @@ var dataStructureTyped = (() => {
7032
6316
  }
7033
6317
  return neighbors;
7034
6318
  }
7035
- /**
7036
- * Time Complexity: O(1)
7037
- * Space Complexity: O(1)
7038
- */
7039
6319
  /**
7040
6320
  * Time Complexity: O(1)
7041
6321
  * Space Complexity: O(1)
@@ -7066,10 +6346,6 @@ var dataStructureTyped = (() => {
7066
6346
  isEmpty() {
7067
6347
  return this.vertexMap.size === 0 && this.inEdgeMap.size === 0 && this.outEdgeMap.size === 0;
7068
6348
  }
7069
- /**
7070
- * Time Complexity: O(1)
7071
- * Space Complexity: O(1)
7072
- */
7073
6349
  /**
7074
6350
  * Time Complexity: O(1)
7075
6351
  * Space Complexity: O(1)
@@ -7093,12 +6369,6 @@ var dataStructureTyped = (() => {
7093
6369
  cloned.outEdgeMap = new Map(this.outEdgeMap);
7094
6370
  return cloned;
7095
6371
  }
7096
- /**
7097
- * Time Complexity: O(V + E)
7098
- * Space Complexity: O(V)
7099
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7100
- * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
7101
- */
7102
6372
  /**
7103
6373
  * Time Complexity: O(V + E)
7104
6374
  * Space Complexity: O(V)
@@ -7150,10 +6420,6 @@ var dataStructureTyped = (() => {
7150
6420
  }
7151
6421
  return { dfnMap, lowMap, SCCs };
7152
6422
  }
7153
- /**
7154
- * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
7155
- * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
7156
- */
7157
6423
  /**
7158
6424
  * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
7159
6425
  * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
@@ -7182,10 +6448,6 @@ var dataStructureTyped = (() => {
7182
6448
  getSCCs() {
7183
6449
  return this.tarjan().SCCs;
7184
6450
  }
7185
- /**
7186
- * Time Complexity: O(1)
7187
- * Space Complexity: O(1)
7188
- */
7189
6451
  /**
7190
6452
  * Time Complexity: O(1)
7191
6453
  * Space Complexity: O(1)
@@ -7292,10 +6554,6 @@ var dataStructureTyped = (() => {
7292
6554
  createEdge(v1, v2, weight, value) {
7293
6555
  return new UndirectedEdge(v1, v2, weight != null ? weight : 1, value);
7294
6556
  }
7295
- /**
7296
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7297
- * Space Complexity: O(1)
7298
- */
7299
6557
  /**
7300
6558
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7301
6559
  * Space Complexity: O(1)
@@ -7319,10 +6577,6 @@ var dataStructureTyped = (() => {
7319
6577
  }
7320
6578
  return edgeMap ? edgeMap[0] || void 0 : void 0;
7321
6579
  }
7322
- /**
7323
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7324
- * Space Complexity: O(1)
7325
- */
7326
6580
  /**
7327
6581
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7328
6582
  * Space Complexity: O(1)
@@ -7350,10 +6604,6 @@ var dataStructureTyped = (() => {
7350
6604
  }
7351
6605
  return removed;
7352
6606
  }
7353
- /**
7354
- * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7355
- * Space Complexity: O(1)
7356
- */
7357
6607
  /**
7358
6608
  * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7359
6609
  * Space Complexity: O(1)
@@ -7386,10 +6636,6 @@ var dataStructureTyped = (() => {
7386
6636
  return;
7387
6637
  }
7388
6638
  }
7389
- /**
7390
- * Time Complexity: O(1) - Constant time for Map operations.
7391
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
7392
- */
7393
6639
  /**
7394
6640
  * Time Complexity: O(1) - Constant time for Map operations.
7395
6641
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -7424,10 +6670,6 @@ var dataStructureTyped = (() => {
7424
6670
  }
7425
6671
  return this._vertexMap.delete(vertexKey);
7426
6672
  }
7427
- /**
7428
- * Time Complexity: O(1)
7429
- * Space Complexity: O(1)
7430
- */
7431
6673
  /**
7432
6674
  * Time Complexity: O(1)
7433
6675
  * Space Complexity: O(1)
@@ -7447,10 +6689,6 @@ var dataStructureTyped = (() => {
7447
6689
  return 0;
7448
6690
  }
7449
6691
  }
7450
- /**
7451
- * Time Complexity: O(1)
7452
- * Space Complexity: O(1)
7453
- */
7454
6692
  /**
7455
6693
  * Time Complexity: O(1)
7456
6694
  * Space Complexity: O(1)
@@ -7468,10 +6706,6 @@ var dataStructureTyped = (() => {
7468
6706
  return [];
7469
6707
  }
7470
6708
  }
7471
- /**
7472
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7473
- * Space Complexity: O(|E|)
7474
- */
7475
6709
  /**
7476
6710
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7477
6711
  * Space Complexity: O(|E|)
@@ -7488,10 +6722,6 @@ var dataStructureTyped = (() => {
7488
6722
  });
7489
6723
  return [...edgeSet];
7490
6724
  }
7491
- /**
7492
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7493
- * Space Complexity: O(|E|)
7494
- */
7495
6725
  /**
7496
6726
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7497
6727
  * Space Complexity: O(|E|)
@@ -7515,10 +6745,6 @@ var dataStructureTyped = (() => {
7515
6745
  }
7516
6746
  return neighbors;
7517
6747
  }
7518
- /**
7519
- * Time Complexity: O(1)
7520
- * Space Complexity: O(1)
7521
- */
7522
6748
  /**
7523
6749
  * Time Complexity: O(1)
7524
6750
  * Space Complexity: O(1)
@@ -7548,10 +6774,6 @@ var dataStructureTyped = (() => {
7548
6774
  isEmpty() {
7549
6775
  return this.vertexMap.size === 0 && this.edgeMap.size === 0;
7550
6776
  }
7551
- /**
7552
- * Time Complexity: O(1)
7553
- * Space Complexity: O(1)
7554
- */
7555
6777
  /**
7556
6778
  * Time Complexity: O(1)
7557
6779
  * Space Complexity: O(1)
@@ -7577,10 +6799,6 @@ var dataStructureTyped = (() => {
7577
6799
  cloned.edgeMap = new Map(this.edgeMap);
7578
6800
  return cloned;
7579
6801
  }
7580
- /**
7581
- * Time Complexity: O(1)
7582
- * Space Complexity: O(1)
7583
- */
7584
6802
  /**
7585
6803
  * Time Complexity: O(V + E)
7586
6804
  * Space Complexity: O(V)
@@ -7637,12 +6855,6 @@ var dataStructureTyped = (() => {
7637
6855
  cutVertices
7638
6856
  };
7639
6857
  }
7640
- /**
7641
- * Time Complexity: O(V + E)
7642
- * Space Complexity: O(V)
7643
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
7644
- * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
7645
- */
7646
6858
  /**
7647
6859
  * The function "getBridges" returns an array of bridges in a graph using the Tarjan's algorithm.
7648
6860
  * @returns The function `getBridges()` is returning the bridges found using the Tarjan's algorithm.
@@ -7802,6 +7014,13 @@ var dataStructureTyped = (() => {
7802
7014
  }
7803
7015
  };
7804
7016
 
7017
+ // src/types/data-structures/binary-tree/binary-tree.ts
7018
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
7019
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
7020
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
7021
+ return DFSOperation2;
7022
+ })(DFSOperation || {});
7023
+
7805
7024
  // src/data-structures/binary-tree/binary-tree.ts
7806
7025
  var BinaryTreeNode = class {
7807
7026
  /**
@@ -7972,30 +7191,26 @@ var dataStructureTyped = (() => {
7972
7191
  return null;
7973
7192
  if (this.isNode(keyOrNodeOrEntryOrRawElement))
7974
7193
  return keyOrNodeOrEntryOrRawElement;
7975
- if (this.toEntryFn) {
7976
- const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
7977
- if (key)
7978
- return this.createNode(key, entryValue != null ? entryValue : value);
7979
- else
7980
- return;
7981
- }
7982
7194
  if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
7983
- const [key, value2] = keyOrNodeOrEntryOrRawElement;
7195
+ const [key, entryValue] = keyOrNodeOrEntryOrRawElement;
7984
7196
  if (key === void 0)
7985
7197
  return;
7986
7198
  else if (key === null)
7987
7199
  return null;
7200
+ if (this.isKey(key))
7201
+ return this.createNode(key, value != null ? value : entryValue);
7202
+ }
7203
+ if (this.toEntryFn) {
7204
+ const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
7205
+ if (this.isKey(key))
7206
+ return this.createNode(key, value != null ? value : entryValue);
7988
7207
  else
7989
- return this.createNode(key, value2);
7208
+ return;
7990
7209
  }
7991
7210
  if (this.isKey(keyOrNodeOrEntryOrRawElement))
7992
7211
  return this.createNode(keyOrNodeOrEntryOrRawElement, value);
7993
7212
  return;
7994
7213
  }
7995
- /**
7996
- * Time Complexity: O(n)
7997
- * Space Complexity: O(log n)
7998
- */
7999
7214
  /**
8000
7215
  * Time Complexity: O(n)
8001
7216
  * Space Complexity: O(log n)
@@ -8010,7 +7225,7 @@ var dataStructureTyped = (() => {
8010
7225
  * default value of `'ITERATIVE'`.
8011
7226
  * @returns The function `ensureNode` returns either a `NODE` object, `null`, or `undefined`.
8012
7227
  */
8013
- ensureNode(keyOrNodeOrEntryOrRawElement, iterationType = "ITERATIVE") {
7228
+ ensureNode(keyOrNodeOrEntryOrRawElement, iterationType = this.iterationType) {
8014
7229
  if (keyOrNodeOrEntryOrRawElement === null)
8015
7230
  return null;
8016
7231
  if (keyOrNodeOrEntryOrRawElement === void 0)
@@ -8021,7 +7236,7 @@ var dataStructureTyped = (() => {
8021
7236
  return keyOrNodeOrEntryOrRawElement;
8022
7237
  if (this.toEntryFn) {
8023
7238
  const [key] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
8024
- if (key)
7239
+ if (this.isKey(key))
8025
7240
  return this.getNodeByKey(key);
8026
7241
  }
8027
7242
  if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
@@ -8063,8 +7278,8 @@ var dataStructureTyped = (() => {
8063
7278
  * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
8064
7279
  * @returns a boolean value.
8065
7280
  */
8066
- isNodeOrNull(node) {
8067
- return this.isRealNode(node) || node === null;
7281
+ isRealNodeOrNull(node) {
7282
+ return node === null || this.isRealNode(node);
8068
7283
  }
8069
7284
  /**
8070
7285
  * The function checks if a given node is equal to the NIL value.
@@ -8075,6 +7290,23 @@ var dataStructureTyped = (() => {
8075
7290
  isNIL(node) {
8076
7291
  return node === this.NIL;
8077
7292
  }
7293
+ /**
7294
+ * The function `isLeaf` determines whether a given node is a leaf node in a binary tree structure.
7295
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter in the `isLeaf` function
7296
+ * can be either a regular node (`R`) or a `BTNKeyOrNodeOrEntry<K, V, NODE>`.
7297
+ * @returns The `isLeaf` function is checking if the provided node is a leaf node in a binary tree.
7298
+ * If the node is `undefined`, it returns `false`. If the node is `null`, it returns `true`.
7299
+ * Otherwise, it checks if both the left and right children of the node are not real nodes, and
7300
+ * returns `true` if they are not, indicating that the node is a
7301
+ */
7302
+ isLeaf(node) {
7303
+ node = this.ensureNode(node);
7304
+ if (node === void 0)
7305
+ return false;
7306
+ if (node === null)
7307
+ return true;
7308
+ return !this.isRealNode(node.left) && !this.isRealNode(node.right);
7309
+ }
8078
7310
  /**
8079
7311
  * The function checks if the input is an array with two elements, indicating it is a binary tree
8080
7312
  * node entry.
@@ -8086,41 +7318,21 @@ var dataStructureTyped = (() => {
8086
7318
  return Array.isArray(keyOrNodeOrEntryOrRawElement) && keyOrNodeOrEntryOrRawElement.length === 2;
8087
7319
  }
8088
7320
  /**
8089
- * The function checks if a given value is a valid key by evaluating its type and value.
8090
- * @param {any} key - The `key` parameter can be of any type. It is the value that we want to check
8091
- * if it is a valid key.
8092
- * @param [isCheckValueOf=true] - The `isCheckValueOf` parameter is a boolean flag that determines
8093
- * whether the function should check the valueOf() method of an object when the key is of type
8094
- * 'object'. If `isCheckValueOf` is true, the function will recursively call itself with the value
8095
- * returned by key.valueOf().
8096
- * @returns a boolean value.
7321
+ * Time Complexity O(1)
7322
+ * Space Complexity O(1)
7323
+ *
7324
+ * The function `isKey` checks if a given key is comparable.
7325
+ * @param {any} key - The `key` parameter is of type `any`, which means it can be any data type in
7326
+ * TypeScript.
7327
+ * @returns The function `isKey` is checking if the `key` parameter is `null` or if it is comparable.
7328
+ * If the `key` is `null`, the function returns `true`. Otherwise, it returns the result of the
7329
+ * `isComparable` function, which is not provided in the code snippet.
8097
7330
  */
8098
- isKey(key, isCheckValueOf = true) {
7331
+ isKey(key) {
8099
7332
  if (key === null)
8100
7333
  return true;
8101
- const keyType = typeof key;
8102
- if (keyType === "string" || keyType === "bigint" || keyType === "boolean")
8103
- return true;
8104
- if (keyType === "number")
8105
- return !isNaN(key);
8106
- if (keyType === "symbol" || keyType === "undefined")
8107
- return false;
8108
- if (keyType === "function")
8109
- return this.isKey(key());
8110
- if (keyType === "object") {
8111
- if (typeof key.toString === "function")
8112
- return true;
8113
- if (isCheckValueOf && typeof key.valueOf === "function") {
8114
- this.isKey(key.valueOf(), false);
8115
- }
8116
- return false;
8117
- }
8118
- return false;
7334
+ return isComparable(key);
8119
7335
  }
8120
- /**
8121
- * Time Complexity O(n)
8122
- * Space Complexity O(1)
8123
- */
8124
7336
  /**
8125
7337
  * Time Complexity O(n)
8126
7338
  * Space Complexity O(1)
@@ -8177,11 +7389,6 @@ var dataStructureTyped = (() => {
8177
7389
  }
8178
7390
  return false;
8179
7391
  }
8180
- /**
8181
- * Time Complexity: O(k * n)
8182
- * Space Complexity: O(1)
8183
- * Comments: The time complexity for adding a node depends on the depth of the tree. In the best case (when the tree is empty), it's O(1). In the worst case (when the tree is a degenerate tree), it's O(n). The space complexity is constant.
8184
- */
8185
7392
  /**
8186
7393
  * Time Complexity: O(k * n)
8187
7394
  * Space Complexity: O(1)
@@ -8214,11 +7421,6 @@ var dataStructureTyped = (() => {
8214
7421
  }
8215
7422
  return inserted;
8216
7423
  }
8217
- /**
8218
- * Time Complexity: O(k * n)
8219
- * Space Complexity: O(1)
8220
- * "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
8221
- */
8222
7424
  /**
8223
7425
  * Time Complexity: O(k * n)
8224
7426
  * Space Complexity: O(1)
@@ -8234,10 +7436,6 @@ var dataStructureTyped = (() => {
8234
7436
  this.clear();
8235
7437
  this.addMany(keysOrNodesOrEntriesOrRawElements, values);
8236
7438
  }
8237
- /**
8238
- * Time Complexity: O(n)
8239
- * Space Complexity: O(1)
8240
- */
8241
7439
  /**
8242
7440
  * Time Complexity: O(n)
8243
7441
  * Space Complexity: O(1)
@@ -8267,7 +7465,7 @@ var dataStructureTyped = (() => {
8267
7465
  if (!curr.left && !curr.right && !parent) {
8268
7466
  this._setRoot(void 0);
8269
7467
  } else if (curr.left) {
8270
- const leftSubTreeRightMost = this.getRightMost(curr.left);
7468
+ const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);
8271
7469
  if (leftSubTreeRightMost) {
8272
7470
  const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
8273
7471
  orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
@@ -8295,10 +7493,6 @@ var dataStructureTyped = (() => {
8295
7493
  deletedResult.push({ deleted: orgCurrent, needBalanced });
8296
7494
  return deletedResult;
8297
7495
  }
8298
- /**
8299
- * Time Complexity: O(n)
8300
- * Space Complexity: O(k + log n)
8301
- */
8302
7496
  /**
8303
7497
  * Time Complexity: O(n)
8304
7498
  * Space Complexity: O(k + log n)
@@ -8324,6 +7518,10 @@ var dataStructureTyped = (() => {
8324
7518
  * @returns an array of NODE objects.
8325
7519
  */
8326
7520
  getNodes(identifier, callback = this._DEFAULT_CALLBACK, onlyOne = false, beginRoot = this.root, iterationType = this.iterationType) {
7521
+ if (identifier === void 0)
7522
+ return [];
7523
+ if (identifier === null)
7524
+ return [];
8327
7525
  beginRoot = this.ensureNode(beginRoot);
8328
7526
  if (!beginRoot)
8329
7527
  return [];
@@ -8359,10 +7557,6 @@ var dataStructureTyped = (() => {
8359
7557
  }
8360
7558
  return ans;
8361
7559
  }
8362
- /**
8363
- * Time Complexity: O(n)
8364
- * Space Complexity: O(log n).
8365
- */
8366
7560
  /**
8367
7561
  * Time Complexity: O(n)
8368
7562
  * Space Complexity: O(log n).
@@ -8385,10 +7579,6 @@ var dataStructureTyped = (() => {
8385
7579
  var _a;
8386
7580
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) != null ? _a : null;
8387
7581
  }
8388
- /**
8389
- * Time Complexity: O(n)
8390
- * Space Complexity: O(log n)
8391
- */
8392
7582
  /**
8393
7583
  * Time Complexity: O(n)
8394
7584
  * Space Complexity: O(log n)
@@ -8401,13 +7591,9 @@ var dataStructureTyped = (() => {
8401
7591
  * It has a default value of `'ITERATIVE'`.
8402
7592
  * @returns a value of type NODE, null, or undefined.
8403
7593
  */
8404
- getNodeByKey(key, iterationType = "ITERATIVE") {
7594
+ getNodeByKey(key, iterationType = this.iterationType) {
8405
7595
  return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
8406
7596
  }
8407
- /**
8408
- * Time Complexity: O(n)
8409
- * Space Complexity: O(log n)
8410
- */
8411
7597
  /**
8412
7598
  * Time Complexity: O(n)
8413
7599
  * Space Complexity: O(log n)
@@ -8433,10 +7619,6 @@ var dataStructureTyped = (() => {
8433
7619
  var _a;
8434
7620
  return (_a = this.getNode(identifier, callback, beginRoot, iterationType)) == null ? void 0 : _a.value;
8435
7621
  }
8436
- /**
8437
- * Time Complexity: O(n)
8438
- * Space Complexity: O(log n)
8439
- */
8440
7622
  /**
8441
7623
  * Time Complexity: O(n)
8442
7624
  * Space Complexity: O(log n)
@@ -8461,10 +7643,6 @@ var dataStructureTyped = (() => {
8461
7643
  callback = this._ensureCallback(identifier, callback);
8462
7644
  return this.getNodes(identifier, callback, true, beginRoot, iterationType).length > 0;
8463
7645
  }
8464
- /**
8465
- * Time Complexity: O(1)
8466
- * Space Complexity: O(1)
8467
- */
8468
7646
  /**
8469
7647
  * Time Complexity: O(1)
8470
7648
  * Space Complexity: O(1)
@@ -8475,10 +7653,6 @@ var dataStructureTyped = (() => {
8475
7653
  this._setRoot(void 0);
8476
7654
  this._size = 0;
8477
7655
  }
8478
- /**
8479
- * Time Complexity: O(1)
8480
- * Space Complexity: O(1)
8481
- */
8482
7656
  /**
8483
7657
  * Time Complexity: O(1)
8484
7658
  * Space Complexity: O(1)
@@ -8489,10 +7663,6 @@ var dataStructureTyped = (() => {
8489
7663
  isEmpty() {
8490
7664
  return this.size === 0;
8491
7665
  }
8492
- /**
8493
- * Time Complexity: O(n)
8494
- * Space Complexity: O(log n)
8495
- */
8496
7666
  /**
8497
7667
  * Time Complexity: O(n)
8498
7668
  * Space Complexity: O(log n)
@@ -8508,10 +7678,6 @@ var dataStructureTyped = (() => {
8508
7678
  isPerfectlyBalanced(beginRoot = this.root) {
8509
7679
  return this.getMinHeight(beginRoot) + 1 >= this.getHeight(beginRoot);
8510
7680
  }
8511
- /**
8512
- * Time Complexity: O(n)
8513
- * Space Complexity: O(1)
8514
- */
8515
7681
  /**
8516
7682
  * Time Complexity: O(n)
8517
7683
  * Space Complexity: O(1)
@@ -8565,10 +7731,6 @@ var dataStructureTyped = (() => {
8565
7731
  return isStandardBST || isInverseBST;
8566
7732
  }
8567
7733
  }
8568
- /**
8569
- * Time Complexity: O(n)
8570
- * Space Complexity: O(1)
8571
- */
8572
7734
  /**
8573
7735
  * Time Complexity: O(n)
8574
7736
  * Space Complexity: O(1)
@@ -8596,10 +7758,6 @@ var dataStructureTyped = (() => {
8596
7758
  }
8597
7759
  return depth;
8598
7760
  }
8599
- /**
8600
- * Time Complexity: O(n)
8601
- * Space Complexity: O(1)
8602
- */
8603
7761
  /**
8604
7762
  * Time Complexity: O(n)
8605
7763
  * Space Complexity: O(1)
@@ -8640,10 +7798,6 @@ var dataStructureTyped = (() => {
8640
7798
  return maxHeight;
8641
7799
  }
8642
7800
  }
8643
- /**
8644
- * Time Complexity: O(n)
8645
- * Space Complexity: O(log n)
8646
- */
8647
7801
  /**
8648
7802
  * Time Complexity: O(n)
8649
7803
  * Space Complexity: O(log n)
@@ -8702,10 +7856,6 @@ var dataStructureTyped = (() => {
8702
7856
  return (_c = depths.get(beginRoot)) != null ? _c : -1;
8703
7857
  }
8704
7858
  }
8705
- /**
8706
- * Time Complexity: O(log n)
8707
- * Space Complexity: O(log n)
8708
- */
8709
7859
  /**
8710
7860
  * Time Complexity: O(log n)
8711
7861
  * Space Complexity: O(log n)
@@ -8731,89 +7881,93 @@ var dataStructureTyped = (() => {
8731
7881
  result.push(beginNodeEnsured);
8732
7882
  return isReverse ? result.reverse() : result;
8733
7883
  }
8734
- /**
8735
- * Time Complexity: O(log n)
8736
- * Space Complexity: O(1)
8737
- */
8738
7884
  /**
8739
7885
  * Time Complexity: O(log n)
8740
7886
  * Space Complexity: O(1)
8741
7887
  *
8742
- * The `getLeftMost` function returns the leftmost node in a binary tree, either using recursive or
8743
- * iterative traversal.
8744
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
8745
- * starting point for finding the leftmost node in a binary tree. It can be either a root node (`R`),
8746
- * a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
8747
- * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
8748
- * of iteration to be performed. It can have two possible values:
8749
- * @returns The function `getLeftMost` returns the leftmost node in a binary tree.
7888
+ * The function `getLeftMost` retrieves the leftmost node in a binary tree using either recursive or
7889
+ * tail-recursive iteration.
7890
+ * @param {C} callback - The `callback` parameter is a function that will be called with the leftmost
7891
+ * node of a binary tree or null if the tree is empty. It has a default value of `_DEFAULT_CALLBACK`
7892
+ * if not provided explicitly.
7893
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter in the
7894
+ * `getLeftMost` function represents the starting point for finding the leftmost node in a binary
7895
+ * tree. It can be either a reference to the root node of the tree (`R`), or a key, node, or entry in
7896
+ * the binary tree structure (`
7897
+ * @param {IterationType} iterationType - The `iterationType` parameter in the `getLeftMost` function
7898
+ * specifies the type of iteration to be used when traversing the binary tree nodes. It can have two
7899
+ * possible values:
7900
+ * @returns The `getLeftMost` function returns the result of the callback function `C` applied to the
7901
+ * leftmost node in the binary tree starting from the `beginRoot` node. If the `beginRoot` is `NIL`,
7902
+ * it returns the result of the callback function applied to `undefined`. If the `beginRoot` is not a
7903
+ * real node, it returns the result of the callback function applied
8750
7904
  */
8751
- getLeftMost(beginRoot = this.root, iterationType = this.iterationType) {
7905
+ getLeftMost(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
8752
7906
  if (this.isNIL(beginRoot))
8753
- return beginRoot;
7907
+ return callback(void 0);
8754
7908
  beginRoot = this.ensureNode(beginRoot);
8755
7909
  if (!this.isRealNode(beginRoot))
8756
- return beginRoot;
7910
+ return callback(beginRoot);
8757
7911
  if (iterationType === "RECURSIVE") {
8758
7912
  const dfs = (cur) => {
8759
7913
  if (!this.isRealNode(cur.left))
8760
7914
  return cur;
8761
7915
  return dfs(cur.left);
8762
7916
  };
8763
- return dfs(beginRoot);
7917
+ return callback(dfs(beginRoot));
8764
7918
  } else {
8765
7919
  const dfs = trampoline((cur) => {
8766
7920
  if (!this.isRealNode(cur.left))
8767
7921
  return cur;
8768
7922
  return dfs.cont(cur.left);
8769
7923
  });
8770
- return dfs(beginRoot);
7924
+ return callback(dfs(beginRoot));
8771
7925
  }
8772
7926
  }
8773
- /**
8774
- * Time Complexity: O(log n)
8775
- * Space Complexity: O(1)
8776
- */
8777
7927
  /**
8778
7928
  * Time Complexity: O(log n)
8779
7929
  * Space Complexity: O(1)
8780
7930
  *
8781
- * The `getRightMost` function returns the rightmost node in a binary tree, either recursively or
8782
- * iteratively.
8783
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
8784
- * starting point for finding the rightmost node in a binary tree. It can be either a root node
8785
- * (`R`), a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
8786
- * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
8787
- * of iteration to be performed when finding the rightmost node in a binary tree. It can have two
8788
- * possible values:
8789
- * @returns The function `getRightMost` returns a NODE object, `null`, or `undefined`.
7931
+ * The function `getRightMost` retrieves the rightmost node in a binary tree using either recursive
7932
+ * or iterative traversal methods.
7933
+ * @param {C} callback - The `callback` parameter is a function that will be called with the result
7934
+ * of the operation. It has a generic type `C` which extends `BTNCallback<OptBTNOrNull<NODE>>`. The
7935
+ * default value for `callback` is `this._DEFAULT_CALLBACK` if it is not provided.
7936
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter in the
7937
+ * `getRightMost` function represents the starting point for finding the rightmost node in a binary
7938
+ * tree. It can be either a reference to the root node of the tree (`this.root`) or a specific key,
7939
+ * node, or entry in the tree. If
7940
+ * @param {IterationType} iterationType - The `iterationType` parameter in the `getRightMost`
7941
+ * function specifies the type of iteration to be used when finding the rightmost node in a binary
7942
+ * tree. It can have two possible values:
7943
+ * @returns The `getRightMost` function returns the result of the callback function `C` applied to
7944
+ * the rightmost node in the binary tree. The rightmost node is found either through a recursive
7945
+ * depth-first search (if `iterationType` is 'RECURSIVE') or through an indirect implementation of
7946
+ * iteration using tail recursion optimization. The result of the callback function applied to the
7947
+ * rightmost node is returned
8790
7948
  */
8791
- getRightMost(beginRoot = this.root, iterationType = this.iterationType) {
7949
+ getRightMost(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
8792
7950
  if (this.isNIL(beginRoot))
8793
- return beginRoot;
7951
+ return callback(void 0);
8794
7952
  beginRoot = this.ensureNode(beginRoot);
8795
7953
  if (!beginRoot)
8796
- return beginRoot;
7954
+ return callback(beginRoot);
8797
7955
  if (iterationType === "RECURSIVE") {
8798
7956
  const dfs = (cur) => {
8799
7957
  if (!this.isRealNode(cur.right))
8800
7958
  return cur;
8801
7959
  return dfs(cur.right);
8802
7960
  };
8803
- return dfs(beginRoot);
7961
+ return callback(dfs(beginRoot));
8804
7962
  } else {
8805
7963
  const dfs = trampoline((cur) => {
8806
7964
  if (!this.isRealNode(cur.right))
8807
7965
  return cur;
8808
7966
  return dfs.cont(cur.right);
8809
7967
  });
8810
- return dfs(beginRoot);
7968
+ return callback(dfs(beginRoot));
8811
7969
  }
8812
7970
  }
8813
- /**
8814
- * Time Complexity: O(log n)
8815
- * Space Complexity: O(1)
8816
- */
8817
7971
  /**
8818
7972
  * Time Complexity: O(log n)
8819
7973
  * Space Complexity: O(1)
@@ -8836,10 +7990,6 @@ var dataStructureTyped = (() => {
8836
7990
  return node;
8837
7991
  }
8838
7992
  }
8839
- /**
8840
- * Time Complexity: O(log n)
8841
- * Space Complexity: O(1)
8842
- */
8843
7993
  /**
8844
7994
  * Time Complexity: O(log n)
8845
7995
  * Space Complexity: O(1)
@@ -8854,7 +8004,7 @@ var dataStructureTyped = (() => {
8854
8004
  if (!this.isRealNode(x))
8855
8005
  return void 0;
8856
8006
  if (this.isRealNode(x.right)) {
8857
- return this.getLeftMost(x.right);
8007
+ return this.getLeftMost((node) => node, x.right);
8858
8008
  }
8859
8009
  let y = x.parent;
8860
8010
  while (this.isRealNode(y) && x === y.right) {
@@ -8863,10 +8013,6 @@ var dataStructureTyped = (() => {
8863
8013
  }
8864
8014
  return y;
8865
8015
  }
8866
- /**
8867
- * Time complexity: O(n)
8868
- * Space complexity: O(n)
8869
- */
8870
8016
  /**
8871
8017
  * Time complexity: O(n)
8872
8018
  * Space complexity: O(n)
@@ -8890,109 +8036,12 @@ var dataStructureTyped = (() => {
8890
8036
  * values will
8891
8037
  * @returns an array of the return types of the callback function.
8892
8038
  */
8893
- dfs(callback = this._DEFAULT_CALLBACK, pattern = "IN", beginRoot = this.root, iterationType = "ITERATIVE", includeNull = false) {
8039
+ dfs(callback = this._DEFAULT_CALLBACK, pattern = "IN", beginRoot = this.root, iterationType = this.iterationType, includeNull = false) {
8894
8040
  beginRoot = this.ensureNode(beginRoot);
8895
8041
  if (!beginRoot)
8896
8042
  return [];
8897
- const ans = [];
8898
- if (iterationType === "RECURSIVE") {
8899
- const dfs = (node) => {
8900
- switch (pattern) {
8901
- case "IN":
8902
- if (includeNull) {
8903
- if (this.isRealNode(node) && this.isNodeOrNull(node.left))
8904
- dfs(node.left);
8905
- this.isNodeOrNull(node) && ans.push(callback(node));
8906
- if (this.isRealNode(node) && this.isNodeOrNull(node.right))
8907
- dfs(node.right);
8908
- } else {
8909
- if (this.isRealNode(node) && this.isRealNode(node.left))
8910
- dfs(node.left);
8911
- this.isRealNode(node) && ans.push(callback(node));
8912
- if (this.isRealNode(node) && this.isRealNode(node.right))
8913
- dfs(node.right);
8914
- }
8915
- break;
8916
- case "PRE":
8917
- if (includeNull) {
8918
- this.isNodeOrNull(node) && ans.push(callback(node));
8919
- if (this.isRealNode(node) && this.isNodeOrNull(node.left))
8920
- dfs(node.left);
8921
- if (this.isRealNode(node) && this.isNodeOrNull(node.right))
8922
- dfs(node.right);
8923
- } else {
8924
- this.isRealNode(node) && ans.push(callback(node));
8925
- if (this.isRealNode(node) && this.isRealNode(node.left))
8926
- dfs(node.left);
8927
- if (this.isRealNode(node) && this.isRealNode(node.right))
8928
- dfs(node.right);
8929
- }
8930
- break;
8931
- case "POST":
8932
- if (includeNull) {
8933
- if (this.isRealNode(node) && this.isNodeOrNull(node.left))
8934
- dfs(node.left);
8935
- if (this.isRealNode(node) && this.isNodeOrNull(node.right))
8936
- dfs(node.right);
8937
- this.isNodeOrNull(node) && ans.push(callback(node));
8938
- } else {
8939
- if (this.isRealNode(node) && this.isRealNode(node.left))
8940
- dfs(node.left);
8941
- if (this.isRealNode(node) && this.isRealNode(node.right))
8942
- dfs(node.right);
8943
- this.isRealNode(node) && ans.push(callback(node));
8944
- }
8945
- break;
8946
- }
8947
- };
8948
- dfs(beginRoot);
8949
- } else {
8950
- const stack = [{ opt: 0, node: beginRoot }];
8951
- while (stack.length > 0) {
8952
- const cur = stack.pop();
8953
- if (cur === void 0 || this.isNIL(cur.node))
8954
- continue;
8955
- if (includeNull) {
8956
- if (cur.node === void 0)
8957
- continue;
8958
- } else {
8959
- if (cur.node === null || cur.node === void 0)
8960
- continue;
8961
- }
8962
- if (cur.opt === 1) {
8963
- ans.push(callback(cur.node));
8964
- } else {
8965
- switch (pattern) {
8966
- case "IN":
8967
- cur.node && stack.push({ opt: 0, node: cur.node.right });
8968
- stack.push({ opt: 1, node: cur.node });
8969
- cur.node && stack.push({ opt: 0, node: cur.node.left });
8970
- break;
8971
- case "PRE":
8972
- cur.node && stack.push({ opt: 0, node: cur.node.right });
8973
- cur.node && stack.push({ opt: 0, node: cur.node.left });
8974
- stack.push({ opt: 1, node: cur.node });
8975
- break;
8976
- case "POST":
8977
- stack.push({ opt: 1, node: cur.node });
8978
- cur.node && stack.push({ opt: 0, node: cur.node.right });
8979
- cur.node && stack.push({ opt: 0, node: cur.node.left });
8980
- break;
8981
- default:
8982
- cur.node && stack.push({ opt: 0, node: cur.node.right });
8983
- stack.push({ opt: 1, node: cur.node });
8984
- cur.node && stack.push({ opt: 0, node: cur.node.left });
8985
- break;
8986
- }
8987
- }
8988
- }
8989
- }
8990
- return ans;
8043
+ return this._dfs(callback, pattern, beginRoot, iterationType, includeNull);
8991
8044
  }
8992
- /**
8993
- * Time complexity: O(n)
8994
- * Space complexity: O(n)
8995
- */
8996
8045
  /**
8997
8046
  * Time complexity: O(n)
8998
8047
  * Space complexity: O(n)
@@ -9028,9 +8077,9 @@ var dataStructureTyped = (() => {
9028
8077
  const current = queue.shift();
9029
8078
  ans.push(callback(current));
9030
8079
  if (includeNull) {
9031
- if (current && this.isNodeOrNull(current.left))
8080
+ if (current && this.isRealNodeOrNull(current.left))
9032
8081
  queue.push(current.left);
9033
- if (current && this.isNodeOrNull(current.right))
8082
+ if (current && this.isRealNodeOrNull(current.right))
9034
8083
  queue.push(current.right);
9035
8084
  } else {
9036
8085
  if (this.isRealNode(current.left))
@@ -9049,9 +8098,9 @@ var dataStructureTyped = (() => {
9049
8098
  const current = queue.shift();
9050
8099
  ans.push(callback(current));
9051
8100
  if (includeNull) {
9052
- if (current && this.isNodeOrNull(current.left))
8101
+ if (current && this.isRealNodeOrNull(current.left))
9053
8102
  queue.push(current.left);
9054
- if (current && this.isNodeOrNull(current.right))
8103
+ if (current && this.isRealNodeOrNull(current.right))
9055
8104
  queue.push(current.right);
9056
8105
  } else {
9057
8106
  if (this.isRealNode(current.left))
@@ -9067,7 +8116,54 @@ var dataStructureTyped = (() => {
9067
8116
  /**
9068
8117
  * Time complexity: O(n)
9069
8118
  * Space complexity: O(n)
9070
- */
8119
+ *
8120
+ * The `leaves` function in TypeScript iterates through a binary tree to find and return the leaf
8121
+ * nodes based on a specified callback and iteration type.
8122
+ * @param {C} callback - The `callback` parameter is a function that will be called on each leaf node
8123
+ * in the binary tree. It is a generic type `C` that extends `BTNCallback<NODE | null>`, where `NODE`
8124
+ * represents a node in the binary tree. The default value for `callback` is
8125
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter in the `leaves`
8126
+ * method is used to specify the starting point for finding and processing the leaves of a binary
8127
+ * tree. It represents the root node of the binary tree or a specific key, node, or entry within the
8128
+ * tree from which the search for leaves should begin
8129
+ * @param {IterationType} iterationType - The `iterationType` parameter in the `leaves` method
8130
+ * specifies the type of iteration to be performed when collecting the leaves of a binary tree. It
8131
+ * can have two possible values:
8132
+ * @returns The `leaves` method returns an array of values that are the result of applying the
8133
+ * provided callback function to the leaf nodes in the binary tree structure.
8134
+ */
8135
+ leaves(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
8136
+ beginRoot = this.ensureNode(beginRoot);
8137
+ const leaves = [];
8138
+ if (!this.isRealNode(beginRoot)) {
8139
+ return [];
8140
+ }
8141
+ if (iterationType === "RECURSIVE") {
8142
+ const dfs = (cur) => {
8143
+ if (this.isLeaf(cur)) {
8144
+ leaves.push(callback(cur));
8145
+ }
8146
+ if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right))
8147
+ return;
8148
+ this.isRealNode(cur.left) && dfs(cur.left);
8149
+ this.isRealNode(cur.right) && dfs(cur.right);
8150
+ };
8151
+ dfs(beginRoot);
8152
+ } else {
8153
+ const queue = new Queue([beginRoot]);
8154
+ while (queue.size > 0) {
8155
+ const cur = queue.shift();
8156
+ if (this.isRealNode(cur)) {
8157
+ if (this.isLeaf(cur)) {
8158
+ leaves.push(callback(cur));
8159
+ }
8160
+ this.isRealNode(cur.left) && queue.push(cur.left);
8161
+ this.isRealNode(cur.right) && queue.push(cur.right);
8162
+ }
8163
+ }
8164
+ }
8165
+ return leaves;
8166
+ }
9071
8167
  /**
9072
8168
  * Time complexity: O(n)
9073
8169
  * Space complexity: O(n)
@@ -9100,9 +8196,9 @@ var dataStructureTyped = (() => {
9100
8196
  levelsNodes[level] = [];
9101
8197
  levelsNodes[level].push(callback(node));
9102
8198
  if (includeNull) {
9103
- if (node && this.isNodeOrNull(node.left))
8199
+ if (node && this.isRealNodeOrNull(node.left))
9104
8200
  _recursive(node.left, level + 1);
9105
- if (node && this.isNodeOrNull(node.right))
8201
+ if (node && this.isRealNodeOrNull(node.right))
9106
8202
  _recursive(node.right, level + 1);
9107
8203
  } else {
9108
8204
  if (node && node.left)
@@ -9121,9 +8217,9 @@ var dataStructureTyped = (() => {
9121
8217
  levelsNodes[level] = [];
9122
8218
  levelsNodes[level].push(callback(node));
9123
8219
  if (includeNull) {
9124
- if (node && this.isNodeOrNull(node.right))
8220
+ if (node && this.isRealNodeOrNull(node.right))
9125
8221
  stack.push([node.right, level + 1]);
9126
- if (node && this.isNodeOrNull(node.left))
8222
+ if (node && this.isRealNodeOrNull(node.left))
9127
8223
  stack.push([node.left, level + 1]);
9128
8224
  } else {
9129
8225
  if (node && node.right)
@@ -9135,10 +8231,6 @@ var dataStructureTyped = (() => {
9135
8231
  }
9136
8232
  return levelsNodes;
9137
8233
  }
9138
- /**
9139
- * Time complexity: O(n)
9140
- * Space complexity: O(n)
9141
- */
9142
8234
  /**
9143
8235
  * Time complexity: O(n)
9144
8236
  * Space complexity: O(n)
@@ -9239,10 +8331,6 @@ var dataStructureTyped = (() => {
9239
8331
  }
9240
8332
  return ans;
9241
8333
  }
9242
- /**
9243
- * Time complexity: O(n)
9244
- * Space complexity: O(n)
9245
- */
9246
8334
  /**
9247
8335
  * Time complexity: O(n)
9248
8336
  * Space complexity: O(n)
@@ -9265,10 +8353,6 @@ var dataStructureTyped = (() => {
9265
8353
  );
9266
8354
  return cloned;
9267
8355
  }
9268
- /**
9269
- * Time Complexity: O(n)
9270
- * Space Complexity: O(n)
9271
- */
9272
8356
  /**
9273
8357
  * Time Complexity: O(n)
9274
8358
  * Space Complexity: O(n)
@@ -9294,10 +8378,6 @@ var dataStructureTyped = (() => {
9294
8378
  }
9295
8379
  return newTree;
9296
8380
  }
9297
- /**
9298
- * Time Complexity: O(n)
9299
- * Space Complexity: O(n)
9300
- */
9301
8381
  /**
9302
8382
  * Time Complexity: O(n)
9303
8383
  * Space Complexity: O(n)
@@ -9330,10 +8410,6 @@ var dataStructureTyped = (() => {
9330
8410
  // // return newTree;
9331
8411
  // // }
9332
8412
  //
9333
- /**
9334
- * Time Complexity: O(n)
9335
- * Space Complexity: O(n)
9336
- */
9337
8413
  /**
9338
8414
  * Time Complexity: O(n)
9339
8415
  * Space Complexity: O(n)
@@ -9351,29 +8427,163 @@ var dataStructureTyped = (() => {
9351
8427
  print(beginRoot = this.root, options) {
9352
8428
  const opts = __spreadValues({ isShowUndefined: false, isShowNull: false, isShowRedBlackNIL: false }, options);
9353
8429
  beginRoot = this.ensureNode(beginRoot);
8430
+ let output = "";
9354
8431
  if (!beginRoot)
9355
- return;
8432
+ return output;
9356
8433
  if (opts.isShowUndefined)
9357
- console.log(`U for undefined
9358
- `);
8434
+ output += `U for undefined
8435
+ `;
9359
8436
  if (opts.isShowNull)
9360
- console.log(`N for null
9361
- `);
8437
+ output += `N for null
8438
+ `;
9362
8439
  if (opts.isShowRedBlackNIL)
9363
- console.log(`S for Sentinel Node(NIL)
9364
- `);
8440
+ output += `S for Sentinel Node(NIL)
8441
+ `;
9365
8442
  const display = (root) => {
9366
8443
  const [lines, , ,] = this._displayAux(root, opts);
8444
+ let paragraph = "";
9367
8445
  for (const line of lines) {
9368
- console.log(line);
8446
+ paragraph += line + "\n";
9369
8447
  }
8448
+ output += paragraph;
9370
8449
  };
9371
8450
  display(beginRoot);
8451
+ return output;
9372
8452
  }
9373
8453
  /**
9374
- * Time Complexity: O(1)
9375
- * Space Complexity: O(1)
9376
- */
8454
+ * Time complexity: O(n)
8455
+ * Space complexity: O(n)
8456
+ *
8457
+ * The function `_dfs` performs a depth-first search traversal on a binary tree structure based on
8458
+ * the specified order pattern and callback function.
8459
+ * @param {C} callback - The `callback` parameter is a function that will be called on each node
8460
+ * visited during the depth-first search. It is of type `C`, which extends
8461
+ * `BTNCallback<OptBTNOrNull<NODE>>`. The default value is set to `this._DEFAULT_CALLBACK` if not
8462
+ * provided.
8463
+ * @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `_dfs` method specifies the
8464
+ * order in which the Depth-First Search (DFS) algorithm should traverse the nodes in a binary tree.
8465
+ * It can have one of the following values:
8466
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter in the `_dfs`
8467
+ * method is used to specify the starting point for the depth-first search traversal in a binary
8468
+ * tree. It can be provided as either the root node of the tree or a key, node, or entry that exists
8469
+ * in the tree. If no specific `
8470
+ * @param {IterationType} iterationType - The `iterationType` parameter in the `_dfs` method
8471
+ * specifies the type of iteration to be performed during the Depth-First Search (DFS) traversal. It
8472
+ * can have two possible values:
8473
+ * @param [includeNull=false] - The `includeNull` parameter in the `_dfs` method is a boolean flag
8474
+ * that determines whether null nodes should be included in the depth-first search traversal. If
8475
+ * `includeNull` is set to `true`, the traversal will consider null nodes as valid nodes to visit and
8476
+ * process. If set to `
8477
+ * @param shouldVisitLeft - The `shouldVisitLeft` parameter is a function that takes a node as input
8478
+ * and returns a boolean value. It is used to determine whether the left child of a node should be
8479
+ * visited during the depth-first search traversal. By default, it checks if the node is truthy (not
8480
+ * null or undefined
8481
+ * @param shouldVisitRight - The `shouldVisitRight` parameter is a function that takes a node as
8482
+ * input and returns a boolean value. It is used to determine whether the right child of a node
8483
+ * should be visited during the depth-first search traversal. The default implementation checks if
8484
+ * the node is truthy before visiting the right child.
8485
+ * @param shouldVisitRoot - The `shouldVisitRoot` parameter is a function that takes a node as an
8486
+ * argument and returns a boolean value. It is used to determine whether a given node should be
8487
+ * visited during the depth-first search traversal based on certain conditions. The default
8488
+ * implementation checks if the node is a real node or null based
8489
+ * @param shouldProcessRoot - The `shouldProcessRoot` parameter is a function that takes a node as
8490
+ * input and returns a boolean value indicating whether the node should be processed during the
8491
+ * depth-first search traversal. The default implementation of this function simply returns `true`,
8492
+ * meaning that by default all nodes will be processed. However, you can
8493
+ * @returns The `_dfs` method returns an array of the return type of the callback function provided
8494
+ * as input.
8495
+ */
8496
+ _dfs(callback = this._DEFAULT_CALLBACK, pattern = "IN", beginRoot = this.root, iterationType = this.iterationType, includeNull = false, shouldVisitLeft = (node) => !!node, shouldVisitRight = (node) => !!node, shouldVisitRoot = (node) => {
8497
+ if (includeNull)
8498
+ return this.isRealNodeOrNull(node);
8499
+ return this.isRealNode(node);
8500
+ }, shouldProcessRoot = (node) => this.isRealNodeOrNull(node)) {
8501
+ beginRoot = this.ensureNode(beginRoot);
8502
+ if (!beginRoot)
8503
+ return [];
8504
+ const ans = [];
8505
+ if (iterationType === "RECURSIVE") {
8506
+ const dfs = (node) => {
8507
+ if (!shouldVisitRoot(node))
8508
+ return;
8509
+ const visitLeft = () => {
8510
+ if (shouldVisitLeft(node))
8511
+ dfs(node == null ? void 0 : node.left);
8512
+ };
8513
+ const visitRight = () => {
8514
+ if (shouldVisitRight(node))
8515
+ dfs(node == null ? void 0 : node.right);
8516
+ };
8517
+ switch (pattern) {
8518
+ case "IN":
8519
+ visitLeft();
8520
+ if (shouldProcessRoot(node))
8521
+ ans.push(callback(node));
8522
+ visitRight();
8523
+ break;
8524
+ case "PRE":
8525
+ if (shouldProcessRoot(node))
8526
+ ans.push(callback(node));
8527
+ visitLeft();
8528
+ visitRight();
8529
+ break;
8530
+ case "POST":
8531
+ visitLeft();
8532
+ visitRight();
8533
+ if (shouldProcessRoot(node))
8534
+ ans.push(callback(node));
8535
+ break;
8536
+ }
8537
+ };
8538
+ dfs(beginRoot);
8539
+ } else {
8540
+ const stack = [{ opt: 0 /* VISIT */, node: beginRoot }];
8541
+ const pushLeft = (cur) => {
8542
+ var _a;
8543
+ if (shouldVisitLeft(cur.node))
8544
+ stack.push({ opt: 0 /* VISIT */, node: (_a = cur.node) == null ? void 0 : _a.left });
8545
+ };
8546
+ const pushRight = (cur) => {
8547
+ var _a;
8548
+ if (shouldVisitRight(cur.node))
8549
+ stack.push({ opt: 0 /* VISIT */, node: (_a = cur.node) == null ? void 0 : _a.right });
8550
+ };
8551
+ const pushRoot = (cur) => {
8552
+ if (shouldVisitRoot(cur.node))
8553
+ stack.push({ opt: 1 /* PROCESS */, node: cur.node });
8554
+ };
8555
+ while (stack.length > 0) {
8556
+ const cur = stack.pop();
8557
+ if (cur === void 0)
8558
+ continue;
8559
+ if (!shouldVisitRoot(cur.node))
8560
+ continue;
8561
+ if (cur.opt === 1 /* PROCESS */) {
8562
+ if (shouldProcessRoot(cur.node))
8563
+ ans.push(callback(cur.node));
8564
+ } else {
8565
+ switch (pattern) {
8566
+ case "IN":
8567
+ pushRight(cur);
8568
+ pushRoot(cur);
8569
+ pushLeft(cur);
8570
+ break;
8571
+ case "PRE":
8572
+ pushRight(cur);
8573
+ pushLeft(cur);
8574
+ pushRoot(cur);
8575
+ break;
8576
+ case "POST":
8577
+ pushRoot(cur);
8578
+ pushRight(cur);
8579
+ pushLeft(cur);
8580
+ break;
8581
+ }
8582
+ }
8583
+ }
8584
+ }
8585
+ return ans;
8586
+ }
9377
8587
  /**
9378
8588
  * Time Complexity: O(1)
9379
8589
  * Space Complexity: O(1)
@@ -9411,10 +8621,6 @@ var dataStructureTyped = (() => {
9411
8621
  }
9412
8622
  }
9413
8623
  }
9414
- /**
9415
- * Time Complexity: O(n)
9416
- * Space Complexity: O(n)
9417
- */
9418
8624
  /**
9419
8625
  * Time Complexity: O(n)
9420
8626
  * Space Complexity: O(n)
@@ -9472,10 +8678,6 @@ var dataStructureTyped = (() => {
9472
8678
  ];
9473
8679
  }
9474
8680
  }
9475
- /**
9476
- * Time Complexity: O(1)
9477
- * Space Complexity: O(1)
9478
- */
9479
8681
  /**
9480
8682
  * Time Complexity: O(1)
9481
8683
  * Space Complexity: O(1)
@@ -9505,10 +8707,6 @@ var dataStructureTyped = (() => {
9505
8707
  }
9506
8708
  return void 0;
9507
8709
  }
9508
- /**
9509
- * Time Complexity: O(1)
9510
- * Space Complexity: O(1)
9511
- */
9512
8710
  /**
9513
8711
  * Time Complexity: O(1)
9514
8712
  * Space Complexity: O(1)
@@ -9537,10 +8735,6 @@ var dataStructureTyped = (() => {
9537
8735
  }
9538
8736
  return newNode;
9539
8737
  }
9540
- /**
9541
- * Time Complexity: O(1)
9542
- * Space Complexity: O(1)
9543
- */
9544
8738
  /**
9545
8739
  * Time Complexity: O(1)
9546
8740
  * Space Complexity: O(1)
@@ -9556,10 +8750,6 @@ var dataStructureTyped = (() => {
9556
8750
  }
9557
8751
  this._root = v;
9558
8752
  }
9559
- /**
9560
- * Time Complexity: O(1)
9561
- * Space Complexity: O(1)
9562
- */
9563
8753
  /**
9564
8754
  * Time Complexity: O(1)
9565
8755
  * Space Complexity: O(1)
@@ -9722,7 +8912,7 @@ var dataStructureTyped = (() => {
9722
8912
  * @returns The method is returning either the node that was ensured or `undefined` if the node could
9723
8913
  * not be ensured.
9724
8914
  */
9725
- ensureNode(keyOrNodeOrEntryOrRawElement, iterationType = "ITERATIVE") {
8915
+ ensureNode(keyOrNodeOrEntryOrRawElement, iterationType = this.iterationType) {
9726
8916
  var _a;
9727
8917
  return (_a = super.ensureNode(keyOrNodeOrEntryOrRawElement, iterationType)) != null ? _a : void 0;
9728
8918
  }
@@ -9736,6 +8926,9 @@ var dataStructureTyped = (() => {
9736
8926
  isNode(keyOrNodeOrEntryOrRawElement) {
9737
8927
  return keyOrNodeOrEntryOrRawElement instanceof BSTNode;
9738
8928
  }
8929
+ isKey(key) {
8930
+ return isComparable(key, this.comparator !== this._DEFAULT_COMPARATOR);
8931
+ }
9739
8932
  /**
9740
8933
  * Time Complexity: O(log n)
9741
8934
  * Space Complexity: O(1)
@@ -9779,10 +8972,6 @@ var dataStructureTyped = (() => {
9779
8972
  }
9780
8973
  return false;
9781
8974
  }
9782
- /**
9783
- * Time Complexity: O(log n)
9784
- * Space Complexity: O(log n)
9785
- */
9786
8975
  /**
9787
8976
  * Time Complexity: O(k log n)
9788
8977
  * Space Complexity: O(k + log n)
@@ -9909,6 +9098,10 @@ var dataStructureTyped = (() => {
9909
9098
  * @returns The method `getNodes` returns an array of `NODE` objects.
9910
9099
  */
9911
9100
  getNodes(identifier, callback = this._DEFAULT_CALLBACK, onlyOne = false, beginRoot = this.root, iterationType = this.iterationType) {
9101
+ if (identifier === void 0)
9102
+ return [];
9103
+ if (identifier === null)
9104
+ return [];
9912
9105
  beginRoot = this.ensureNode(beginRoot);
9913
9106
  if (!beginRoot)
9914
9107
  return [];
@@ -9958,10 +9151,6 @@ var dataStructureTyped = (() => {
9958
9151
  }
9959
9152
  return ans;
9960
9153
  }
9961
- /**
9962
- * Time Complexity: O(log n)
9963
- * Space Complexity: O(1)
9964
- */
9965
9154
  /**
9966
9155
  * Time Complexity: O(log n)
9967
9156
  * Space Complexity: O(1)
@@ -9987,10 +9176,6 @@ var dataStructureTyped = (() => {
9987
9176
  var _a;
9988
9177
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) != null ? _a : void 0;
9989
9178
  }
9990
- /**
9991
- * Time Complexity: O(k log n)
9992
- * Space Complexity: O(k + log n)
9993
- */
9994
9179
  /**
9995
9180
  * Time Complexity: O(log n)
9996
9181
  * Space Complexity: O(1)
@@ -10004,13 +9189,9 @@ var dataStructureTyped = (() => {
10004
9189
  * It has a default value of `'ITERATIVE'`.
10005
9190
  * @returns The method is returning a NODE object or undefined.
10006
9191
  */
10007
- getNodeByKey(key, iterationType = "ITERATIVE") {
9192
+ getNodeByKey(key, iterationType = this.iterationType) {
10008
9193
  return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
10009
9194
  }
10010
- /**
10011
- * Time Complexity: O(log n)
10012
- * Space Complexity: O(k + log n)
10013
- */
10014
9195
  /**
10015
9196
  * Time complexity: O(n)
10016
9197
  * Space complexity: O(n)
@@ -10031,13 +9212,9 @@ var dataStructureTyped = (() => {
10031
9212
  * following values:
10032
9213
  * @returns The method is returning an array of the return type of the callback function.
10033
9214
  */
10034
- dfs(callback = this._DEFAULT_CALLBACK, pattern = "IN", beginRoot = this.root, iterationType = "ITERATIVE") {
10035
- return super.dfs(callback, pattern, beginRoot, iterationType, false);
10036
- }
10037
- /**
10038
- * Time Complexity: O(log n)
10039
- * Space Complexity: O(1)
10040
- */
9215
+ dfs(callback = this._DEFAULT_CALLBACK, pattern = "IN", beginRoot = this.root, iterationType = this.iterationType) {
9216
+ return super.dfs(callback, pattern, beginRoot, iterationType);
9217
+ }
10041
9218
  /**
10042
9219
  * Time complexity: O(n)
10043
9220
  * Space complexity: O(n)
@@ -10058,10 +9235,6 @@ var dataStructureTyped = (() => {
10058
9235
  bfs(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
10059
9236
  return super.bfs(callback, beginRoot, iterationType, false);
10060
9237
  }
10061
- /**
10062
- * Time Complexity: O(log n)
10063
- * Space Complexity: O(1)
10064
- */
10065
9238
  /**
10066
9239
  * Time complexity: O(n)
10067
9240
  * Space complexity: O(n)
@@ -10083,10 +9256,6 @@ var dataStructureTyped = (() => {
10083
9256
  listLevels(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
10084
9257
  return super.listLevels(callback, beginRoot, iterationType, false);
10085
9258
  }
10086
- /**
10087
- * Time complexity: O(n)
10088
- * Space complexity: O(n)
10089
- */
10090
9259
  /**
10091
9260
  * Time complexity: O(n)
10092
9261
  * Space complexity: O(n)
@@ -10145,10 +9314,6 @@ var dataStructureTyped = (() => {
10145
9314
  return ans;
10146
9315
  }
10147
9316
  }
10148
- /**
10149
- * Time complexity: O(n)
10150
- * Space complexity: O(n)
10151
- */
10152
9317
  /**
10153
9318
  * Time complexity: O(n)
10154
9319
  * Space complexity: O(n)
@@ -10196,10 +9361,6 @@ var dataStructureTyped = (() => {
10196
9361
  return true;
10197
9362
  }
10198
9363
  }
10199
- /**
10200
- * Time complexity: O(n)
10201
- * Space complexity: O(n)
10202
- */
10203
9364
  /**
10204
9365
  * Time Complexity: O(n)
10205
9366
  * Space Complexity: O(log n)
@@ -10255,10 +9416,6 @@ var dataStructureTyped = (() => {
10255
9416
  }
10256
9417
  return balanced;
10257
9418
  }
10258
- /**
10259
- * Time Complexity: O(n)
10260
- * Space Complexity: O(log n)
10261
- */
10262
9419
  /**
10263
9420
  * The function returns the value of the _comparator property.
10264
9421
  * @returns The `_comparator` property is being returned.
@@ -10927,11 +10084,6 @@ var dataStructureTyped = (() => {
10927
10084
  isNode(keyOrNodeOrEntryOrRawElement) {
10928
10085
  return keyOrNodeOrEntryOrRawElement instanceof AVLTreeNode;
10929
10086
  }
10930
- /**
10931
- * Time Complexity: O(log n)
10932
- * Space Complexity: O(1)
10933
- * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
10934
- */
10935
10087
  /**
10936
10088
  * Time Complexity: O(log n)
10937
10089
  * Space Complexity: O(1)
@@ -10953,10 +10105,6 @@ var dataStructureTyped = (() => {
10953
10105
  this._balancePath(keyOrNodeOrEntryOrRawElement);
10954
10106
  return inserted;
10955
10107
  }
10956
- /**
10957
- * Time Complexity: O(log n)
10958
- * Space Complexity: O(1)
10959
- */
10960
10108
  /**
10961
10109
  * Time Complexity: O(log n)
10962
10110
  * Space Complexity: O(1)
@@ -10979,10 +10127,6 @@ var dataStructureTyped = (() => {
10979
10127
  }
10980
10128
  return deletedResults;
10981
10129
  }
10982
- /**
10983
- * Time Complexity: O(1)
10984
- * Space Complexity: O(1)
10985
- */
10986
10130
  /**
10987
10131
  * Time Complexity: O(1)
10988
10132
  * Space Complexity: O(1)
@@ -11015,10 +10159,6 @@ var dataStructureTyped = (() => {
11015
10159
  }
11016
10160
  return void 0;
11017
10161
  }
11018
- /**
11019
- * Time Complexity: O(1)
11020
- * Space Complexity: O(1)
11021
- */
11022
10162
  /**
11023
10163
  * Time Complexity: O(1)
11024
10164
  * Space Complexity: O(1)
@@ -11037,10 +10177,6 @@ var dataStructureTyped = (() => {
11037
10177
  else
11038
10178
  return node.right.height - node.left.height;
11039
10179
  }
11040
- /**
11041
- * Time Complexity: O(1)
11042
- * Space Complexity: O(1)
11043
- */
11044
10180
  /**
11045
10181
  * Time Complexity: O(1)
11046
10182
  * Space Complexity: O(1)
@@ -11060,10 +10196,6 @@ var dataStructureTyped = (() => {
11060
10196
  else
11061
10197
  node.height = 1 + Math.max(node.right.height, node.left.height);
11062
10198
  }
11063
- /**
11064
- * Time Complexity: O(1)
11065
- * Space Complexity: O(1)
11066
- */
11067
10199
  /**
11068
10200
  * Time Complexity: O(1)
11069
10201
  * Space Complexity: O(1)
@@ -11099,10 +10231,6 @@ var dataStructureTyped = (() => {
11099
10231
  if (B)
11100
10232
  this._updateHeight(B);
11101
10233
  }
11102
- /**
11103
- * Time Complexity: O(1)
11104
- * Space Complexity: O(1)
11105
- */
11106
10234
  /**
11107
10235
  * Time Complexity: O(1)
11108
10236
  * Space Complexity: O(1)
@@ -11153,10 +10281,6 @@ var dataStructureTyped = (() => {
11153
10281
  B && this._updateHeight(B);
11154
10282
  C && this._updateHeight(C);
11155
10283
  }
11156
- /**
11157
- * Time Complexity: O(1)
11158
- * Space Complexity: O(1)
11159
- */
11160
10284
  /**
11161
10285
  * Time Complexity: O(1)
11162
10286
  * Space Complexity: O(1)
@@ -11193,10 +10317,6 @@ var dataStructureTyped = (() => {
11193
10317
  this._updateHeight(A);
11194
10318
  B && this._updateHeight(B);
11195
10319
  }
11196
- /**
11197
- * Time Complexity: O(1)
11198
- * Space Complexity: O(1)
11199
- */
11200
10320
  /**
11201
10321
  * Time Complexity: O(1)
11202
10322
  * Space Complexity: O(1)
@@ -11247,11 +10367,6 @@ var dataStructureTyped = (() => {
11247
10367
  B && this._updateHeight(B);
11248
10368
  C && this._updateHeight(C);
11249
10369
  }
11250
- /**
11251
- * Time Complexity: O(log n)
11252
- * Space Complexity: O(1)
11253
- * logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root. constant space, as it doesn't use additional data structures that scale with input size.
11254
- */
11255
10370
  /**
11256
10371
  * Time Complexity: O(log n)
11257
10372
  * Space Complexity: O(1)
@@ -11288,10 +10403,6 @@ var dataStructureTyped = (() => {
11288
10403
  }
11289
10404
  }
11290
10405
  }
11291
- /**
11292
- * Time Complexity: O(1)
11293
- * Space Complexity: O(1)
11294
- */
11295
10406
  /**
11296
10407
  * Time Complexity: O(1)
11297
10408
  * Space Complexity: O(1)
@@ -11398,10 +10509,6 @@ var dataStructureTyped = (() => {
11398
10509
  iterationType: this.iterationType
11399
10510
  }, options));
11400
10511
  }
11401
- /**
11402
- * Time Complexity: O(1)
11403
- * Space Complexity: O(1)
11404
- */
11405
10512
  /**
11406
10513
  * Time Complexity: O(1)
11407
10514
  * Space Complexity: O(1)
@@ -11437,7 +10544,7 @@ var dataStructureTyped = (() => {
11437
10544
  //
11438
10545
  // if (this.toEntryFn) {
11439
10546
  // const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement as R);
11440
- // if (key) return this.createNode(key, entryValue ?? value, 'RED');
10547
+ // if (this.isKey(key)) return this.createNode(key, entryValue ?? value, 'RED');
11441
10548
  // }
11442
10549
  //
11443
10550
  // if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
@@ -11450,10 +10557,6 @@ var dataStructureTyped = (() => {
11450
10557
  //
11451
10558
  // return ;
11452
10559
  // }
11453
- /**
11454
- * Time Complexity: O(1)
11455
- * Space Complexity: O(1)
11456
- */
11457
10560
  /**
11458
10561
  * Time Complexity: O(1)
11459
10562
  * Space Complexity: O(1)
@@ -11465,10 +10568,6 @@ var dataStructureTyped = (() => {
11465
10568
  super.clear();
11466
10569
  this._root = this.NIL;
11467
10570
  }
11468
- /**
11469
- * Time Complexity: O(log n)
11470
- * Space Complexity: O(1)
11471
- */
11472
10571
  /**
11473
10572
  * Time Complexity: O(log n)
11474
10573
  * Space Complexity: O(1)
@@ -11500,10 +10599,6 @@ var dataStructureTyped = (() => {
11500
10599
  } else
11501
10600
  return insertStatus === "UPDATED";
11502
10601
  }
11503
- /**
11504
- * Time Complexity: O(log n)
11505
- * Space Complexity: O(1)
11506
- */
11507
10602
  /**
11508
10603
  * Time Complexity: O(log n)
11509
10604
  * Space Complexity: O(1)
@@ -11538,7 +10633,7 @@ var dataStructureTyped = (() => {
11538
10633
  replacementNode = nodeToDelete.left;
11539
10634
  this._transplant(nodeToDelete, nodeToDelete.left);
11540
10635
  } else {
11541
- const successor = this.getLeftMost(nodeToDelete.right);
10636
+ const successor = this.getLeftMost((node) => node, nodeToDelete.right);
11542
10637
  if (successor) {
11543
10638
  originalColor = successor.color;
11544
10639
  replacementNode = successor.right;
@@ -11568,10 +10663,6 @@ var dataStructureTyped = (() => {
11568
10663
  results.push({ deleted: nodeToDelete, needBalanced: void 0 });
11569
10664
  return results;
11570
10665
  }
11571
- /**
11572
- * Time Complexity: O(1)
11573
- * Space Complexity: O(1)
11574
- */
11575
10666
  /**
11576
10667
  * Time Complexity: O(1)
11577
10668
  * Space Complexity: O(1)
@@ -11586,10 +10677,6 @@ var dataStructureTyped = (() => {
11586
10677
  }
11587
10678
  this._root = v;
11588
10679
  }
11589
- /**
11590
- * Time Complexity: O(1)
11591
- * Space Complexity: O(1)
11592
- */
11593
10680
  /**
11594
10681
  * Time Complexity: O(1)
11595
10682
  * Space Complexity: O(1)
@@ -11606,10 +10693,6 @@ var dataStructureTyped = (() => {
11606
10693
  newNode.color = oldNode.color;
11607
10694
  return super._replaceNode(oldNode, newNode);
11608
10695
  }
11609
- /**
11610
- * Time Complexity: O(log n)
11611
- * Space Complexity: O(1)
11612
- */
11613
10696
  /**
11614
10697
  * Time Complexity: O(log n)
11615
10698
  * Space Complexity: O(1)
@@ -11652,10 +10735,6 @@ var dataStructureTyped = (() => {
11652
10735
  this._insertFixup(node);
11653
10736
  return "CREATED";
11654
10737
  }
11655
- /**
11656
- * Time Complexity: O(1)
11657
- * Space Complexity: O(1)
11658
- */
11659
10738
  /**
11660
10739
  * Time Complexity: O(1)
11661
10740
  * Space Complexity: O(1)
@@ -11677,10 +10756,6 @@ var dataStructureTyped = (() => {
11677
10756
  v.parent = u.parent;
11678
10757
  }
11679
10758
  }
11680
- /**
11681
- * Time Complexity: O(log n)
11682
- * Space Complexity: O(1)
11683
- */
11684
10759
  /**
11685
10760
  * Time Complexity: O(log n)
11686
10761
  * Space Complexity: O(1)
@@ -11733,10 +10808,6 @@ var dataStructureTyped = (() => {
11733
10808
  if (this.isRealNode(this._root))
11734
10809
  this._root.color = "BLACK";
11735
10810
  }
11736
- /**
11737
- * Time Complexity: O(log n)
11738
- * Space Complexity: O(1)
11739
- */
11740
10811
  /**
11741
10812
  * Time Complexity: O(log n)
11742
10813
  * Space Complexity: O(1)
@@ -11812,10 +10883,6 @@ var dataStructureTyped = (() => {
11812
10883
  node.color = "BLACK";
11813
10884
  }
11814
10885
  }
11815
- /**
11816
- * Time Complexity: O(1)
11817
- * Space Complexity: O(1)
11818
- */
11819
10886
  /**
11820
10887
  * Time Complexity: O(1)
11821
10888
  * Space Complexity: O(1)
@@ -11845,10 +10912,6 @@ var dataStructureTyped = (() => {
11845
10912
  y.left = x;
11846
10913
  x.parent = y;
11847
10914
  }
11848
- /**
11849
- * Time Complexity: O(1)
11850
- * Space Complexity: O(1)
11851
- */
11852
10915
  /**
11853
10916
  * Time Complexity: O(1)
11854
10917
  * Space Complexity: O(1)
@@ -11936,10 +10999,6 @@ var dataStructureTyped = (() => {
11936
10999
  get count() {
11937
11000
  return this._count;
11938
11001
  }
11939
- /**
11940
- * Time Complexity: O(n)
11941
- * Space Complexity: O(1)
11942
- */
11943
11002
  /**
11944
11003
  * Time Complexity: O(n)
11945
11004
  * Space Complexity: O(1)
@@ -12007,26 +11066,22 @@ var dataStructureTyped = (() => {
12007
11066
  return;
12008
11067
  if (this.isNode(keyOrNodeOrEntryOrRawElement))
12009
11068
  return keyOrNodeOrEntryOrRawElement;
12010
- if (this.toEntryFn) {
12011
- const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
12012
- if (key)
12013
- return this.createNode(key, entryValue != null ? entryValue : value, count);
12014
- }
12015
11069
  if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
12016
- const [key, value2] = keyOrNodeOrEntryOrRawElement;
11070
+ const [key, entryValue] = keyOrNodeOrEntryOrRawElement;
12017
11071
  if (key === void 0 || key === null)
12018
11072
  return;
12019
- else
12020
- return this.createNode(key, value2, count);
11073
+ if (this.isKey(key))
11074
+ return this.createNode(key, value != null ? value : entryValue, count);
11075
+ }
11076
+ if (this.toEntryFn) {
11077
+ const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
11078
+ if (this.isKey(key))
11079
+ return this.createNode(key, value != null ? value : entryValue, count);
12021
11080
  }
12022
11081
  if (this.isKey(keyOrNodeOrEntryOrRawElement))
12023
11082
  return this.createNode(keyOrNodeOrEntryOrRawElement, value, count);
12024
11083
  return;
12025
11084
  }
12026
- /**
12027
- * Time Complexity: O(log n)
12028
- * Space Complexity: O(1)
12029
- */
12030
11085
  /**
12031
11086
  * Time Complexity: O(log n)
12032
11087
  * Space Complexity: O(1)
@@ -12055,10 +11110,6 @@ var dataStructureTyped = (() => {
12055
11110
  }
12056
11111
  return true;
12057
11112
  }
12058
- /**
12059
- * Time Complexity: O(log n)
12060
- * Space Complexity: O(1)
12061
- */
12062
11113
  /**
12063
11114
  * Time Complexity: O(log n)
12064
11115
  * Space Complexity: O(1)
@@ -12107,7 +11158,7 @@ var dataStructureTyped = (() => {
12107
11158
  needBalanced = parent;
12108
11159
  }
12109
11160
  } else {
12110
- const leftSubTreeRightMost = curr.left ? this.getRightMost(curr.left) : void 0;
11161
+ const leftSubTreeRightMost = curr.left ? this.getRightMost((node) => node, curr.left) : void 0;
12111
11162
  if (leftSubTreeRightMost) {
12112
11163
  const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
12113
11164
  orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
@@ -12131,10 +11182,6 @@ var dataStructureTyped = (() => {
12131
11182
  }
12132
11183
  return deletedResult;
12133
11184
  }
12134
- /**
12135
- * Time Complexity: O(1)
12136
- * Space Complexity: O(1)
12137
- */
12138
11185
  /**
12139
11186
  * Time Complexity: O(1)
12140
11187
  * Space Complexity: O(1)
@@ -12146,10 +11193,6 @@ var dataStructureTyped = (() => {
12146
11193
  super.clear();
12147
11194
  this._count = 0;
12148
11195
  }
12149
- /**
12150
- * Time Complexity: O(n log n)
12151
- * Space Complexity: O(log n)
12152
- */
12153
11196
  /**
12154
11197
  * Time Complexity: O(n log n)
12155
11198
  * Space Complexity: O(log n)
@@ -12197,10 +11240,6 @@ var dataStructureTyped = (() => {
12197
11240
  return true;
12198
11241
  }
12199
11242
  }
12200
- /**
12201
- * Time complexity: O(n)
12202
- * Space complexity: O(n)
12203
- */
12204
11243
  /**
12205
11244
  * Time complexity: O(n)
12206
11245
  * Space complexity: O(n)
@@ -12213,10 +11252,6 @@ var dataStructureTyped = (() => {
12213
11252
  this.bfs((node) => cloned.add(node.key, node.value, node.count));
12214
11253
  return cloned;
12215
11254
  }
12216
- /**
12217
- * Time Complexity: O(1)
12218
- * Space Complexity: O(1)
12219
- */
12220
11255
  /**
12221
11256
  * Time Complexity: O(1)
12222
11257
  * Space Complexity: O(1)
@@ -12251,10 +11286,6 @@ var dataStructureTyped = (() => {
12251
11286
  }
12252
11287
  return void 0;
12253
11288
  }
12254
- /**
12255
- * Time Complexity: O(1)
12256
- * Space Complexity: O(1)
12257
- */
12258
11289
  /**
12259
11290
  * Time Complexity: O(1)
12260
11291
  * Space Complexity: O(1)
@@ -12331,10 +11362,6 @@ var dataStructureTyped = (() => {
12331
11362
  get count() {
12332
11363
  return this._count;
12333
11364
  }
12334
- /**
12335
- * Time Complexity: O(n)
12336
- * Space Complexity: O(1)
12337
- */
12338
11365
  /**
12339
11366
  * Time Complexity: O(n)
12340
11367
  * Space Complexity: O(1)
@@ -12394,17 +11421,17 @@ var dataStructureTyped = (() => {
12394
11421
  return;
12395
11422
  if (this.isNode(keyOrNodeOrEntryOrRawElement))
12396
11423
  return keyOrNodeOrEntryOrRawElement;
12397
- if (this.toEntryFn) {
12398
- const [key] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
12399
- if (key)
12400
- return this.getNodeByKey(key);
12401
- }
12402
11424
  if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
12403
- const [key, value2] = keyOrNodeOrEntryOrRawElement;
11425
+ const [key, entryValue] = keyOrNodeOrEntryOrRawElement;
12404
11426
  if (key === void 0 || key === null)
12405
11427
  return;
12406
- else
12407
- return this.createNode(key, value2, "BLACK", count);
11428
+ if (this.isKey(key))
11429
+ return this.createNode(key, value != null ? value : entryValue, "BLACK", count);
11430
+ }
11431
+ if (this.toEntryFn) {
11432
+ const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
11433
+ if (this.isKey(key))
11434
+ return this.createNode(key, value != null ? value : entryValue, "BLACK", count);
12408
11435
  }
12409
11436
  if (this.isKey(keyOrNodeOrEntryOrRawElement))
12410
11437
  return this.createNode(keyOrNodeOrEntryOrRawElement, value, "BLACK", count);
@@ -12420,10 +11447,6 @@ var dataStructureTyped = (() => {
12420
11447
  isNode(keyOrNodeOrEntryOrRawElement) {
12421
11448
  return keyOrNodeOrEntryOrRawElement instanceof TreeMultiMapNode;
12422
11449
  }
12423
- /**
12424
- * Time Complexity: O(log n)
12425
- * Space Complexity: O(1)
12426
- */
12427
11450
  /**
12428
11451
  * Time Complexity: O(log n)
12429
11452
  * Space Complexity: O(1)
@@ -12451,10 +11474,6 @@ var dataStructureTyped = (() => {
12451
11474
  return false;
12452
11475
  }
12453
11476
  }
12454
- /**
12455
- * Time Complexity: O(log n)
12456
- * Space Complexity: O(1)
12457
- */
12458
11477
  /**
12459
11478
  * Time Complexity: O(log n)
12460
11479
  * Space Complexity: O(1)
@@ -12507,7 +11526,7 @@ var dataStructureTyped = (() => {
12507
11526
  return results;
12508
11527
  }
12509
11528
  } else {
12510
- const successor = this.getLeftMost(nodeToDelete.right);
11529
+ const successor = this.getLeftMost((node) => node, nodeToDelete.right);
12511
11530
  if (successor) {
12512
11531
  originalColor = successor.color;
12513
11532
  replacementNode = successor.right;
@@ -12553,10 +11572,6 @@ var dataStructureTyped = (() => {
12553
11572
  results.push({ deleted: nodeToDelete, needBalanced: void 0 });
12554
11573
  return results;
12555
11574
  }
12556
- /**
12557
- * Time Complexity: O(1)
12558
- * Space Complexity: O(1)
12559
- */
12560
11575
  /**
12561
11576
  * Time Complexity: O(1)
12562
11577
  * Space Complexity: O(1)
@@ -12568,10 +11583,6 @@ var dataStructureTyped = (() => {
12568
11583
  super.clear();
12569
11584
  this._count = 0;
12570
11585
  }
12571
- /**
12572
- * Time Complexity: O(n log n)
12573
- * Space Complexity: O(log n)
12574
- */
12575
11586
  /**
12576
11587
  * Time Complexity: O(n log n)
12577
11588
  * Space Complexity: O(log n)
@@ -12620,10 +11631,6 @@ var dataStructureTyped = (() => {
12620
11631
  return true;
12621
11632
  }
12622
11633
  }
12623
- /**
12624
- * Time complexity: O(n)
12625
- * Space complexity: O(n)
12626
- */
12627
11634
  /**
12628
11635
  * Time complexity: O(n)
12629
11636
  * Space complexity: O(n)
@@ -12636,10 +11643,6 @@ var dataStructureTyped = (() => {
12636
11643
  this.bfs((node) => cloned.add(node.key, node.value, node.count));
12637
11644
  return cloned;
12638
11645
  }
12639
- /**
12640
- * Time Complexity: O(1)
12641
- * Space Complexity: O(1)
12642
- */
12643
11646
  /**
12644
11647
  * Time Complexity: O(1)
12645
11648
  * Space Complexity: O(1)
@@ -12675,10 +11678,6 @@ var dataStructureTyped = (() => {
12675
11678
  }
12676
11679
  return void 0;
12677
11680
  }
12678
- /**
12679
- * Time Complexity: O(1)
12680
- * Space Complexity: O(1)
12681
- */
12682
11681
  /**
12683
11682
  * Time Complexity: O(1)
12684
11683
  * Space Complexity: O(1)
@@ -13616,10 +12615,6 @@ var dataStructureTyped = (() => {
13616
12615
  get root() {
13617
12616
  return this._root;
13618
12617
  }
13619
- /**
13620
- * Time Complexity: O(l), where l is the length of the word being added.
13621
- * Space Complexity: O(l) - Each character in the word adds a TrieNode.
13622
- */
13623
12618
  /**
13624
12619
  * Time Complexity: O(l), where l is the length of the word being added.
13625
12620
  * Space Complexity: O(l) - Each character in the word adds a TrieNode.
@@ -13647,10 +12642,6 @@ var dataStructureTyped = (() => {
13647
12642
  }
13648
12643
  return isNewWord;
13649
12644
  }
13650
- /**
13651
- * Time Complexity: O(l), where l is the length of the input word.
13652
- * Space Complexity: O(1) - Constant space.
13653
- */
13654
12645
  /**
13655
12646
  * Time Complexity: O(l), where l is the length of the input word.
13656
12647
  * Space Complexity: O(1) - Constant space.
@@ -13670,10 +12661,6 @@ var dataStructureTyped = (() => {
13670
12661
  }
13671
12662
  return cur.isEnd;
13672
12663
  }
13673
- /**
13674
- * Time Complexity: O(1)
13675
- * Space Complexity: O(1)
13676
- */
13677
12664
  /**
13678
12665
  * Time Complexity: O(1)
13679
12666
  * Space Complexity: O(1)
@@ -13684,10 +12671,6 @@ var dataStructureTyped = (() => {
13684
12671
  isEmpty() {
13685
12672
  return this.size === 0;
13686
12673
  }
13687
- /**
13688
- * Time Complexity: O(1)
13689
- * Space Complexity: O(1)
13690
- */
13691
12674
  /**
13692
12675
  * Time Complexity: O(1)
13693
12676
  * Space Complexity: O(1)
@@ -13698,10 +12681,6 @@ var dataStructureTyped = (() => {
13698
12681
  this._size = 0;
13699
12682
  this._root = new TrieNode("");
13700
12683
  }
13701
- /**
13702
- * Time Complexity: O(l), where l is the length of the word being deleted.
13703
- * Space Complexity: O(n) - Due to the recursive DFS approach.
13704
- */
13705
12684
  /**
13706
12685
  * Time Complexity: O(l), where l is the length of the word being deleted.
13707
12686
  * Space Complexity: O(n) - Due to the recursive DFS approach.
@@ -13744,10 +12723,6 @@ var dataStructureTyped = (() => {
13744
12723
  }
13745
12724
  return isDeleted;
13746
12725
  }
13747
- /**
13748
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
13749
- * Space Complexity: O(1) - Constant space.
13750
- */
13751
12726
  /**
13752
12727
  * Time Complexity: O(n), where n is the total number of nodes in the trie.
13753
12728
  * Space Complexity: O(1) - Constant space.
@@ -13772,10 +12747,6 @@ var dataStructureTyped = (() => {
13772
12747
  }
13773
12748
  return maxDepth;
13774
12749
  }
13775
- /**
13776
- * Time Complexity: O(l), where l is the length of the input prefix.
13777
- * Space Complexity: O(1) - Constant space.
13778
- */
13779
12750
  /**
13780
12751
  * Time Complexity: O(l), where l is the length of the input prefix.
13781
12752
  * Space Complexity: O(1) - Constant space.
@@ -13795,10 +12766,6 @@ var dataStructureTyped = (() => {
13795
12766
  }
13796
12767
  return !cur.isEnd;
13797
12768
  }
13798
- /**
13799
- * Time Complexity: O(l), where l is the length of the input prefix.
13800
- * Space Complexity: O(1) - Constant space.
13801
- */
13802
12769
  /**
13803
12770
  * Time Complexity: O(l), where l is the length of the input prefix.
13804
12771
  * Space Complexity: O(1) - Constant space.
@@ -13818,10 +12785,6 @@ var dataStructureTyped = (() => {
13818
12785
  }
13819
12786
  return true;
13820
12787
  }
13821
- /**
13822
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
13823
- * Space Complexity: O(l), where l is the length of the input prefix.
13824
- */
13825
12788
  /**
13826
12789
  * Time Complexity: O(n), where n is the total number of nodes in the trie.
13827
12790
  * Space Complexity: O(l), where l is the length of the input prefix.
@@ -13847,10 +12810,6 @@ var dataStructureTyped = (() => {
13847
12810
  dfs(this.root);
13848
12811
  return commonPre === input;
13849
12812
  }
13850
- /**
13851
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
13852
- * Space Complexity: O(l), where l is the length of the longest common prefix.
13853
- */
13854
12813
  /**
13855
12814
  * Time Complexity: O(n), where n is the total number of nodes in the trie.
13856
12815
  * Space Complexity: O(l), where l is the length of the longest common prefix.
@@ -13872,10 +12831,6 @@ var dataStructureTyped = (() => {
13872
12831
  dfs(this.root);
13873
12832
  return commonPre;
13874
12833
  }
13875
- /**
13876
- * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
13877
- * Space Complexity: O(w * l) - The space required for the output array.
13878
- */
13879
12834
  /**
13880
12835
  * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
13881
12836
  * Space Complexity: O(w * l) - The space required for the output array.
@@ -13920,10 +12875,6 @@ var dataStructureTyped = (() => {
13920
12875
  dfs(startNode, prefix);
13921
12876
  return words;
13922
12877
  }
13923
- /**
13924
- * Time Complexity: O(n)
13925
- * Space Complexity: O(n)
13926
- */
13927
12878
  /**
13928
12879
  * Time Complexity: O(n)
13929
12880
  * Space Complexity: O(n)
@@ -13935,10 +12886,6 @@ var dataStructureTyped = (() => {
13935
12886
  clone() {
13936
12887
  return new _Trie(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
13937
12888
  }
13938
- /**
13939
- * Time Complexity: O(n)
13940
- * Space Complexity: O(n)
13941
- */
13942
12889
  /**
13943
12890
  * Time Complexity: O(n)
13944
12891
  * Space Complexity: O(n)
@@ -13964,10 +12911,6 @@ var dataStructureTyped = (() => {
13964
12911
  }
13965
12912
  return results;
13966
12913
  }
13967
- /**
13968
- * Time Complexity: O(n)
13969
- * Space Complexity: O(n)
13970
- */
13971
12914
  /**
13972
12915
  * Time Complexity: O(n)
13973
12916
  * Space Complexity: O(n)
@@ -13995,10 +12938,6 @@ var dataStructureTyped = (() => {
13995
12938
  }
13996
12939
  return newTrie;
13997
12940
  }
13998
- /**
13999
- * Time Complexity: O(n)
14000
- * Space Complexity: O(n)
14001
- */
14002
12941
  /**
14003
12942
  * Time Complexity: O(n)
14004
12943
  * Space Complexity: O(n)
@@ -14017,10 +12956,6 @@ var dataStructureTyped = (() => {
14017
12956
  }
14018
12957
  yield* __yieldStar(_dfs(this.root, ""));
14019
12958
  }
14020
- /**
14021
- * Time Complexity: O(l), where l is the length of the input string.
14022
- * Space Complexity: O(1) - Constant space.
14023
- */
14024
12959
  /**
14025
12960
  * Time Complexity: O(l), where l is the length of the input string.
14026
12961
  * Space Complexity: O(1) - Constant space.
@@ -14054,7 +12989,8 @@ var dataStructureTyped = (() => {
14054
12989
  __publicField(this, "_children");
14055
12990
  this._key = key;
14056
12991
  this._value = value || void 0;
14057
- this._children = children || [];
12992
+ if (children)
12993
+ this._children = children;
14058
12994
  }
14059
12995
  /**
14060
12996
  * The function returns the value of the protected variable _key.