data-structure-typed 1.49.0 → 1.49.1

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 (163) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +10 -12
  3. package/dist/cjs/data-structures/binary-tree/avl-tree.js +3 -4
  4. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +58 -58
  6. package/dist/cjs/data-structures/binary-tree/binary-tree.js +6 -6
  7. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/bst.d.ts +15 -15
  9. package/dist/cjs/data-structures/binary-tree/bst.js +3 -3
  10. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +11 -11
  12. package/dist/cjs/data-structures/binary-tree/rb-tree.js +5 -6
  13. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +14 -14
  15. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +3 -3
  16. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  17. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +9 -3
  18. package/dist/cjs/data-structures/graph/abstract-graph.js +27 -31
  19. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  20. package/dist/cjs/data-structures/graph/directed-graph.d.ts +8 -1
  21. package/dist/cjs/data-structures/graph/directed-graph.js +1 -8
  22. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/map-graph.d.ts +1 -1
  24. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +8 -1
  25. package/dist/cjs/data-structures/graph/undirected-graph.js +1 -8
  26. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  27. package/dist/cjs/data-structures/hash/hash-map.d.ts +14 -2
  28. package/dist/cjs/data-structures/hash/hash-map.js +19 -8
  29. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  30. package/dist/cjs/data-structures/hash/hash-table.d.ts +2 -2
  31. package/dist/cjs/data-structures/hash/hash-table.js.map +1 -1
  32. package/dist/cjs/data-structures/heap/heap.d.ts +14 -3
  33. package/dist/cjs/data-structures/heap/heap.js +12 -0
  34. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  35. package/dist/cjs/data-structures/heap/max-heap.d.ts +11 -1
  36. package/dist/cjs/data-structures/heap/max-heap.js +10 -7
  37. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  38. package/dist/cjs/data-structures/heap/min-heap.d.ts +11 -1
  39. package/dist/cjs/data-structures/heap/min-heap.js +10 -7
  40. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  41. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +8 -2
  42. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +6 -7
  43. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  44. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  45. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +0 -7
  46. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  47. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +1 -1
  48. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -7
  49. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  50. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +1 -1
  51. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -7
  52. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  53. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +9 -1
  54. package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -7
  55. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  56. package/dist/cjs/data-structures/queue/deque.d.ts +6 -5
  57. package/dist/cjs/data-structures/queue/deque.js +6 -12
  58. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  59. package/dist/cjs/data-structures/queue/queue.d.ts +18 -3
  60. package/dist/cjs/data-structures/queue/queue.js +16 -6
  61. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  62. package/dist/cjs/data-structures/stack/stack.d.ts +15 -5
  63. package/dist/cjs/data-structures/stack/stack.js +7 -4
  64. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  65. package/dist/cjs/data-structures/trie/trie.d.ts +13 -3
  66. package/dist/cjs/data-structures/trie/trie.js +11 -8
  67. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  68. package/dist/cjs/interfaces/binary-tree.d.ts +4 -4
  69. package/dist/cjs/types/common.d.ts +32 -8
  70. package/dist/cjs/types/common.js +22 -1
  71. package/dist/cjs/types/common.js.map +1 -1
  72. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -24
  73. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -22
  74. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
  75. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
  76. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +1 -1
  77. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +10 -12
  78. package/dist/mjs/data-structures/binary-tree/avl-tree.js +3 -4
  79. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +58 -58
  80. package/dist/mjs/data-structures/binary-tree/binary-tree.js +6 -6
  81. package/dist/mjs/data-structures/binary-tree/bst.d.ts +15 -15
  82. package/dist/mjs/data-structures/binary-tree/bst.js +3 -3
  83. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +11 -11
  84. package/dist/mjs/data-structures/binary-tree/rb-tree.js +5 -6
  85. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +14 -14
  86. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +3 -3
  87. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +9 -3
  88. package/dist/mjs/data-structures/graph/abstract-graph.js +27 -31
  89. package/dist/mjs/data-structures/graph/directed-graph.d.ts +8 -1
  90. package/dist/mjs/data-structures/graph/directed-graph.js +1 -8
  91. package/dist/mjs/data-structures/graph/map-graph.d.ts +1 -1
  92. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +8 -1
  93. package/dist/mjs/data-structures/graph/undirected-graph.js +1 -8
  94. package/dist/mjs/data-structures/hash/hash-map.d.ts +14 -2
  95. package/dist/mjs/data-structures/hash/hash-map.js +18 -7
  96. package/dist/mjs/data-structures/hash/hash-table.d.ts +2 -2
  97. package/dist/mjs/data-structures/heap/heap.d.ts +14 -3
  98. package/dist/mjs/data-structures/heap/heap.js +13 -1
  99. package/dist/mjs/data-structures/heap/max-heap.d.ts +11 -1
  100. package/dist/mjs/data-structures/heap/max-heap.js +9 -6
  101. package/dist/mjs/data-structures/heap/min-heap.d.ts +11 -1
  102. package/dist/mjs/data-structures/heap/min-heap.js +9 -6
  103. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +8 -2
  104. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +7 -8
  105. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  106. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +0 -7
  107. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +1 -1
  108. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +0 -7
  109. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +1 -1
  110. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +0 -7
  111. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +9 -1
  112. package/dist/mjs/data-structures/priority-queue/priority-queue.js +7 -6
  113. package/dist/mjs/data-structures/queue/deque.d.ts +6 -5
  114. package/dist/mjs/data-structures/queue/deque.js +6 -12
  115. package/dist/mjs/data-structures/queue/queue.d.ts +18 -3
  116. package/dist/mjs/data-structures/queue/queue.js +16 -6
  117. package/dist/mjs/data-structures/stack/stack.d.ts +15 -5
  118. package/dist/mjs/data-structures/stack/stack.js +8 -5
  119. package/dist/mjs/data-structures/trie/trie.d.ts +13 -3
  120. package/dist/mjs/data-structures/trie/trie.js +12 -9
  121. package/dist/mjs/interfaces/binary-tree.d.ts +4 -4
  122. package/dist/mjs/types/common.d.ts +32 -8
  123. package/dist/mjs/types/common.js +21 -0
  124. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -24
  125. package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +1 -21
  126. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
  127. package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +1 -1
  128. package/dist/umd/data-structure-typed.js +179 -172
  129. package/dist/umd/data-structure-typed.min.js +2 -2
  130. package/dist/umd/data-structure-typed.min.js.map +1 -1
  131. package/package.json +1 -1
  132. package/src/data-structures/binary-tree/avl-tree.ts +14 -14
  133. package/src/data-structures/binary-tree/binary-tree.ts +74 -77
  134. package/src/data-structures/binary-tree/bst.ts +18 -17
  135. package/src/data-structures/binary-tree/rb-tree.ts +17 -18
  136. package/src/data-structures/binary-tree/tree-multimap.ts +22 -20
  137. package/src/data-structures/graph/abstract-graph.ts +35 -25
  138. package/src/data-structures/graph/directed-graph.ts +2 -2
  139. package/src/data-structures/graph/map-graph.ts +1 -1
  140. package/src/data-structures/graph/undirected-graph.ts +2 -2
  141. package/src/data-structures/hash/hash-map.ts +20 -3
  142. package/src/data-structures/hash/hash-table.ts +3 -3
  143. package/src/data-structures/heap/heap.ts +14 -3
  144. package/src/data-structures/heap/max-heap.ts +11 -2
  145. package/src/data-structures/heap/min-heap.ts +11 -2
  146. package/src/data-structures/linked-list/doubly-linked-list.ts +9 -3
  147. package/src/data-structures/linked-list/singly-linked-list.ts +3 -3
  148. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  149. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  150. package/src/data-structures/priority-queue/priority-queue.ts +9 -2
  151. package/src/data-structures/queue/deque.ts +7 -9
  152. package/src/data-structures/queue/queue.ts +18 -3
  153. package/src/data-structures/stack/stack.ts +16 -6
  154. package/src/data-structures/trie/trie.ts +13 -4
  155. package/src/interfaces/binary-tree.ts +5 -5
  156. package/src/types/common.ts +37 -12
  157. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -1
  158. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -26
  159. package/src/types/data-structures/binary-tree/bst.ts +0 -1
  160. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -1
  161. package/src/types/data-structures/binary-tree/tree-multimap.ts +1 -1
  162. package/test/unit/data-structures/graph/directed-graph.test.ts +21 -1
  163. package/test/unit/data-structures/graph/undirected-graph.test.ts +39 -1
