max-priority-queue-typed 2.5.1 → 2.5.3

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 (75) hide show
  1. package/dist/cjs/index.cjs +207 -71
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +206 -70
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +207 -72
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +206 -71
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +127 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  37. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  38. package/dist/umd/max-priority-queue-typed.js +204 -69
  39. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  40. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  41. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/common/error.ts +19 -1
  44. package/src/common/index.ts +1 -1
  45. package/src/data-structures/base/iterable-element-base.ts +3 -2
  46. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  47. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  48. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  49. package/src/data-structures/binary-tree/bst.ts +542 -13
  50. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  51. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  52. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  53. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  54. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  55. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  56. package/src/data-structures/graph/abstract-graph.ts +2 -2
  57. package/src/data-structures/graph/directed-graph.ts +71 -1
  58. package/src/data-structures/graph/undirected-graph.ts +64 -1
  59. package/src/data-structures/hash/hash-map.ts +102 -16
  60. package/src/data-structures/heap/heap.ts +153 -23
  61. package/src/data-structures/heap/max-heap.ts +2 -2
  62. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  63. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  64. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  65. package/src/data-structures/matrix/matrix.ts +65 -9
  66. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  67. package/src/data-structures/queue/deque.ts +130 -0
  68. package/src/data-structures/queue/queue.ts +109 -0
  69. package/src/data-structures/stack/stack.ts +75 -5
  70. package/src/data-structures/trie/trie.ts +86 -2
  71. package/src/interfaces/binary-tree.ts +1 -9
  72. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  73. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  74. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  75. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -1,6 +1,61 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
+ // src/common/error.ts
5
+ function raise(ErrorClass, message) {
6
+ throw new ErrorClass(message);
7
+ }
8
+ __name(raise, "raise");
9
+ var ERR = {
10
+ // Range / index
11
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
12
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
13
+ // Type / argument
14
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
15
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
16
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
17
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
18
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
19
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
20
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
21
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
22
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
23
+ // State / operation
24
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
25
+ // Matrix
26
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
27
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
28
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
29
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
30
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
31
+ // Order statistic
32
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
33
+ };
34
+
35
+ // src/common/index.ts
36
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
37
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
38
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
39
+ return DFSOperation2;
40
+ })(DFSOperation || {});
41
+ var Range = class {
42
+ constructor(low, high, includeLow = true, includeHigh = true) {
43
+ this.low = low;
44
+ this.high = high;
45
+ this.includeLow = includeLow;
46
+ this.includeHigh = includeHigh;
47
+ }
48
+ static {
49
+ __name(this, "Range");
50
+ }
51
+ // Determine whether a key is within the range
52
+ isInRange(key, comparator) {
53
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
54
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
55
+ return lowCheck && highCheck;
56
+ }
57
+ };
58
+
4
59
  // src/data-structures/base/iterable-element-base.ts
