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
@@ -5,6 +5,60 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
5
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
+ // src/common/error.ts
9
+ function raise(ErrorClass, message) {
10
+ throw new ErrorClass(message);
11
+ }
12
+ __name(raise, "raise");
13
+ var ERR = {
14
+ // Range / index
15
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
16
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
17
+ // Type / argument
18
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
19
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
20
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
21
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
22
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
23
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
24
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
25
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
26
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
27
+ // State / operation
28
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
29
+ // Matrix
30
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
31
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
32
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
33
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
34
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
35
+ // Order statistic
36
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
37
+ };
38
+
39
+ // src/common/index.ts
40
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
41
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
42
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
43
+ return DFSOperation2;
44
+ })(DFSOperation || {});
45
+ var _Range = class _Range {
46
+ constructor(low, high, includeLow = true, includeHigh = true) {
47
+ this.low = low;
48
+ this.high = high;
49
+ this.includeLow = includeLow;
50
+ this.includeHigh = includeHigh;
51
+ }
52
+ // Determine whether a key is within the range
53
+ isInRange(key, comparator) {
54
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
55
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
56
+ return lowCheck && highCheck;
57
+ }
58
+ };
59
+ __name(_Range, "Range");
60
+ var Range = _Range;
61
+
8
62
  // src/data-structures/base/iterable-element-base.ts