@@ -444,80 +444,6 @@ var dataStructureTyped = (() => {
444
444
  __publicField(_HashTable, "LOAD_FACTOR", 0.75);
445
445
  var HashTable = _HashTable;
446
446
 
447
- // src/utils/utils.ts
448
- var uuidV4 = function() {
449
- return "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g, function(c) {
450
- const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
451
- return v.toString(16);
452
- });
453
- };
454
- var arrayRemove = function(array, predicate) {
455
- let i = -1, len = array ? array.length : 0;
456
- const result = [];
457
- while (++i < len) {
458
- const value = array[i];
459
- if (predicate(value, i, array)) {
460
- result.push(value);
461
- Array.prototype.splice.call(array, i--, 1);
462
- len--;
463
- }
464
- }
465
- return result;
466
- };
467
- var THUNK_SYMBOL = Symbol("thunk");
468
- var isThunk = (fnOrValue) => {
469
- return typeof fnOrValue === "function" && fnOrValue.__THUNK__ === THUNK_SYMBOL;
470
- };
471
- var toThunk = (fn) => {
472
- const thunk = () => fn();
473
- thunk.__THUNK__ = THUNK_SYMBOL;
474
- return thunk;
475
- };
476
- var trampoline = (fn) => {
477
- const cont = (...args) => toThunk(() => fn(...args));
478
- return Object.assign(
479
- (...args) => {
480
- let result = fn(...args);
481
- while (isThunk(result) && typeof result === "function") {
482
- result = result();
483
- }
484
- return result;
485
- },
486
- { cont }
487
- );
488
- };
489
- var trampolineAsync = (fn) => {
490
- const cont = (...args) => toThunk(() => fn(...args));
491
- return Object.assign(
492
- (...args) => __async(void 0, null, function* () {
493
- let result = yield fn(...args);
494
- while (isThunk(result) && typeof result === "function") {
495
- result = yield result();
496
- }
497
- return result;
498
- }),
499
- { cont }
500
- );
501
- };
502
- var getMSB = (value) => {
503
- if (value <= 0) {
504
- return 0;
505
- }
506
- return 1 << 31 - Math.clz32(value);
507
- };
508
- var rangeCheck = (index, min, max, message = "Index out of bounds.") => {
509
- if (index < min || index > max)
510
- throw new RangeError(message);
511
- };
512
- var throwRangeError = (message = "The value is off-limits.") => {
513
- throw new RangeError(message);
514
- };
515
- var isWeakKey = (input) => {
516
- const inputType = typeof input;
517
- return inputType === "object" && input !== null || inputType === "function";
518
- };
519
- var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
520
-
521
447
  // src/data-structures/base/iterable-base.ts