5
60
  var IterableElementBase = class {
6
61
  static {
@@ -19,7 +74,7 @@ var IterableElementBase = class {
19
74
  if (options) {
20
75
  const { toElementFn } = options;
21
76
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
22
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
77
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
23
78
  }
24
79
  }
25
80
  /**
@@ -182,7 +237,7 @@ var IterableElementBase = class {
182
237
  acc = initialValue;
183
238
  } else {
184
239
  const first = iter.next();
185
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
240
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
186
241
  acc = first.value;
187
242
  index = 1;
188
243
  }
@@ -224,55 +279,6 @@ var IterableElementBase = class {
224
279
  }
225
280
  };
226
281
 
227
- // src/common/error.ts
228
- var ERR = {
229
- // Range / index
230
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
231
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
232
- // Type / argument
233
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
234
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
235
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
236
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
237
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
238
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
239
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
240
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
241
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
242
- // State / operation
243
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
244
- // Matrix
245
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
246
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
247
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
248
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
249
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
250
- };
251
-
252
- // src/common/index.ts
253
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
254
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
255
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
256
- return DFSOperation2;
257
- })(DFSOperation || {});
258
- var Range = class {
259
- constructor(low, high, includeLow = true, includeHigh = true) {
260
- this.low = low;
261
- this.high = high;
262
- this.includeLow = includeLow;
263
- this.includeHigh = includeHigh;
264
- }
265
- static {
266
- __name(this, "Range");
267
- }
268
- // Determine whether a key is within the range
269
- isInRange(key, comparator) {
270
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
271
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
272
- return lowCheck && highCheck;
273
- }
274
- };
275
-
276
282
  // src/data-structures/heap/heap.ts
277
283
  var Heap = class _Heap extends IterableElementBase {
278
284
  static {
@@ -331,6 +337,13 @@ var Heap = class _Heap extends IterableElementBase {
331
337
 
332
338
 
333
339
 
340
+
341
+
342
+
343
+
344
+
345
+
346
+
334
347
 
335
348
 
336
349
 
@@ -387,7 +400,7 @@ var Heap = class _Heap extends IterableElementBase {
387
400
  }
388
401
  /**
389
402
  * Insert an element.
390
- * @remarks Time O(1) amortized, Space O(1)
403
+ * @remarks Time O(log N) amortized, Space O(1)
391
404
  * @param element - Element to insert.
392
405
  * @returns True.
393
406
 
@@ -414,6 +427,13 @@ var Heap = class _Heap extends IterableElementBase {
414
427
 
415
428
 
416
429
 
430
+
431
+
432
+
433
+
434
+
435
+
436
+
417
437
 
418
438
 
419
439
 
@@ -468,6 +488,13 @@ var Heap = class _Heap extends IterableElementBase {
468
488
 
469
489
 
470
490
 
491
+
492
+
493
+
494
+
495
+
496
+
497
+
471
498
 
472
499
 
473
500
 
@@ -532,6 +559,40 @@ var Heap = class _Heap extends IterableElementBase {
532
559
 
533
560
 
534
561
 
562
+
563
+
564
+
565
+
566
+
567
+
568
+ * @example
569
+ * // Heap with custom comparator (MaxHeap behavior)
570
+ * interface Task {
571
+ * id: number;
572
+ * priority: number;
573
+ * name: string;
574
+ * }
575
+ *
576
+ * // Custom comparator for max heap behavior (higher priority first)
577
+ * const tasks: Task[] = [
578
+ * { id: 1, priority: 5, name: 'Email' },
579
+ * { id: 2, priority: 3, name: 'Chat' },
580
+ * { id: 3, priority: 8, name: 'Alert' }
581
+ * ];
582
+ *
583
+ * const maxHeap = new Heap(tasks, {
584
+ * comparator: (a: Task, b: Task) => b.priority - a.priority
585
+ * });
586
+ *
587
+ * console.log(maxHeap.size); // 3;
588
+ *
589
+ * // Peek returns highest priority task
590
+ * const topTask = maxHeap.peek();
591
+ * console.log(topTask?.priority); // 8;
592
+ * console.log(topTask?.name); // 'Alert';
593
+ */
594
+ /**
595
+ * @deprecated Use `pop` instead. Will be removed in a future major version.
535
596
  * @example
536
597
  * // Heap with custom comparator (MaxHeap behavior)
537
598
  * interface Task {
@@ -559,6 +620,14 @@ var Heap = class _Heap extends IterableElementBase {
559
620
  * console.log(topTask?.name); // 'Alert';
560
621
  */
561
622
  poll() {
623
+ return this.pop();
624
+ }
625
+ /**
626
+ * Remove and return the top element (min or max depending on comparator).
627
+ * @remarks Time O(log N) amortized, Space O(1)
628
+ * @returns The removed top element, or undefined if empty.
629
+ */
630
+ pop() {
562
631
  if (this.elements.length === 0) return;
563
632
  const value = this.elements[0];
564
633
  const last = this.elements.pop();
@@ -596,6 +665,13 @@ var Heap = class _Heap extends IterableElementBase {
596
665
 
597
666
 
598
667
 
668
+
669
+
670
+
671
+
672
+
673
+
674
+
599
675
 
600
676
 
601
677
 
@@ -693,6 +769,13 @@ var Heap = class _Heap extends IterableElementBase {
693
769
 
694
770
 
695
771
 
772
+
773
+
774
+
775
+
776
+
777
+
778
+
696
779
 
697
780
 
698
781
 
@@ -737,6 +820,13 @@ var Heap = class _Heap extends IterableElementBase {
737
820
 
738
821
 
739
822
 
823
+
824
+
825
+
826
+
827
+
828
+
829
+
740
830
 
741
831
 
742
832
 
@@ -754,16 +844,6 @@ var Heap = class _Heap extends IterableElementBase {
754
844
  clear() {
755
845
  this._elements = [];
756
846
  }
757
- /**
758
- * Replace the backing array and rebuild the heap.
759
- * @remarks Time O(N), Space O(N)
760
- * @param elements - Iterable used to refill the heap.
761
- * @returns Array of per-node results from fixing steps.
762
- */
763
- refill(elements) {
764
- this._elements = Array.from(elements);
765
- return this.fix();
766
- }
767
847
  /**
768
848
  * Check if an equal element exists in the heap.
769
849
  * @remarks Time O(N), Space O(1)
@@ -784,6 +864,13 @@ var Heap = class _Heap extends IterableElementBase {
784
864
 
785
865
 
786
866
 
867
+
868
+
869
+
870
+
871
+
872
+
873
+
787
874
 
788
875
 
789
876
 
@@ -828,6 +915,13 @@ var Heap = class _Heap extends IterableElementBase {
828
915
 
829
916
 
830
917
 
918
+
919
+
920
+
921
+
922
+
923
+
924
+
831
925
 
832
926
 
833
927
 
@@ -852,7 +946,7 @@ var Heap = class _Heap extends IterableElementBase {
852
946
  }
853
947
  if (index < 0) return false;
854
948
  if (index === 0) {
855
- this.poll();
949
+ this.pop();
856
950
  } else if (index === this.elements.length - 1) {
857
951
  this.elements.pop();
858
952
  } else {
@@ -862,13 +956,19 @@ var Heap = class _Heap extends IterableElementBase {
862
956
  }
863
957
  return true;
864
958
  }
959
+ /**
960
+ * @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
961
+ */
962
+ deleteBy(predicate) {
963
+ return this.deleteWhere(predicate);
964
+ }
865
965
  /**
866
966
  * Delete the first element that matches a predicate.
867
967
  * @remarks Time O(N), Space O(1)
868
968
  * @param predicate - Function (element, index, heap) → boolean.
869
969
  * @returns True if an element was removed.
870
970
  */
871
- deleteBy(predicate) {
971
+ deleteWhere(predicate) {
872
972
  let idx = -1;
873
973
  for (let i = 0; i < this.elements.length; i++) {
874
974
  if (predicate(this.elements[i], i, this)) {
@@ -878,7 +978,7 @@ var Heap = class _Heap extends IterableElementBase {
878
978
  }
879
979
  if (idx < 0) return false;
880
980
  if (idx === 0) {
881
- this.poll();
981
+ this.pop();
882
982
  } else if (idx === this.elements.length - 1) {
883
983
  this.elements.pop();
884
984
  } else {
@@ -918,6 +1018,13 @@ var Heap = class _Heap extends IterableElementBase {
918
1018
 
919
1019
 
920
1020
 
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
921
1028
 
922
1029
 
923
1030
 
@@ -995,6 +1102,13 @@ var Heap = class _Heap extends IterableElementBase {
995
1102
 
996
1103
 
997
1104
 
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
998
1112
 
999
1113
 
1000
1114
 
@@ -1045,6 +1159,13 @@ var Heap = class _Heap extends IterableElementBase {
1045
1159
 
1046
1160
 
1047
1161
 
1162
+
1163
+
1164
+
1165
+
1166
+
1167
+
1168
+
1048
1169
 
1049
1170
 
1050
1171
 
@@ -1094,6 +1215,13 @@ var Heap = class _Heap extends IterableElementBase {
1094
1215
 
1095
1216
 
1096
1217
 
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+
1097
1225
 
1098
1226
 
1099
1227
 
@@ -1150,6 +1278,13 @@ var Heap = class _Heap extends IterableElementBase {
1150
1278
 
1151
1279
 
1152
1280
 
1281
+
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+
1153
1288
 
1154
1289
 
1155
1290
 
@@ -1166,7 +1301,7 @@ var Heap = class _Heap extends IterableElementBase {
1166
1301
  */
1167
1302
  map(callback, options, thisArg) {
1168
1303
  const { comparator, toElementFn, ...rest } = options ?? {};
1169
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1304
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1170
1305
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1171
1306
  let i = 0;
1172
1307
  for (const x of this) {
@@ -1193,7 +1328,7 @@ var Heap = class _Heap extends IterableElementBase {
1193
1328
  }
1194
1329
  _DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
1195
1330
  if (typeof a === "object" || typeof b === "object") {
1196
- throw new TypeError(ERR.comparatorRequired("Heap"));
1331
+ raise(TypeError, ERR.comparatorRequired("Heap"));
1197
1332
  }
1198
1333
  if (a > b) return 1;
1199
1334
  if (a < b) return -1;
@@ -1305,7 +1440,7 @@ var FibonacciHeap = class {
1305
1440
  constructor(comparator) {
1306
1441
  this.clear();
1307
1442
  this._comparator = comparator || this._defaultComparator;
1308
- if (typeof this.comparator !== "function") throw new TypeError(ERR.notAFunction("comparator", "FibonacciHeap"));
1443
+ if (typeof this.comparator !== "function") raise(TypeError, ERR.notAFunction("comparator", "FibonacciHeap"));
1309
1444
  }
1310
1445
  _root;
1311
1446
  /**
@@ -1346,7 +1481,7 @@ var FibonacciHeap = class {
1346
1481
  * Push an element into the root list.
1347
1482
  * @remarks Time O(1) amortized, Space O(1)
1348
1483
  * @param element - Element to insert.
1349
- * @returns This heap.
1484
+ * @returns True when the element is added.
1350
1485
  */
1351
1486
  push(element) {
1352
1487
  const node = this.createNode(element);
@@ -1355,7 +1490,7 @@ var FibonacciHeap = class {
1355
1490
  this.mergeWithRoot(node);
1356
1491
  if (!this.min || this.comparator(node.element, this.min.element) <= 0) this._min = node;
1357
1492
  this._size++;
1358
- return this;
1493
+ return true;
1359
1494
  }
1360
1495
  peek() {
1361
1496
  return this.min ? this.min.element : void 0;
@@ -1533,7 +1668,7 @@ var MaxPriorityQueue = class extends PriorityQueue {
1533
1668
  super(elements, {
1534
1669
  comparator: /* @__PURE__ */ __name((a, b) => {
1535
1670
  if (typeof a === "object" || typeof b === "object") {
1536
- throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
1671
+ raise(TypeError, ERR.comparatorRequired("MaxPriorityQueue"));
1537
1672
  }
1538
1673
  if (a < b) return 1;
1539
1674
  if (a > b) return -1;
@@ -1558,6 +1693,6 @@ var MaxPriorityQueue = class extends PriorityQueue {
1558
1693
  * @license MIT License
1559
1694
  */
1560
1695
 
1561
- export { DFSOperation, ERR, FibonacciHeap, FibonacciHeapNode, Heap, MaxPriorityQueue, PriorityQueue, Range };
1696
+ export { DFSOperation, ERR, FibonacciHeap, FibonacciHeapNode, Heap, MaxPriorityQueue, PriorityQueue, Range, raise };
1562
1697
  //# sourceMappingURL=index.mjs.map
1563
1698
  //# sourceMappingURL=index.mjs.map