9
63
  var _IterableElementBase = class _IterableElementBase {
10
64
  /**
@@ -27,7 +81,7 @@ var _IterableElementBase = class _IterableElementBase {
27
81
  if (options) {
28
82
  const { toElementFn } = options;
29
83
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
30
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
84
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
31
85
  }
32
86
  }
33
87
  /**
@@ -183,7 +237,7 @@ var _IterableElementBase = class _IterableElementBase {
183
237
  acc = initialValue;
184
238
  } else {
185
239
  const first = iter.next();
186
- 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");
187
241
  acc = first.value;
188
242
  index = 1;
189
243
  }
@@ -227,54 +281,6 @@ var _IterableElementBase = class _IterableElementBase {
227
281
  __name(_IterableElementBase, "IterableElementBase");
228
282
  var IterableElementBase = _IterableElementBase;
229
283
 
230
- // src/common/error.ts
231
- var ERR = {
232
- // Range / index
233
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
234
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
235
- // Type / argument
236
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
237
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
238
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
239
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
240
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
241
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
242
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
243
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
244
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
245
- // State / operation
246
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
247
- // Matrix
248
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
249
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
250
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
251
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
252
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
253
- };
254
-
255
- // src/common/index.ts
256
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
257
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
258
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
259
- return DFSOperation2;
260
- })(DFSOperation || {});
261
- var _Range = class _Range {
262
- constructor(low, high, includeLow = true, includeHigh = true) {
263
- this.low = low;
264
- this.high = high;
265
- this.includeLow = includeLow;
266
- this.includeHigh = includeHigh;
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
- __name(_Range, "Range");
276
- var Range = _Range;
277
-
278
284
  // src/data-structures/heap/heap.ts
279
285
  var _Heap = class _Heap extends IterableElementBase {
280
286
  /**
@@ -290,7 +296,7 @@ var _Heap = class _Heap extends IterableElementBase {
290
296
  __publicField(this, "_elements", []);
291
297
  __publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
292
298
  if (typeof a === "object" || typeof b === "object") {
293
- throw new TypeError(ERR.comparatorRequired("Heap"));
299
+ raise(TypeError, ERR.comparatorRequired("Heap"));
294
300
  }
295
301
  if (a > b) return 1;
296
302
  if (a < b) return -1;
@@ -339,6 +345,13 @@ var _Heap = class _Heap extends IterableElementBase {
339
345
 
340
346
 
341
347
 
348
+
349
+
350
+
351
+
352
+
353
+
354
+
342
355
 
343
356
 
344
357
 
@@ -396,7 +409,7 @@ var _Heap = class _Heap extends IterableElementBase {
396
409
  }
397
410
  /**
398
411
  * Insert an element.
399
- * @remarks Time O(1) amortized, Space O(1)
412
+ * @remarks Time O(log N) amortized, Space O(1)
400
413
  * @param element - Element to insert.
401
414
  * @returns True.
402
415
 
@@ -423,6 +436,13 @@ var _Heap = class _Heap extends IterableElementBase {
423
436
 
424
437
 
425
438
 
439
+
440
+
441
+
442
+
443
+
444
+
445
+
426
446
 
427
447
 
428
448
 
@@ -477,6 +497,13 @@ var _Heap = class _Heap extends IterableElementBase {
477
497
 
478
498
 
479
499
 
500
+
501
+
502
+
503
+
504
+
505
+
506
+
480
507
 
481
508
 
482
509
 
@@ -541,6 +568,40 @@ var _Heap = class _Heap extends IterableElementBase {
541
568
 
542
569
 
543
570
 
571
+
572
+
573
+
574
+
575
+
576
+
577
+ * @example
578
+ * // Heap with custom comparator (MaxHeap behavior)
579
+ * interface Task {
580
+ * id: number;
581
+ * priority: number;
582
+ * name: string;
583
+ * }
584
+ *
585
+ * // Custom comparator for max heap behavior (higher priority first)
586
+ * const tasks: Task[] = [
587
+ * { id: 1, priority: 5, name: 'Email' },
588
+ * { id: 2, priority: 3, name: 'Chat' },
589
+ * { id: 3, priority: 8, name: 'Alert' }
590
+ * ];
591
+ *
592
+ * const maxHeap = new Heap(tasks, {
593
+ * comparator: (a: Task, b: Task) => b.priority - a.priority
594
+ * });
595
+ *
596
+ * console.log(maxHeap.size); // 3;
597
+ *
598
+ * // Peek returns highest priority task
599
+ * const topTask = maxHeap.peek();
600
+ * console.log(topTask?.priority); // 8;
601
+ * console.log(topTask?.name); // 'Alert';
602
+ */
603
+ /**
604
+ * @deprecated Use `pop` instead. Will be removed in a future major version.
544
605
  * @example
545
606
  * // Heap with custom comparator (MaxHeap behavior)
546
607
  * interface Task {
@@ -568,6 +629,14 @@ var _Heap = class _Heap extends IterableElementBase {
568
629
  * console.log(topTask?.name); // 'Alert';
569
630
  */
570
631
  poll() {
632
+ return this.pop();
633
+ }
634
+ /**
635
+ * Remove and return the top element (min or max depending on comparator).
636
+ * @remarks Time O(log N) amortized, Space O(1)
637
+ * @returns The removed top element, or undefined if empty.
638
+ */
639
+ pop() {
571
640
  if (this.elements.length === 0) return;
572
641
  const value = this.elements[0];
573
642
  const last = this.elements.pop();
@@ -605,6 +674,13 @@ var _Heap = class _Heap extends IterableElementBase {
605
674
 
606
675
 
607
676
 
677
+
678
+
679
+
680
+
681
+
682
+
683
+
608
684
 
609
685
 
610
686
 
@@ -702,6 +778,13 @@ var _Heap = class _Heap extends IterableElementBase {
702
778
 
703
779
 
704
780
 
781
+
782
+
783
+
784
+
785
+
786
+
787
+
705
788
 
706
789
 
707
790
 
@@ -746,6 +829,13 @@ var _Heap = class _Heap extends IterableElementBase {
746
829
 
747
830
 
748
831
 
832
+
833
+
834
+
835
+
836
+
837
+
838
+
749
839
 
750
840
 
751
841
 
@@ -763,16 +853,6 @@ var _Heap = class _Heap extends IterableElementBase {
763
853
  clear() {
764
854
  this._elements = [];
765
855
  }
766
- /**
767
- * Replace the backing array and rebuild the heap.
768
- * @remarks Time O(N), Space O(N)
769
- * @param elements - Iterable used to refill the heap.
770
- * @returns Array of per-node results from fixing steps.
771
- */
772
- refill(elements) {
773
- this._elements = Array.from(elements);
774
- return this.fix();
775
- }
776
856
  /**
777
857
  * Check if an equal element exists in the heap.
778
858
  * @remarks Time O(N), Space O(1)
@@ -793,6 +873,13 @@ var _Heap = class _Heap extends IterableElementBase {
793
873
 
794
874
 
795
875
 
876
+
877
+
878
+
879
+
880
+
881
+
882
+
796
883
 
797
884
 
798
885
 
@@ -837,6 +924,13 @@ var _Heap = class _Heap extends IterableElementBase {
837
924
 
838
925
 
839
926
 
927
+
928
+
929
+
930
+
931
+
932
+
933
+
840
934
 
841
935
 
842
936
 
@@ -861,7 +955,7 @@ var _Heap = class _Heap extends IterableElementBase {
861
955
  }
862
956
  if (index < 0) return false;
863
957
  if (index === 0) {
864
- this.poll();
958
+ this.pop();
865
959
  } else if (index === this.elements.length - 1) {
866
960
  this.elements.pop();
867
961
  } else {
@@ -871,13 +965,19 @@ var _Heap = class _Heap extends IterableElementBase {
871
965
  }
872
966
  return true;
873
967
  }
968
+ /**
969
+ * @deprecated Use `deleteWhere` instead. Will be removed in a future major version.
970
+ */
971
+ deleteBy(predicate) {
972
+ return this.deleteWhere(predicate);
973
+ }
874
974
  /**
875
975
  * Delete the first element that matches a predicate.
876
976
  * @remarks Time O(N), Space O(1)
877
977
  * @param predicate - Function (element, index, heap) → boolean.
878
978
  * @returns True if an element was removed.
879
979
  */
880
- deleteBy(predicate) {
980
+ deleteWhere(predicate) {
881
981
  let idx = -1;
882
982
  for (let i = 0; i < this.elements.length; i++) {
883
983
  if (predicate(this.elements[i], i, this)) {
@@ -887,7 +987,7 @@ var _Heap = class _Heap extends IterableElementBase {
887
987
  }
888
988
  if (idx < 0) return false;
889
989
  if (idx === 0) {
890
- this.poll();
990
+ this.pop();
891
991
  } else if (idx === this.elements.length - 1) {
892
992
  this.elements.pop();
893
993
  } else {
@@ -927,6 +1027,13 @@ var _Heap = class _Heap extends IterableElementBase {
927
1027
 
928
1028
 
929
1029
 
1030
+
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
930
1037
 
931
1038
 
932
1039
 
@@ -1004,6 +1111,13 @@ var _Heap = class _Heap extends IterableElementBase {
1004
1111
 
1005
1112
 
1006
1113
 
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1007
1121
 
1008
1122
 
1009
1123
 
@@ -1054,6 +1168,13 @@ var _Heap = class _Heap extends IterableElementBase {
1054
1168
 
1055
1169
 
1056
1170
 
1171
+
1172
+
1173
+
1174
+
1175
+
1176
+
1177
+
1057
1178
 
1058
1179
 
1059
1180
 
@@ -1103,6 +1224,13 @@ var _Heap = class _Heap extends IterableElementBase {
1103
1224
 
1104
1225
 
1105
1226
 
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1106
1234
 
1107
1235
 
1108
1236
 
@@ -1159,6 +1287,13 @@ var _Heap = class _Heap extends IterableElementBase {
1159
1287
 
1160
1288
 
1161
1289
 
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+
1296
+
1162
1297
 
1163
1298
 
1164
1299
 
@@ -1175,7 +1310,7 @@ var _Heap = class _Heap extends IterableElementBase {
1175
1310
  */
1176
1311
  map(callback, options, thisArg) {
1177
1312
  const { comparator, toElementFn, ...rest } = options != null ? options : {};
1178
- if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
1313
+ if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
1179
1314
  const out = this._createLike([], { ...rest, comparator, toElementFn });
1180
1315
  let i = 0;
1181
1316
  for (const x of this) {
@@ -1307,7 +1442,7 @@ var _FibonacciHeap = class _FibonacciHeap {
1307
1442
  __publicField(this, "_comparator");
1308
1443
  this.clear();
1309
1444
  this._comparator = comparator || this._defaultComparator;
1310
- if (typeof this.comparator !== "function") throw new TypeError(ERR.notAFunction("comparator", "FibonacciHeap"));
1445
+ if (typeof this.comparator !== "function") raise(TypeError, ERR.notAFunction("comparator", "FibonacciHeap"));
1311
1446
  }
1312
1447
  /**
1313
1448
  * Get the circular root list head.
@@ -1344,7 +1479,7 @@ var _FibonacciHeap = class _FibonacciHeap {
1344
1479
  * Push an element into the root list.
1345
1480
  * @remarks Time O(1) amortized, Space O(1)
1346
1481
  * @param element - Element to insert.
1347
- * @returns This heap.
1482
+ * @returns True when the element is added.
1348
1483
  */
1349
1484
  push(element) {
1350
1485
  const node = this.createNode(element);
@@ -1353,7 +1488,7 @@ var _FibonacciHeap = class _FibonacciHeap {
1353
1488
  this.mergeWithRoot(node);
1354
1489
  if (!this.min || this.comparator(node.element, this.min.element) <= 0) this._min = node;
1355
1490
  this._size++;
1356
- return this;
1491
+ return true;
1357
1492
  }
1358
1493
  peek() {
1359
1494
  return this.min ? this.min.element : void 0;
@@ -1529,7 +1664,7 @@ var _MaxPriorityQueue = class _MaxPriorityQueue extends PriorityQueue {
1529
1664
  super(elements, {
1530
1665
  comparator: /* @__PURE__ */ __name((a, b) => {
1531
1666
  if (typeof a === "object" || typeof b === "object") {
1532
- throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
1667
+ raise(TypeError, ERR.comparatorRequired("MaxPriorityQueue"));
1533
1668
  }
1534
1669
  if (a < b) return 1;
1535
1670
  if (a > b) return -1;
@@ -1564,5 +1699,6 @@ exports.Heap = Heap;
1564
1699
  exports.MaxPriorityQueue = MaxPriorityQueue;
1565
1700
  exports.PriorityQueue = PriorityQueue;
1566
1701
  exports.Range = Range;
1702
+ exports.raise = raise;
1567
1703
  //# sourceMappingURL=index.cjs.map
1568
1704
  //# sourceMappingURL=index.cjs.map