522
448
  var IterableEntryBase = class {
523
449
  /**
@@ -827,6 +753,80 @@ var dataStructureTyped = (() => {
827
753
  }
828
754
  };
829
755
 
756
+ // src/utils/utils.ts
757
+ var uuidV4 = function() {
758
+ return "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g, function(c) {
759
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
760
+ return v.toString(16);
761
+ });
762
+ };
763
+ var arrayRemove = function(array, predicate) {
764
+ let i = -1, len = array ? array.length : 0;
765
+ const result = [];
766
+ while (++i < len) {
767
+ const value = array[i];
768
+ if (predicate(value, i, array)) {
769
+ result.push(value);
770
+ Array.prototype.splice.call(array, i--, 1);
771
+ len--;
772
+ }
773
+ }
774
+ return result;
775
+ };
776
+ var THUNK_SYMBOL = Symbol("thunk");
777
+ var isThunk = (fnOrValue) => {
778
+ return typeof fnOrValue === "function" && fnOrValue.__THUNK__ === THUNK_SYMBOL;
779
+ };
780
+ var toThunk = (fn) => {
781
+ const thunk = () => fn();
782
+ thunk.__THUNK__ = THUNK_SYMBOL;
783
+ return thunk;
784
+ };
785
+ var trampoline = (fn) => {
786
+ const cont = (...args) => toThunk(() => fn(...args));
787
+ return Object.assign(
788
+ (...args) => {
789
+ let result = fn(...args);
790
+ while (isThunk(result) && typeof result === "function") {
791
+ result = result();
792
+ }
793
+ return result;
794
+ },
795
+ { cont }
796
+ );
797
+ };
798
+ var trampolineAsync = (fn) => {
799
+ const cont = (...args) => toThunk(() => fn(...args));
800
+ return Object.assign(
801
+ (...args) => __async(void 0, null, function* () {
802
+ let result = yield fn(...args);
803
+ while (isThunk(result) && typeof result === "function") {
804
+ result = yield result();
805
+ }
806
+ return result;
807
+ }),
808
+ { cont }
809
+ );
810
+ };
811
+ var getMSB = (value) => {
812
+ if (value <= 0) {
813
+ return 0;
814
+ }
815
+ return 1 << 31 - Math.clz32(value);
816
+ };
817
+ var rangeCheck = (index, min, max, message = "Index out of bounds.") => {
818
+ if (index < min || index > max)
819
+ throw new RangeError(message);
820
+ };
821
+ var throwRangeError = (message = "The value is off-limits.") => {
822
+ throw new RangeError(message);
823
+ };
824
+ var isWeakKey = (input) => {
825
+ const inputType = typeof input;
826
+ return inputType === "object" && input !== null || inputType === "function";
827
+ };
828
+ var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
829
+
830
830
  // src/data-structures/hash/hash-map.ts
831
831
  var HashMap = class _HashMap extends IterableEntryBase {
832
832
  /**
@@ -1171,6 +1171,13 @@ var dataStructureTyped = (() => {
1171
1171
  return hash in this._noObjMap;
1172
1172
  }
1173
1173
  }
1174
+ hasValue(value) {
1175
+ for (const [, elementValue] of this) {
1176
+ if (elementValue === value)
1177
+ return true;
1178
+ }
1179
+ return false;
1180
+ }
1174
1181
  setMany(entries) {
1175
1182
  for (const entry of entries) {
1176
1183
  const [key, value] = entry;
@@ -3157,7 +3164,7 @@ var dataStructureTyped = (() => {
3157
3164
  pop() {
3158
3165
  if (this.isEmpty())
3159
3166
  return void 0;
3160
- return this.elements.pop() || void 0;
3167
+ return this.elements.pop();
3161
3168
  }
3162
3169
  /**
3163
3170
  * Time Complexity: O(n)
@@ -3414,7 +3421,7 @@ var dataStructureTyped = (() => {
3414
3421
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
3415
3422
  */
3416
3423
  enqueue(value) {
3417
- this.push(value);
3424
+ return this.push(value);
3418
3425
  }
3419
3426
  /**
3420
3427
  * Time Complexity: O(n) - same as shift().
@@ -5175,43 +5182,6 @@ var dataStructureTyped = (() => {
5175
5182
  }
5176
5183
  };
5177
5184
 
5178
- // src/data-structures/priority-queue/priority-queue.ts
5179
- var PriorityQueue = class extends Heap {
5180
- constructor(elements, options) {
5181
- super(elements, options);
5182
- }
5183
- };
5184
-
5185
- // src/data-structures/priority-queue/min-priority-queue.ts
5186
- var MinPriorityQueue = class extends PriorityQueue {
5187
- constructor(elements, options = {
5188
- comparator: (a, b) => {
5189
- if (!(typeof a === "number" && typeof b === "number")) {
5190
- throw new Error("The a, b params of compare function must be number");
5191
- } else {
5192
- return a - b;
5193
- }
5194
- }
5195
- }) {
5196
- super(elements, options);
5197
- }
5198
- };
5199
-
5200
- // src/data-structures/priority-queue/max-priority-queue.ts
5201
- var MaxPriorityQueue = class extends PriorityQueue {
5202
- constructor(elements, options = {
5203
- comparator: (a, b) => {
5204
- if (!(typeof a === "number" && typeof b === "number")) {
5205
- throw new Error("The a, b params of compare function must be number");
5206
- } else {
5207
- return b - a;
5208
- }
5209
- }
5210
- }) {
5211
- super(elements, options);
5212
- }
5213
- };
5214
-
5215
5185
  // src/data-structures/graph/abstract-graph.ts
5216
5186
  var AbstractVertex = class {
5217
5187
  /**
@@ -5638,13 +5608,7 @@ var dataStructureTyped = (() => {
5638
5608
  * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
5639
5609
  * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
5640
5610
  */
5641
- dijkstraWithoutHeap(src, dest, getMinDist, genPaths) {
5642
- if (getMinDist === void 0)
5643
- getMinDist = false;
5644
- if (genPaths === void 0)
5645
- genPaths = false;
5646
- if (dest === void 0)
5647
- dest = void 0;
5611
+ dijkstraWithoutHeap(src, dest = void 0, getMinDist = false, genPaths = false) {
5648
5612
  let minDist = Infinity;
5649
5613
  let minDest = void 0;
5650
5614
  let minPath = [];
@@ -5771,14 +5735,8 @@ var dataStructureTyped = (() => {
5771
5735
  * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
5772
5736
  * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
5773
5737
  */
5774
- dijkstra(src, dest, getMinDist, genPaths) {
5738
+ dijkstra(src, dest = void 0, getMinDist = false, genPaths = false) {
5775
5739
  var _a;
5776
- if (getMinDist === void 0)
5777
- getMinDist = false;
5778
- if (genPaths === void 0)
5779
- genPaths = false;
5780
- if (dest === void 0)
5781
- dest = void 0;
5782
5740
  let minDist = Infinity;
5783
5741
  let minDest = void 0;
5784
5742
  let minPath = [];
@@ -5796,7 +5754,7 @@ var dataStructureTyped = (() => {
5796
5754
  if (vertexOrKey instanceof AbstractVertex)
5797
5755
  distMap.set(vertexOrKey, Infinity);
5798
5756
  }
5799
- const heap = new PriorityQueue([], { comparator: (a, b) => a.key - b.key });
5757
+ const heap = new Heap([], { comparator: (a, b) => a.key - b.key });
5800
5758
  heap.add({ key: 0, value: srcVertex });
5801
5759
  distMap.set(srcVertex, 0);
5802
5760
  preMap.set(srcVertex, void 0);
@@ -6152,13 +6110,27 @@ var dataStructureTyped = (() => {
6152
6110
  }
6153
6111
  const cycles = /* @__PURE__ */ new Map();
6154
6112
  if (needCycles) {
6155
- let SCCs2 = /* @__PURE__ */ new Map();
6156
- if (SCCs2.size < 1) {
6157
- SCCs2 = getSCCs();
6158
- }
6159
- SCCs2.forEach((SCC, low) => {
6160
- if (SCC.length > 1) {
6161
- cycles.set(low, SCC);
6113
+ const visitedMap = /* @__PURE__ */ new Map();
6114
+ const stack = [];
6115
+ const findCyclesDFS = (cur, parent) => {
6116
+ visitedMap.set(cur, true);
6117
+ stack.push(cur);
6118
+ const neighbors = this.getNeighbors(cur);
6119
+ for (const neighbor of neighbors) {
6120
+ if (!visitedMap.get(neighbor)) {
6121
+ findCyclesDFS(neighbor, cur);
6122
+ } else if (stack.includes(neighbor) && neighbor !== parent) {
6123
+ const cycleStartIndex = stack.indexOf(neighbor);
6124
+ const cycle = stack.slice(cycleStartIndex);
6125
+ const cycleLow = Math.min(...cycle.map((v) => dfnMap.get(v) || Infinity));
6126
+ cycles.set(cycleLow, cycle);
6127
+ }
6128
+ }
6129
+ stack.pop();
6130
+ };
6131
+ vertexMap.forEach((v) => {
6132
+ if (!visitedMap.get(v)) {
6133
+ findCyclesDFS(v, void 0);
6162
6134
  }
6163
6135
  });
6164
6136
  }
@@ -7285,23 +7257,6 @@ var dataStructureTyped = (() => {
7285
7257
  }
7286
7258
  };
7287
7259
 
7288
- // src/types/data-structures/binary-tree/binary-tree.ts
7289
- var IterationType = /* @__PURE__ */ ((IterationType3) => {
7290
- IterationType3["ITERATIVE"] = "ITERATIVE";
7291
- IterationType3["RECURSIVE"] = "RECURSIVE";
7292
- return IterationType3;
7293
- })(IterationType || {});
7294
- var FamilyPosition = /* @__PURE__ */ ((FamilyPosition2) => {
7295
- FamilyPosition2["ROOT"] = "ROOT";
7296
- FamilyPosition2["LEFT"] = "LEFT";
7297
- FamilyPosition2["RIGHT"] = "RIGHT";
7298
- FamilyPosition2["ROOT_LEFT"] = "ROOT_LEFT";
7299
- FamilyPosition2["ROOT_RIGHT"] = "ROOT_RIGHT";
7300
- FamilyPosition2["ISOLATED"] = "ISOLATED";
7301
- FamilyPosition2["MAL_NODE"] = "MAL_NODE";
7302
- return FamilyPosition2;
7303
- })(FamilyPosition || {});
7304
-
7305
7260
  // src/types/data-structures/binary-tree/rb-tree.ts
7306
7261
  var RBTNColor = /* @__PURE__ */ ((RBTNColor2) => {
7307
7262
  RBTNColor2[RBTNColor2["RED"] = 1] = "RED";
@@ -7321,6 +7276,21 @@ var dataStructureTyped = (() => {
7321
7276
  CP2["gt"] = "gt";
7322
7277
  return CP2;
7323
7278
  })(CP || {});
7279
+ var IterationType = /* @__PURE__ */ ((IterationType3) => {
7280
+ IterationType3["ITERATIVE"] = "ITERATIVE";
7281
+ IterationType3["RECURSIVE"] = "RECURSIVE";
7282
+ return IterationType3;
7283
+ })(IterationType || {});
7284
+ var FamilyPosition = /* @__PURE__ */ ((FamilyPosition2) => {
7285
+ FamilyPosition2["ROOT"] = "ROOT";
7286
+ FamilyPosition2["LEFT"] = "LEFT";
7287
+ FamilyPosition2["RIGHT"] = "RIGHT";
7288
+ FamilyPosition2["ROOT_LEFT"] = "ROOT_LEFT";
7289
+ FamilyPosition2["ROOT_RIGHT"] = "ROOT_RIGHT";
7290
+ FamilyPosition2["ISOLATED"] = "ISOLATED";
7291
+ FamilyPosition2["MAL_NODE"] = "MAL_NODE";
7292
+ return FamilyPosition2;
7293
+ })(FamilyPosition || {});
7324
7294
 
7325
7295
  // src/data-structures/binary-tree/binary-tree.ts
7326
7296
  var BinaryTreeNode = class {
@@ -7371,7 +7341,7 @@ var dataStructureTyped = (() => {
7371
7341
  var BinaryTree = class _BinaryTree extends IterableEntryBase {
7372
7342
  /**
7373
7343
  * The constructor function initializes a binary tree object with optional elements and options.
7374
- * @param [elements] - An optional iterable of BTNodeExemplar objects. These objects represent the
7344
+ * @param [elements] - An optional iterable of BTNExemplar objects. These objects represent the
7375
7345
  * elements to be added to the binary tree.
7376
7346
  * @param [options] - The `options` parameter is an optional object that can contain additional
7377
7347
  * configuration options for the binary tree. In this case, it is of type
@@ -7428,7 +7398,7 @@ var dataStructureTyped = (() => {
7428
7398
  }
7429
7399
  /**
7430
7400
  * The function "isNode" checks if an exemplar is an instance of the BinaryTreeNode class.
7431
- * @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V,N>`.
7401
+ * @param exemplar - The `exemplar` parameter is a variable of type `BTNExemplar<K, V,N>`.
7432
7402
  * @returns a boolean value indicating whether the exemplar is an instance of the class N.
7433
7403
  */
7434
7404
  isNode(exemplar) {
@@ -7436,7 +7406,7 @@ var dataStructureTyped = (() => {
7436
7406
  }
7437
7407
  /**
7438
7408
  * The function `exemplarToNode` converts an exemplar object into a node object.
7439
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
7409
+ * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
7440
7410
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
7441
7411
  * `exemplarToNode` function. It represents the value associated with the exemplar node. If no value
7442
7412
  * is provided, it will be `undefined`.
@@ -7468,7 +7438,7 @@ var dataStructureTyped = (() => {
7468
7438
  }
7469
7439
  /**
7470
7440
  * The function checks if a given value is an entry in a binary tree node.
7471
- * @param kne - BTNodeExemplar<K, V,N> - A generic type representing a node in a binary tree. It has
7441
+ * @param kne - BTNExemplar<K, V,N> - A generic type representing a node in a binary tree. It has
7472
7442
  * two type parameters V and N, representing the value and node type respectively.
7473
7443
  * @returns a boolean value.
7474
7444
  */
@@ -7540,7 +7510,7 @@ var dataStructureTyped = (() => {
7540
7510
  *
7541
7511
  * The `addMany` function takes in a collection of nodes and an optional collection of values, and
7542
7512
  * adds each node with its corresponding value to the data structure.
7543
- * @param nodes - An iterable collection of BTNodeExemplar objects.
7513
+ * @param nodes - An iterable collection of BTNExemplar objects.
7544
7514
  * @param [values] - An optional iterable of values that will be assigned to each node being added.
7545
7515
  * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
7546
7516
  */
@@ -7583,7 +7553,7 @@ var dataStructureTyped = (() => {
7583
7553
  * @param {C} callback - The `callback` parameter is a function that is used to determine the
7584
7554
  * identifier of the node to be deleted. It is optional and has a default value of
7585
7555
  * `this._defaultOneParamCallback`. The `callback` function should return the identifier of the node.
7586
- * @returns an array of `BiTreeDeleteResult<N>`.
7556
+ * @returns an array of `BinaryTreeDeleteResult<N>`.
7587
7557
  */
7588
7558
  delete(identifier, callback = this._defaultOneParamCallback) {
7589
7559
  const deletedResult = [];
@@ -8989,7 +8959,7 @@ var dataStructureTyped = (() => {
8989
8959
  /**
8990
8960
  * This is the constructor function for a binary search tree class in TypeScript, which initializes
8991
8961
  * the tree with optional elements and options.
8992
- * @param [elements] - An optional iterable of BTNodeExemplar objects that will be added to the
8962
+ * @param [elements] - An optional iterable of BTNExemplar objects that will be added to the
8993
8963
  * binary search tree.
8994
8964
  * @param [options] - The `options` parameter is an optional object that can contain additional
8995
8965
  * configuration options for the binary search tree. It can have the following properties:
@@ -9040,7 +9010,7 @@ var dataStructureTyped = (() => {
9040
9010
  }
9041
9011
  /**
9042
9012
  * The function checks if an exemplar is an instance of BSTNode.
9043
- * @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V, N>`.
9013
+ * @param exemplar - The `exemplar` parameter is a variable of type `BTNExemplar<K, V, N>`.
9044
9014
  * @returns a boolean value indicating whether the exemplar is an instance of the BSTNode class.
9045
9015
  */
9046
9016
  isNode(exemplar) {
@@ -9049,7 +9019,7 @@ var dataStructureTyped = (() => {
9049
9019
  /**
9050
9020
  * The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
9051
9021
  * otherwise it returns undefined.
9052
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
9022
+ * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
9053
9023
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
9054
9024
  * `exemplarToNode` function. It represents the value associated with the exemplar node.
9055
9025
  * @returns a node of type N or undefined.
@@ -10040,7 +10010,7 @@ var dataStructureTyped = (() => {
10040
10010
  var AVLTree = class _AVLTree extends BST {
10041
10011
  /**
10042
10012
  * The constructor function initializes an AVLTree object with optional elements and options.
10043
- * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
10013
+ * @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
10044
10014
  * objects. It represents a collection of elements that will be added to the AVL tree during
10045
10015
  * initialization.
10046
10016
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
@@ -10079,7 +10049,7 @@ var dataStructureTyped = (() => {
10079
10049
  }
10080
10050
  /**
10081
10051
  * The function checks if an exemplar is an instance of AVLTreeNode.
10082
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
10052
+ * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
10083
10053
  * @returns a boolean value indicating whether the exemplar is an instance of the AVLTreeNode class.
10084
10054
  */
10085
10055
  isNode(exemplar) {
@@ -10135,7 +10105,7 @@ var dataStructureTyped = (() => {
10135
10105
  * that is deleted from the binary tree. It is an optional parameter and if not provided, it will
10136
10106
  * default to the `_defaultOneParamCallback` function. The `callback` function should have a single
10137
10107
  * parameter of type `N
10138
- * @returns The method is returning an array of `BiTreeDeleteResult<N>`.
10108
+ * @returns The method is returning an array of `BinaryTreeDeleteResult<N>`.
10139
10109
  */
10140
10110
  delete(identifier, callback = this._defaultOneParamCallback) {
10141
10111
  if (identifier instanceof AVLTreeNode)
@@ -10465,7 +10435,7 @@ var dataStructureTyped = (() => {
10465
10435
  /**
10466
10436
  * This is the constructor function for a Red-Black Tree data structure in TypeScript, which
10467
10437
  * initializes the tree with optional elements and options.
10468
- * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
10438
+ * @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
10469
10439
  * objects. It represents the initial elements that will be added to the RBTree during its
10470
10440
  * construction. If this parameter is provided, the `addMany` method is called to add all the
10471
10441
  * elements to the
@@ -10518,7 +10488,7 @@ var dataStructureTyped = (() => {
10518
10488
  }
10519
10489
  /**
10520
10490
  * The function checks if an exemplar is an instance of the RedBlackTreeNode class.
10521
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
10491
+ * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
10522
10492
  * @returns a boolean value indicating whether the exemplar is an instance of the RedBlackTreeNode
10523
10493
  * class.
10524
10494
  */
@@ -10536,7 +10506,7 @@ var dataStructureTyped = (() => {
10536
10506
  }
10537
10507
  /**
10538
10508
  * The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
10539
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
10509
+ * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
10540
10510
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
10541
10511
  * `exemplarToNode` function. It represents the value associated with the exemplar node. If a value
10542
10512
  * is provided, it will be used when creating the new node. If no value is provided, the new node
@@ -10638,7 +10608,7 @@ var dataStructureTyped = (() => {
10638
10608
  * @param {C} callback - The `callback` parameter is a function that takes a node of type `N` and
10639
10609
  * returns a value of type `ReturnType<C>`. It is used to determine if a node should be deleted based
10640
10610
  * on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
10641
- * @returns an array of `BiTreeDeleteResult<N>`.
10611
+ * @returns an array of `BinaryTreeDeleteResult<N>`.
10642
10612
  */
10643
10613
  delete(identifier, callback = this._defaultOneParamCallback) {
10644
10614
  const ans = [];
@@ -10729,7 +10699,7 @@ var dataStructureTyped = (() => {
10729
10699
  */
10730
10700
  getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
10731
10701
  var _a;
10732
- if (identifier instanceof BinaryTreeNode)
10702
+ if (identifier instanceof RedBlackTreeNode)
10733
10703
  callback = (node) => node;
10734
10704
  beginRoot = this.ensureNode(beginRoot);
10735
10705
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) != null ? _a : void 0;
@@ -11049,7 +11019,7 @@ var dataStructureTyped = (() => {
11049
11019
  }
11050
11020
  /**
11051
11021
  * The function checks if an exemplar is an instance of the TreeMultimapNode class.
11052
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
11022
+ * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
11053
11023
  * @returns a boolean value indicating whether the exemplar is an instance of the TreeMultimapNode
11054
11024
  * class.
11055
11025
  */
@@ -11067,7 +11037,7 @@ var dataStructureTyped = (() => {
11067
11037
  }
11068
11038
  /**
11069
11039
  * The function `exemplarToNode` converts an exemplar object into a node object.
11070
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
11040
+ * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, which means it
11071
11041
  * can be one of the following:
11072
11042
  * @param {V} [value] - The `value` parameter is an optional argument that represents the value
11073
11043
  * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
@@ -11215,7 +11185,7 @@ var dataStructureTyped = (() => {
11215
11185
  * being deleted. If set to true, the count of the node will not be considered and the node will be
11216
11186
  * deleted regardless of its count. If set to false (default), the count of the node will be
11217
11187
  * decremented by 1 and
11218
- * @returns an array of `BiTreeDeleteResult<N>`.
11188
+ * @returns an array of `BinaryTreeDeleteResult<N>`.
11219
11189
  */
11220
11190
  delete(identifier, callback = this._defaultOneParamCallback, ignoreCount = false) {
11221
11191
  var _a;
@@ -11411,6 +11381,43 @@ var dataStructureTyped = (() => {
11411
11381
  }
11412
11382
  };
11413
11383
 
11384
+ // src/data-structures/priority-queue/priority-queue.ts
11385
+ var PriorityQueue = class extends Heap {
11386
+ constructor(elements, options) {
11387
+ super(elements, options);
11388
+ }
11389
+ };
11390
+
11391
+ // src/data-structures/priority-queue/min-priority-queue.ts
11392
+ var MinPriorityQueue = class extends PriorityQueue {
11393
+ constructor(elements, options = {
11394
+ comparator: (a, b) => {
11395
+ if (!(typeof a === "number" && typeof b === "number")) {
11396
+ throw new Error("The a, b params of compare function must be number");
11397
+ } else {
11398
+ return a - b;
11399
+ }
11400
+ }
11401
+ }) {
11402
+ super(elements, options);
11403
+ }
11404
+ };
11405
+
11406
+ // src/data-structures/priority-queue/max-priority-queue.ts
11407
+ var MaxPriorityQueue = class extends PriorityQueue {
11408
+ constructor(elements, options = {
11409
+ comparator: (a, b) => {
11410
+ if (!(typeof a === "number" && typeof b === "number")) {
11411
+ throw new Error("The a, b params of compare function must be number");
11412
+ } else {
11413
+ return b - a;
11414
+ }
11415
+ }
11416
+ }) {
11417
+ super(elements, options);
11418
+ }
11419
+ };
11420
+
11414
11421
  // src/data-structures/matrix/matrix.ts
11415
11422
  var MatrixNTI2D = class {
11416
11423
  /**