data-structure-typed 2.4.3 → 2.4.5

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 (62) hide show
  1. package/.github/workflows/release.yml +27 -0
  2. package/CHANGELOG.md +24 -1
  3. package/README.md +70 -51
  4. package/dist/cjs/index.cjs +486 -167
  5. package/dist/cjs-legacy/index.cjs +487 -165
  6. package/dist/esm/index.mjs +486 -168
  7. package/dist/esm-legacy/index.mjs +487 -166
  8. package/dist/types/common/error.d.ts +23 -0
  9. package/dist/types/common/index.d.ts +1 -0
  10. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  11. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +15 -5
  12. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +7 -1
  14. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -0
  15. package/dist/types/data-structures/graph/directed-graph.d.ts +3 -2
  16. package/dist/types/data-structures/graph/undirected-graph.d.ts +16 -2
  17. package/dist/types/data-structures/hash/hash-map.d.ts +2 -2
  18. package/dist/types/data-structures/heap/heap.d.ts +3 -7
  19. package/dist/types/data-structures/queue/deque.d.ts +41 -1
  20. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
  21. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
  22. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
  23. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
  24. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  25. package/dist/types/types/data-structures/queue/deque.d.ts +6 -0
  26. package/dist/types/types/data-structures/stack/stack.d.ts +1 -1
  27. package/dist/umd/data-structure-typed.js +486 -164
  28. package/dist/umd/data-structure-typed.min.js +6 -4
  29. package/package.json +2 -2
  30. package/src/common/error.ts +60 -0
  31. package/src/common/index.ts +2 -0
  32. package/src/data-structures/base/iterable-element-base.ts +5 -4
  33. package/src/data-structures/binary-tree/binary-indexed-tree.ts +6 -5
  34. package/src/data-structures/binary-tree/binary-tree.ts +121 -49
  35. package/src/data-structures/binary-tree/bst.ts +12 -4
  36. package/src/data-structures/binary-tree/red-black-tree.ts +20 -0
  37. package/src/data-structures/binary-tree/tree-map.ts +8 -7
  38. package/src/data-structures/binary-tree/tree-multi-map.ts +4 -4
  39. package/src/data-structures/binary-tree/tree-multi-set.ts +10 -9
  40. package/src/data-structures/binary-tree/tree-set.ts +7 -6
  41. package/src/data-structures/graph/abstract-graph.ts +124 -19
  42. package/src/data-structures/graph/directed-graph.ts +8 -4
  43. package/src/data-structures/graph/map-graph.ts +1 -1
  44. package/src/data-structures/graph/undirected-graph.ts +99 -4
  45. package/src/data-structures/hash/hash-map.ts +19 -6
  46. package/src/data-structures/heap/heap.ts +21 -17
  47. package/src/data-structures/heap/max-heap.ts +2 -3
  48. package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
  49. package/src/data-structures/linked-list/singly-linked-list.ts +15 -9
  50. package/src/data-structures/matrix/matrix.ts +9 -10
  51. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -3
  52. package/src/data-structures/queue/deque.ts +72 -4
  53. package/src/data-structures/stack/stack.ts +1 -1
  54. package/src/data-structures/trie/trie.ts +12 -6
  55. package/src/types/data-structures/binary-tree/avl-tree.ts +1 -1
  56. package/src/types/data-structures/binary-tree/red-black-tree.ts +1 -1
  57. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -1
  58. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -1
  59. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  60. package/src/types/data-structures/queue/deque.ts +7 -0
  61. package/src/types/data-structures/stack/stack.ts +1 -1
  62. package/src/utils/utils.ts +4 -2
@@ -191,6 +191,54 @@ var _IterableEntryBase = class _IterableEntryBase {
191
191
  __name(_IterableEntryBase, "IterableEntryBase");
192
192
  var IterableEntryBase = _IterableEntryBase;
193
193
 
194
+ // src/common/error.ts
195
+ var ERR = {
196
+ // Range / index
197
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
198
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
199
+ // Type / argument
200
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
201
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
202
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
203
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
204
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
205
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
206
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
207
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
208
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
209
+ // State / operation
210
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
211
+ // Matrix
212
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
213
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
214
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
215
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
216
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
217
+ };
218
+
219
+ // src/common/index.ts
220
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
221
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
222
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
223
+ return DFSOperation2;
224
+ })(DFSOperation || {});
225
+ var _Range = class _Range {
226
+ constructor(low, high, includeLow = true, includeHigh = true) {
227
+ this.low = low;
228
+ this.high = high;
229
+ this.includeLow = includeLow;
230
+ this.includeHigh = includeHigh;
231
+ }
232
+ // Determine whether a key is within the range
233
+ isInRange(key, comparator) {
234
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
235
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
236
+ return lowCheck && highCheck;
237
+ }
238
+ };
239
+ __name(_Range, "Range");
240
+ var Range = _Range;
241
+
194
242
  // src/data-structures/base/iterable-element-base.ts
195
243
  var _IterableElementBase = class _IterableElementBase {
196
244
  /**
@@ -213,7 +261,7 @@ var _IterableElementBase = class _IterableElementBase {
213
261
  if (options) {
214
262
  const { toElementFn } = options;
215
263
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
216
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
264
+ else if (toElementFn) throw new TypeError(ERR.notAFunction("toElementFn"));
217
265
  }
218
266
  }
219
267
  /**
@@ -369,7 +417,7 @@ var _IterableElementBase = class _IterableElementBase {
369
417
  acc = initialValue;
370
418
  } else {
371
419
  const first = iter.next();
372
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
420
+ if (first.done) throw new TypeError(ERR.reduceEmpty());
373
421
  acc = first.value;
374
422
  index = 1;
375
423
  }
@@ -439,8 +487,10 @@ var getMSB = /* @__PURE__ */ __name((value) => {
439
487
  }
440
488
  return 1 << 31 - Math.clz32(value);
441
489
  }, "getMSB");
442
- var rangeCheck = /* @__PURE__ */ __name((index, min, max, message = "Index out of bounds.") => {
443
- if (index < min || index > max) throw new RangeError(message);
490
+ var rangeCheck = /* @__PURE__ */ __name((index, min, max, message) => {
491
+ if (index < min || index > max) {
492
+ throw new RangeError(message != null ? message : `Index ${index} is out of range [${min}, ${max}].`);
493
+ }
444
494
  }, "rangeCheck");
445
495
  var throwRangeError = /* @__PURE__ */ __name((message = "The value is off-limits.") => {
446
496
  throw new RangeError(message);
@@ -812,8 +862,8 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
812
862
  if (this.isEntry(rawElement)) {
813
863
  return rawElement;
814
864
  }
815
- throw new Error(
816
- "If `entryOrRawElements` does not adhere to [key,value], provide `options.toEntryFn` to transform raw records."
865
+ throw new TypeError(
866
+ ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap")
817
867
  );
818
868
  }, "_toEntryFn"));
819
869
  __publicField(this, "_size", 0);
@@ -1023,8 +1073,9 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
1023
1073
  const cur = node;
1024
1074
  node = node.next;
1025
1075
  if (predicate(cur.key, cur.value, i++, this)) {
1026
- if (isWeakKey(cur.key)) {
1027
- this._objMap.delete(cur.key);
1076
+ const keyToCheck = cur.key;
1077
+ if (isWeakKey(keyToCheck)) {
1078
+ this._objMap.delete(keyToCheck);
1028
1079
  } else {
1029
1080
  const hash = this._hashFn(cur.key);
1030
1081
  delete this._noObjMap[hash];
@@ -1097,6 +1148,13 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
1097
1148
  }
1098
1149
  }
1099
1150
  _deleteNode(node) {
1151
+ const key = node.key;
1152
+ if (isWeakKey(key)) {
1153
+ this._objMap.delete(key);
1154
+ } else {
1155
+ const hash = this._hashFn(key);
1156
+ delete this._noObjMap[hash];
1157
+ }
1100
1158
  const { prev, next } = node;
1101
1159
  prev.next = next;
1102
1160
  next.prev = prev;
@@ -1542,7 +1600,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1542
1600
  */
1543
1601
  constructor(elements = [], options) {
1544
1602
  super(options);
1545
- __publicField(this, "_equals", Object.is);
1603
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
1546
1604
  __publicField(this, "_head");
1547
1605
  __publicField(this, "_tail");
1548
1606
  __publicField(this, "_length", 0);
@@ -1630,6 +1688,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1630
1688
  * @returns Removed element or undefined.
1631
1689
  */
1632
1690
  pop() {
1691
+ var _a;
1633
1692
  if (!this.head) return void 0;
1634
1693
  if (this.head === this.tail) {
1635
1694
  const value2 = this.head.value;
@@ -1639,8 +1698,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1639
1698
  return value2;
1640
1699
  }
1641
1700
  let current = this.head;
1642
- while (current.next !== this.tail) current = current.next;
1643
- const value = this.tail.value;
1701
+ while (current.next && current.next !== this.tail) current = current.next;
1702
+ const value = (_a = this.tail) == null ? void 0 : _a.value;
1644
1703
  current.next = void 0;
1645
1704
  this._tail = current;
1646
1705
  this._length--;
@@ -1728,8 +1787,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1728
1787
  at(index) {
1729
1788
  if (index < 0 || index >= this._length) return void 0;
1730
1789
  let current = this.head;
1731
- for (let i = 0; i < index; i++) current = current.next;
1732
- return current.value;
1790
+ for (let i = 0; i < index && current; i++) current = current.next;
1791
+ return current == null ? void 0 : current.value;
1733
1792
  }
1734
1793
  /**
1735
1794
  * Type guard: check whether the input is a SinglyLinkedListNode.
@@ -1749,7 +1808,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1749
1808
  getNodeAt(index) {
1750
1809
  if (index < 0 || index >= this._length) return void 0;
1751
1810
  let current = this.head;
1752
- for (let i = 0; i < index; i++) current = current.next;
1811
+ for (let i = 0; i < index && current; i++) current = current.next;
1753
1812
  return current;
1754
1813
  }
1755
1814
  /**
@@ -2265,7 +2324,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2265
2324
  */
2266
2325
  constructor(elements = [], options) {
2267
2326
  super(options);
2268
- __publicField(this, "_equals", Object.is);
2327
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2269
2328
  __publicField(this, "_head");
2270
2329
  __publicField(this, "_tail");
2271
2330
  __publicField(this, "_length", 0);
@@ -2453,8 +2512,8 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2453
2512
  at(index) {
2454
2513
  if (index < 0 || index >= this._length) return void 0;
2455
2514
  let current = this.head;
2456
- for (let i = 0; i < index; i++) current = current.next;
2457
- return current.value;
2515
+ for (let i = 0; i < index && current; i++) current = current.next;
2516
+ return current == null ? void 0 : current.value;
2458
2517
  }
2459
2518
  /**
2460
2519
  * Get the node reference at a given index.
@@ -2465,7 +2524,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2465
2524
  getNodeAt(index) {
2466
2525
  if (index < 0 || index >= this._length) return void 0;
2467
2526
  let current = this.head;
2468
- for (let i = 0; i < index; i++) current = current.next;
2527
+ for (let i = 0; i < index && current; i++) current = current.next;
2469
2528
  return current;
2470
2529
  }
2471
2530
  /**
@@ -2977,7 +3036,7 @@ var _Stack = class _Stack extends IterableElementBase {
2977
3036
  */
2978
3037
  constructor(elements = [], options) {
2979
3038
  super(options);
2980
- __publicField(this, "_equals", Object.is);
3039
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2981
3040
  __publicField(this, "_elements", []);
2982
3041
  this.pushMany(elements);
2983
3042
  }
@@ -3603,17 +3662,16 @@ var LinkedListQueue = _LinkedListQueue;
3603
3662
 
3604
3663
  // src/data-structures/queue/deque.ts
3605
3664
  var _Deque = class _Deque extends LinearBase {
3606
- /**
3607
- * Create a Deque and optionally bulk-insert elements.
3608
- * @remarks Time O(N), Space O(N)
3609
- * @param [elements] - Iterable (or iterable-like) of elements/records to insert.
3610
- * @param [options] - Options such as bucketSize, toElementFn, and maxLen.
3611
- * @returns New Deque instance.
3612
- */
3613
3665
  constructor(elements = [], options) {
3614
3666
  super(options);
3615
- __publicField(this, "_equals", Object.is);
3667
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
3616
3668
  __publicField(this, "_bucketSize", 1 << 12);
3669
+ __publicField(this, "_autoCompactRatio", 0.5);
3670
+ /**
3671
+ * Counter for shift/pop operations since last compaction check.
3672
+ * Only checks ratio every `_bucketSize` operations to minimize overhead.
3673
+ */
3674
+ __publicField(this, "_compactCounter", 0);
3617
3675
  __publicField(this, "_bucketFirst", 0);
3618
3676
  __publicField(this, "_firstInBucket", 0);
3619
3677
  __publicField(this, "_bucketLast", 0);
@@ -3622,8 +3680,9 @@ var _Deque = class _Deque extends LinearBase {
3622
3680
  __publicField(this, "_buckets", []);
3623
3681
  __publicField(this, "_length", 0);
3624
3682
  if (options) {
3625
- const { bucketSize } = options;
3683
+ const { bucketSize, autoCompactRatio } = options;
3626
3684
  if (typeof bucketSize === "number") this._bucketSize = bucketSize;
3685
+ if (typeof autoCompactRatio === "number") this._autoCompactRatio = autoCompactRatio;
3627
3686
  }
3628
3687
  let _size;
3629
3688
  if ("length" in elements) {
@@ -3648,6 +3707,24 @@ var _Deque = class _Deque extends LinearBase {
3648
3707
  get bucketSize() {
3649
3708
  return this._bucketSize;
3650
3709
  }
3710
+ /**
3711
+ * Get the auto-compaction ratio.
3712
+ * When `elements / (bucketCount * bucketSize)` drops below this ratio after
3713
+ * enough shift/pop operations, the deque auto-compacts.
3714
+ * @remarks Time O(1), Space O(1)
3715
+ * @returns Current ratio threshold. 0 means auto-compact is disabled.
3716
+ */
3717
+ get autoCompactRatio() {
3718
+ return this._autoCompactRatio;
3719
+ }
3720
+ /**
3721
+ * Set the auto-compaction ratio.
3722
+ * @remarks Time O(1), Space O(1)
3723
+ * @param value - Ratio in [0,1]. 0 disables auto-compact.
3724
+ */
3725
+ set autoCompactRatio(value) {
3726
+ this._autoCompactRatio = value;
3727
+ }
3651
3728
  /**
3652
3729
  * Get the index of the first bucket in use.
3653
3730
  * @remarks Time O(1), Space O(1)
@@ -3779,6 +3856,7 @@ var _Deque = class _Deque extends LinearBase {
3779
3856
  }
3780
3857
  }
3781
3858
  this._length -= 1;
3859
+ this._autoCompact();
3782
3860
  return element;
3783
3861
  }
3784
3862
  /**
@@ -3801,6 +3879,7 @@ var _Deque = class _Deque extends LinearBase {
3801
3879
  }
3802
3880
  }
3803
3881
  this._length -= 1;
3882
+ this._autoCompact();
3804
3883
  return element;
3805
3884
  }
3806
3885
  /**
@@ -4133,11 +4212,40 @@ var _Deque = class _Deque extends LinearBase {
4133
4212
  * @remarks Time O(N), Space O(1)
4134
4213
  * @returns void
4135
4214
  */
4215
+ /**
4216
+ * (Protected) Trigger auto-compaction if space utilization drops below threshold.
4217
+ * Only checks every `_bucketSize` operations to minimize hot-path overhead.
4218
+ * Uses element-based ratio: `elements / (bucketCount * bucketSize)`.
4219
+ */
4220
+ _autoCompact() {
4221
+ if (this._autoCompactRatio <= 0 || this._bucketCount <= 1) return;
4222
+ this._compactCounter++;
4223
+ if (this._compactCounter < this._bucketSize) return;
4224
+ this._compactCounter = 0;
4225
+ const utilization = this._length / (this._bucketCount * this._bucketSize);
4226
+ if (utilization < this._autoCompactRatio) {
4227
+ this.shrinkToFit();
4228
+ }
4229
+ }
4230
+ /**
4231
+ * Compact the deque by removing unused buckets.
4232
+ * @remarks Time O(N), Space O(1)
4233
+ * @returns True if compaction was performed (bucket count reduced).
4234
+ */
4235
+ /**
4236
+ * Compact the deque by removing unused buckets.
4237
+ * @remarks Time O(N), Space O(1)
4238
+ * @returns True if compaction was performed (bucket count reduced).
4239
+ */
4240
+ compact() {
4241
+ const before = this._bucketCount;
4242
+ this.shrinkToFit();
4243
+ return this._bucketCount < before;
4244
+ }
4136
4245
  shrinkToFit() {
4137
4246
  if (this._length === 0) return;
4138
4247
  const newBuckets = [];
4139
- if (this._bucketFirst === this._bucketLast) return;
4140
- else if (this._bucketFirst < this._bucketLast) {
4248
+ if (this._bucketFirst <= this._bucketLast) {
4141
4249
  for (let i = this._bucketFirst; i <= this._bucketLast; ++i) {
4142
4250
  newBuckets.push(this._buckets[i]);
4143
4251
  }
@@ -4152,6 +4260,8 @@ var _Deque = class _Deque extends LinearBase {
4152
4260
  this._bucketFirst = 0;
4153
4261
  this._bucketLast = newBuckets.length - 1;
4154
4262
  this._buckets = newBuckets;
4263
+ this._bucketCount = newBuckets.length;
4264
+ this._compactCounter = 0;
4155
4265
  }
4156
4266
  /**
4157
4267
  * Deep clone this deque, preserving options.
@@ -4349,7 +4459,7 @@ var _Heap = class _Heap extends IterableElementBase {
4349
4459
  __publicField(this, "_elements", []);
4350
4460
  __publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
4351
4461
  if (typeof a === "object" || typeof b === "object") {
4352
- throw TypeError("When comparing object types, define a custom comparator in options.");
4462
+ throw new TypeError(ERR.comparatorRequired("Heap"));
4353
4463
  }
4354
4464
  if (a > b) return 1;
4355
4465
  if (a < b) return -1;
@@ -4659,7 +4769,7 @@ var _Heap = class _Heap extends IterableElementBase {
4659
4769
  */
4660
4770
  map(callback, options, thisArg) {
4661
4771
  const { comparator, toElementFn, ...rest } = options != null ? options : {};
4662
- if (!comparator) throw new TypeError("Heap.map requires options.comparator for EM");
4772
+ if (!comparator) throw new TypeError(ERR.comparatorRequired("Heap.map"));
4663
4773
  const out = this._createLike([], { ...rest, comparator, toElementFn });
4664
4774
  let i = 0;
4665
4775
  for (const x of this) {
@@ -4684,11 +4794,6 @@ var _Heap = class _Heap extends IterableElementBase {
4684
4794
  }
4685
4795
  return out;
4686
4796
  }
4687
- /**
4688
- * Get the comparator used to order elements.
4689
- * @remarks Time O(1), Space O(1)
4690
- * @returns Comparator function.
4691
- */
4692
4797
  /**
4693
4798
  * Get the comparator used to order elements.
4694
4799
  * @remarks Time O(1), Space O(1)
@@ -4737,8 +4842,7 @@ var _Heap = class _Heap extends IterableElementBase {
4737
4842
  */
4738
4843
  _createInstance(options) {
4739
4844
  const Ctor = this.constructor;
4740
- const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
4741
- return next;
4845
+ return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
4742
4846
  }
4743
4847
  /**
4744
4848
  * (Protected) Create a like-kind instance seeded by elements.
@@ -4797,7 +4901,7 @@ var _FibonacciHeap = class _FibonacciHeap {
4797
4901
  __publicField(this, "_comparator");
4798
4902
  this.clear();
4799
4903
  this._comparator = comparator || this._defaultComparator;
4800
- if (typeof this.comparator !== "function") throw new Error("FibonacciHeap: comparator must be a function.");
4904
+ if (typeof this.comparator !== "function") throw new TypeError(ERR.notAFunction("comparator", "FibonacciHeap"));
4801
4905
  }
4802
4906
  /**
4803
4907
  * Get the circular root list head.
@@ -5008,9 +5112,7 @@ var _MaxHeap = class _MaxHeap extends Heap {
5008
5112
  super(elements, {
5009
5113
  comparator: /* @__PURE__ */ __name((a, b) => {
5010
5114
  if (typeof a === "object" || typeof b === "object") {
5011
- throw TypeError(
5012
- `When comparing object types, a custom comparator must be defined in the constructor's options parameter.`
5013
- );
5115
+ throw new TypeError(ERR.comparatorRequired("MaxHeap"));
5014
5116
  }
5015
5117
  if (a < b) return 1;
5016
5118
  if (a > b) return -1;
@@ -5175,7 +5277,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
5175
5277
  const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
5176
5278
  return this._addEdge(newEdge);
5177
5279
  } else {
5178
- throw new Error("dest must be a Vertex or vertex key while srcOrEdge is an Edge");
5280
+ throw new TypeError(ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
5179
5281
  }
5180
5282
  }
5181
5283
  }
@@ -5784,8 +5886,8 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
5784
5886
  const Ctor = this.constructor;
5785
5887
  const instance = new Ctor();
5786
5888
  const graph = _options == null ? void 0 : _options.graph;
5787
- if (graph) instance._options = { ...instance._options, ...graph };
5788
- else instance._options = { ...instance._options, ...this._options };
5889
+ if (graph) instance["_options"] = { ...instance["_options"], ...graph };
5890
+ else instance["_options"] = { ...instance["_options"], ...this._options };
5789
5891
  return instance;
5790
5892
  }
5791
5893
  /**
@@ -5818,12 +5920,10 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
5818
5920
  const [va, vb] = ends;
5819
5921
  const ka = va.key;
5820
5922
  const kb = vb.key;
5821
- const hasA = g.hasVertex ? g.hasVertex(ka) : false;
5822
- const hasB = g.hasVertex ? g.hasVertex(kb) : false;
5923
+ const hasA = typeof g.hasVertex === "function" ? g.hasVertex(ka) : false;
5924
+ const hasB = typeof g.hasVertex === "function" ? g.hasVertex(kb) : false;
5823
5925
  if (hasA && hasB) {
5824
- const w = e.weight;
5825
- const val = e.value;
5826
- const newEdge = g.createEdge(ka, kb, w, val);
5926
+ const newEdge = g.createEdge(ka, kb, e.weight, e.value);
5827
5927
  g._addEdge(newEdge);
5828
5928
  }
5829
5929
  }
@@ -5861,6 +5961,94 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
5861
5961
  _getVertexKey(vertexOrKey) {
5862
5962
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
5863
5963
  }
5964
+ /**
5965
+ * The edge connector string used in visual output.
5966
+ * Override in subclasses (e.g., '--' for undirected, '->' for directed).
5967
+ */
5968
+ get _edgeConnector() {
5969
+ return "--";
5970
+ }
5971
+ /**
5972
+ * Generate a text-based visual representation of the graph.
5973
+ *
5974
+ * **Adjacency list format:**
5975
+ * ```
5976
+ * Graph (5 vertices, 6 edges):
5977
+ * A -> B (1), C (2)
5978
+ * B -> D (3)
5979
+ * C -> (no outgoing edges)
5980
+ * D -> A (1)
5981
+ * E (isolated)
5982
+ * ```
5983
+ *
5984
+ * @param options - Optional display settings.
5985
+ * @param options.showWeight - Whether to show edge weights (default: true).
5986
+ * @returns The visual string.
5987
+ */
5988
+ toVisual(options) {
5989
+ var _a;
5990
+ const showWeight = (_a = options == null ? void 0 : options.showWeight) != null ? _a : true;
5991
+ const vertices = [...this._vertexMap.values()];
5992
+ const vertexCount = vertices.length;
5993
+ const edgeCount = this.edgeSet().length;
5994
+ const lines = [`Graph (${vertexCount} vertices, ${edgeCount} edges):`];
5995
+ for (const vertex of vertices) {
5996
+ const neighbors = this.getNeighbors(vertex);
5997
+ if (neighbors.length === 0) {
5998
+ lines.push(` ${vertex.key} (isolated)`);
5999
+ } else {
6000
+ const edgeStrs = neighbors.map((neighbor) => {
6001
+ const edge = this.getEdge(vertex, neighbor);
6002
+ if (edge && showWeight && edge.weight !== void 0 && edge.weight !== 1) {
6003
+ return `${neighbor.key} (${edge.weight})`;
6004
+ }
6005
+ return `${neighbor.key}`;
6006
+ });
6007
+ lines.push(` ${vertex.key} ${this._edgeConnector} ${edgeStrs.join(", ")}`);
6008
+ }
6009
+ }
6010
+ return lines.join("\n");
6011
+ }
6012
+ /**
6013
+ * Generate DOT language representation for Graphviz.
6014
+ *
6015
+ * @param options - Optional display settings.
6016
+ * @param options.name - Graph name (default: 'G').
6017
+ * @param options.showWeight - Whether to label edges with weight (default: true).
6018
+ * @returns DOT format string.
6019
+ */
6020
+ toDot(options) {
6021
+ var _a, _b;
6022
+ const name = (_a = options == null ? void 0 : options.name) != null ? _a : "G";
6023
+ const showWeight = (_b = options == null ? void 0 : options.showWeight) != null ? _b : true;
6024
+ const isDirected = this._edgeConnector === "->";
6025
+ const graphType = isDirected ? "digraph" : "graph";
6026
+ const edgeOp = isDirected ? "->" : "--";
6027
+ const lines = [`${graphType} ${name} {`];
6028
+ for (const vertex of this._vertexMap.values()) {
6029
+ lines.push(` "${vertex.key}";`);
6030
+ }
6031
+ const visited = /* @__PURE__ */ new Set();
6032
+ for (const vertex of this._vertexMap.values()) {
6033
+ for (const neighbor of this.getNeighbors(vertex)) {
6034
+ const edgeId = isDirected ? `${vertex.key}->${neighbor.key}` : [vertex.key, neighbor.key].sort().join("--");
6035
+ if (visited.has(edgeId)) continue;
6036
+ visited.add(edgeId);
6037
+ const edge = this.getEdge(vertex, neighbor);
6038
+ const label = edge && showWeight && edge.weight !== void 0 && edge.weight !== 1 ? ` [label="${edge.weight}"]` : "";
6039
+ lines.push(` "${vertex.key}" ${edgeOp} "${neighbor.key}"${label};`);
6040
+ }
6041
+ }
6042
+ lines.push("}");
6043
+ return lines.join("\n");
6044
+ }
6045
+ /**
6046
+ * Print the graph to console.
6047
+ * @param options - Display settings passed to `toVisual`.
6048
+ */
6049
+ print(options) {
6050
+ console.log(this.toVisual(options));
6051
+ }
5864
6052
  };
5865
6053
  __name(_AbstractGraph, "AbstractGraph");
5866
6054
  var AbstractGraph = _AbstractGraph;
@@ -5895,6 +6083,9 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
5895
6083
  __publicField(this, "_outEdgeMap", /* @__PURE__ */ new Map());
5896
6084
  __publicField(this, "_inEdgeMap", /* @__PURE__ */ new Map());
5897
6085
  }
6086
+ get _edgeConnector() {
6087
+ return "->";
6088
+ }
5898
6089
  get outEdgeMap() {
5899
6090
  return this._outEdgeMap;
5900
6091
  }
@@ -6675,6 +6866,84 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
6675
6866
  cutVertices
6676
6867
  };
6677
6868
  }
6869
+ /**
6870
+ * Find biconnected components using edge-stack Tarjan variant.
6871
+ * A biconnected component is a maximal biconnected subgraph.
6872
+ * @returns Array of edge arrays, each representing a biconnected component.
6873
+ * @remarks Time O(V + E), Space O(V + E)
6874
+ */
6875
+ getBiconnectedComponents() {
6876
+ const dfn = /* @__PURE__ */ new Map();
6877
+ const low = /* @__PURE__ */ new Map();
6878
+ const edgeStack = [];
6879
+ const components = [];
6880
+ let time = 0;
6881
+ const dfs = /* @__PURE__ */ __name((vertex, parent) => {
6882
+ dfn.set(vertex, time);
6883
+ low.set(vertex, time);
6884
+ time++;
6885
+ const neighbors = this.getNeighbors(vertex);
6886
+ let childCount = 0;
6887
+ for (const neighbor of neighbors) {
6888
+ const edge = this.getEdge(vertex, neighbor);
6889
+ if (!edge) continue;
6890
+ if (!dfn.has(neighbor)) {
6891
+ childCount++;
6892
+ edgeStack.push(edge);
6893
+ dfs(neighbor, vertex);
6894
+ low.set(vertex, Math.min(low.get(vertex), low.get(neighbor)));
6895
+ if (parent === void 0 && childCount > 1 || parent !== void 0 && low.get(neighbor) >= dfn.get(vertex)) {
6896
+ const component = [];
6897
+ let e;
6898
+ do {
6899
+ e = edgeStack.pop();
6900
+ if (e) component.push(e);
6901
+ } while (e && e !== edge);
6902
+ if (component.length > 0) components.push(component);
6903
+ }
6904
+ } else if (neighbor !== parent && dfn.get(neighbor) < dfn.get(vertex)) {
6905
+ edgeStack.push(edge);
6906
+ low.set(vertex, Math.min(low.get(vertex), dfn.get(neighbor)));
6907
+ }
6908
+ }
6909
+ }, "dfs");
6910
+ for (const vertex of this.vertexMap.values()) {
6911
+ if (!dfn.has(vertex)) {
6912
+ dfs(vertex, void 0);
6913
+ if (edgeStack.length > 0) {
6914
+ components.push([...edgeStack]);
6915
+ edgeStack.length = 0;
6916
+ }
6917
+ }
6918
+ }
6919
+ return components;
6920
+ }
6921
+ /**
6922
+ * Detect whether the graph contains a cycle.
6923
+ * Uses DFS with parent tracking.
6924
+ * @returns `true` if a cycle exists, `false` otherwise.
6925
+ * @remarks Time O(V + E), Space O(V)
6926
+ */
6927
+ hasCycle() {
6928
+ const visited = /* @__PURE__ */ new Set();
6929
+ const dfs = /* @__PURE__ */ __name((vertex, parent) => {
6930
+ visited.add(vertex);
6931
+ for (const neighbor of this.getNeighbors(vertex)) {
6932
+ if (!visited.has(neighbor)) {
6933
+ if (dfs(neighbor, vertex)) return true;
6934
+ } else if (neighbor !== parent) {
6935
+ return true;
6936
+ }
6937
+ }
6938
+ return false;
6939
+ }, "dfs");
6940
+ for (const vertex of this.vertexMap.values()) {
6941
+ if (!visited.has(vertex)) {
6942
+ if (dfs(vertex, void 0)) return true;
6943
+ }
6944
+ }
6945
+ return false;
6946
+ }
6678
6947
  /**
6679
6948
  * Get bridges discovered by `tarjan()`.
6680
6949
  * @returns Array of edges that are bridges.
@@ -6827,29 +7096,6 @@ var _MapGraph = class _MapGraph extends DirectedGraph {
6827
7096
  __name(_MapGraph, "MapGraph");
6828
7097
  var MapGraph = _MapGraph;
6829
7098
 
6830
- // src/common/index.ts
6831
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
6832
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
6833
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
6834
- return DFSOperation2;
6835
- })(DFSOperation || {});
6836
- var _Range = class _Range {
6837
- constructor(low, high, includeLow = true, includeHigh = true) {
6838
- this.low = low;
6839
- this.high = high;
6840
- this.includeLow = includeLow;
6841
- this.includeHigh = includeHigh;
6842
- }
6843
- // Determine whether a key is within the range
6844
- isInRange(key, comparator) {
6845
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
6846
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
6847
- return lowCheck && highCheck;
6848
- }
6849
- };
6850
- __name(_Range, "Range");
6851
- var Range = _Range;
6852
-
6853
7099
  // src/data-structures/binary-tree/binary-tree.ts
6854
7100
  var _BinaryTreeNode = class _BinaryTreeNode {
6855
7101
  /**
@@ -7015,14 +7261,14 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7015
7261
  * @param node - The node.
7016
7262
  * @returns The node's key or undefined.
7017
7263
  */
7018
- __publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node ? node.key : void 0, "_DEFAULT_NODE_CALLBACK"));
7264
+ __publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node == null ? void 0 : node.key, "_DEFAULT_NODE_CALLBACK"));
7019
7265
  if (options) {
7020
7266
  const { iterationType, toEntryFn, isMapMode, isDuplicate } = options;
7021
7267
  if (iterationType) this.iterationType = iterationType;
7022
7268
  if (isMapMode !== void 0) this._isMapMode = isMapMode;
7023
7269
  if (isDuplicate !== void 0) this._isDuplicate = isDuplicate;
7024
7270
  if (typeof toEntryFn === "function") this._toEntryFn = toEntryFn;
7025
- else if (toEntryFn) throw TypeError("toEntryFn must be a function type");
7271
+ else if (toEntryFn) throw new TypeError(ERR.notAFunction("toEntryFn", "BinaryTree"));
7026
7272
  }
7027
7273
  if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
7028
7274
  }
@@ -7250,7 +7496,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7250
7496
  if (!this._root) {
7251
7497
  this._setRoot(newNode);
7252
7498
  if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7253
- this._size = 1;
7499
+ if (newNode !== null) this._size = 1;
7254
7500
  return true;
7255
7501
  }
7256
7502
  const queue = new Queue([this._root]);
@@ -7282,7 +7528,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7282
7528
  potentialParent.right = newNode;
7283
7529
  }
7284
7530
  if (this._isMapMode && newNode !== null && newNode !== void 0) this._store.set(newNode.key, newNode);
7285
- this._size++;
7531
+ if (newNode !== null) this._size++;
7286
7532
  return true;
7287
7533
  }
7288
7534
  return false;
@@ -7851,7 +8097,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7851
8097
  }
7852
8098
  /**
7853
8099
  * Finds all leaf nodes in the tree.
7854
- * @remarks Time O(N), visits every node. Space O(H) for recursive stack or O(N) for iterative queue.
8100
+ * @remarks Time O(N), visits every node. Space O(H) for recursive or iterative stack.
7855
8101
  *
7856
8102
  * @template C - The type of the callback function.
7857
8103
  * @param [callback=this._DEFAULT_NODE_CALLBACK] - Function to call on each leaf node.
@@ -7874,15 +8120,15 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7874
8120
  }, "dfs");
7875
8121
  dfs(startNode);
7876
8122
  } else {
7877
- const queue = new Queue([startNode]);
7878
- while (queue.length > 0) {
7879
- const cur = queue.shift();
8123
+ const stack = [startNode];
8124
+ while (stack.length > 0) {
8125
+ const cur = stack.pop();
7880
8126
  if (this.isRealNode(cur)) {
7881
8127
  if (this.isLeaf(cur)) {
7882
8128
  leaves.push(callback(cur));
7883
8129
  }
7884
- if (this.isRealNode(cur.left)) queue.push(cur.left);
7885
- if (this.isRealNode(cur.right)) queue.push(cur.right);
8130
+ if (this.isRealNode(cur.right)) stack.push(cur.right);
8131
+ if (this.isRealNode(cur.left)) stack.push(cur.left);
7886
8132
  }
7887
8133
  }
7888
8134
  }
@@ -8338,42 +8584,98 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
8338
8584
  _displayAux(node, options) {
8339
8585
  const { isShowNull, isShowUndefined, isShowRedBlackNIL } = options;
8340
8586
  const emptyDisplayLayout = [["\u2500"], 1, 0, 0];
8341
- if (node === null && !isShowNull) {
8342
- return emptyDisplayLayout;
8343
- } else if (node === void 0 && !isShowUndefined) {
8344
- return emptyDisplayLayout;
8345
- } else if (this.isNIL(node) && !isShowRedBlackNIL) {
8346
- return emptyDisplayLayout;
8347
- } else if (node !== null && node !== void 0) {
8348
- const key = node.key, line = this.isNIL(node) ? "S" : String(key), width = line.length;
8349
- return _buildNodeDisplay(
8350
- line,
8351
- width,
8352
- this._displayAux(node.left, options),
8353
- this._displayAux(node.right, options)
8354
- );
8355
- } else {
8356
- const line = node === void 0 ? "U" : "N", width = line.length;
8357
- return _buildNodeDisplay(line, width, [[""], 1, 0, 0], [[""], 1, 0, 0]);
8358
- }
8359
- function _buildNodeDisplay(line, width, left, right) {
8360
- const [leftLines, leftWidth, leftHeight, leftMiddle] = left;
8361
- const [rightLines, rightWidth, rightHeight, rightMiddle] = right;
8362
- const firstLine = " ".repeat(Math.max(0, leftMiddle + 1)) + "_".repeat(Math.max(0, leftWidth - leftMiddle - 1)) + line + "_".repeat(Math.max(0, rightMiddle)) + " ".repeat(Math.max(0, rightWidth - rightMiddle));
8363
- const secondLine = (leftHeight > 0 ? " ".repeat(leftMiddle) + "/" + " ".repeat(leftWidth - leftMiddle - 1) : " ".repeat(leftWidth)) + " ".repeat(width) + (rightHeight > 0 ? " ".repeat(rightMiddle) + "\\" + " ".repeat(rightWidth - rightMiddle - 1) : " ".repeat(rightWidth));
8364
- const mergedLines = [firstLine, secondLine];
8365
- for (let i = 0; i < Math.max(leftHeight, rightHeight); i++) {
8366
- const leftLine = i < leftHeight ? leftLines[i] : " ".repeat(leftWidth);
8367
- const rightLine = i < rightHeight ? rightLines[i] : " ".repeat(rightWidth);
8368
- mergedLines.push(leftLine + " ".repeat(width) + rightLine);
8587
+ const newFrame = /* @__PURE__ */ __name((n) => ({
8588
+ node: n,
8589
+ stage: 0,
8590
+ leftLayout: emptyDisplayLayout,
8591
+ rightLayout: emptyDisplayLayout
8592
+ }), "newFrame");
8593
+ const stack = [newFrame(node)];
8594
+ let result = emptyDisplayLayout;
8595
+ const setChildResult = /* @__PURE__ */ __name((layout) => {
8596
+ if (stack.length === 0) {
8597
+ result = layout;
8598
+ return;
8369
8599
  }
8370
- return [
8371
- mergedLines,
8372
- leftWidth + width + rightWidth,
8373
- Math.max(leftHeight, rightHeight) + 2,
8374
- leftWidth + Math.floor(width / 2)
8375
- ];
8600
+ const parent = stack[stack.length - 1];
8601
+ if (parent.stage === 1) parent.leftLayout = layout;
8602
+ else parent.rightLayout = layout;
8603
+ }, "setChildResult");
8604
+ while (stack.length > 0) {
8605
+ const frame = stack[stack.length - 1];
8606
+ const cur = frame.node;
8607
+ if (frame.stage === 0) {
8608
+ if (this._isDisplayLeaf(cur, options)) {
8609
+ stack.pop();
8610
+ const layout = this._resolveDisplayLeaf(cur, options, emptyDisplayLayout);
8611
+ setChildResult(layout);
8612
+ continue;
8613
+ }
8614
+ frame.stage = 1;
8615
+ stack.push(newFrame(cur.left));
8616
+ } else if (frame.stage === 1) {
8617
+ frame.stage = 2;
8618
+ stack.push(newFrame(cur.right));
8619
+ } else {
8620
+ stack.pop();
8621
+ const line = this.isNIL(cur) ? "S" : String(cur.key);
8622
+ const layout = _BinaryTree._buildNodeDisplay(line, line.length, frame.leftLayout, frame.rightLayout);
8623
+ setChildResult(layout);
8624
+ }
8625
+ }
8626
+ return result;
8627
+ }
8628
+ static _buildNodeDisplay(line, width, left, right) {
8629
+ const [leftLines, leftWidth, leftHeight, leftMiddle] = left;
8630
+ const [rightLines, rightWidth, rightHeight, rightMiddle] = right;
8631
+ const firstLine = " ".repeat(Math.max(0, leftMiddle + 1)) + "_".repeat(Math.max(0, leftWidth - leftMiddle - 1)) + line + "_".repeat(Math.max(0, rightMiddle)) + " ".repeat(Math.max(0, rightWidth - rightMiddle));
8632
+ const secondLine = (leftHeight > 0 ? " ".repeat(leftMiddle) + "/" + " ".repeat(leftWidth - leftMiddle - 1) : " ".repeat(leftWidth)) + " ".repeat(width) + (rightHeight > 0 ? " ".repeat(rightMiddle) + "\\" + " ".repeat(rightWidth - rightMiddle - 1) : " ".repeat(rightWidth));
8633
+ const mergedLines = [firstLine, secondLine];
8634
+ for (let i = 0; i < Math.max(leftHeight, rightHeight); i++) {
8635
+ const leftLine = i < leftHeight ? leftLines[i] : " ".repeat(leftWidth);
8636
+ const rightLine = i < rightHeight ? rightLines[i] : " ".repeat(rightWidth);
8637
+ mergedLines.push(leftLine + " ".repeat(width) + rightLine);
8376
8638
  }
8639
+ return [
8640
+ mergedLines,
8641
+ leftWidth + width + rightWidth,
8642
+ Math.max(leftHeight, rightHeight) + 2,
8643
+ leftWidth + Math.floor(width / 2)
8644
+ ];
8645
+ }
8646
+ /**
8647
+ * Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
8648
+ */
8649
+ _isDisplayLeaf(node, options) {
8650
+ const { isShowNull, isShowUndefined, isShowRedBlackNIL } = options;
8651
+ if (node === null && !isShowNull) return true;
8652
+ if (node === void 0 && !isShowUndefined) return true;
8653
+ if (this.isNIL(node) && !isShowRedBlackNIL) return true;
8654
+ if (node === null || node === void 0) return true;
8655
+ const hasDisplayableLeft = this._hasDisplayableChild(node.left, options);
8656
+ const hasDisplayableRight = this._hasDisplayableChild(node.right, options);
8657
+ return !hasDisplayableLeft && !hasDisplayableRight;
8658
+ }
8659
+ _hasDisplayableChild(child, options) {
8660
+ if (child === null) return !!options.isShowNull;
8661
+ if (child === void 0) return !!options.isShowUndefined;
8662
+ if (this.isNIL(child)) return !!options.isShowRedBlackNIL;
8663
+ return true;
8664
+ }
8665
+ /**
8666
+ * Resolve a display leaf node to its layout.
8667
+ */
8668
+ _resolveDisplayLeaf(node, options, emptyDisplayLayout) {
8669
+ const { isShowNull, isShowUndefined, isShowRedBlackNIL } = options;
8670
+ if (node === null && !isShowNull) return emptyDisplayLayout;
8671
+ if (node === void 0 && !isShowUndefined) return emptyDisplayLayout;
8672
+ if (this.isNIL(node) && !isShowRedBlackNIL) return emptyDisplayLayout;
8673
+ if (node !== null && node !== void 0) {
8674
+ const line2 = this.isNIL(node) ? "S" : String(node.key);
8675
+ return _BinaryTree._buildNodeDisplay(line2, line2.length, emptyDisplayLayout, emptyDisplayLayout);
8676
+ }
8677
+ const line = node === void 0 ? "U" : "N";
8678
+ return _BinaryTree._buildNodeDisplay(line, line.length, [[""], 1, 0, 0], [[""], 1, 0, 0]);
8377
8679
  }
8378
8680
  /**
8379
8681
  * (Protected) Swaps the key/value properties of two nodes.
@@ -9379,9 +9681,15 @@ var _BST = class _BST extends BinaryTree {
9379
9681
  if (a < b) return -1;
9380
9682
  return 0;
9381
9683
  }
9684
+ if (a instanceof Date && b instanceof Date) {
9685
+ const ta = a.getTime();
9686
+ const tb = b.getTime();
9687
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(ERR.invalidDate("BST"));
9688
+ return ta > tb ? 1 : ta < tb ? -1 : 0;
9689
+ }
9382
9690
  if (typeof a === "object" || typeof b === "object") {
9383
- throw TypeError(
9384
- `When comparing object type keys, a custom comparator must be provided in the constructor's options!`
9691
+ throw new TypeError(
9692
+ ERR.comparatorRequired("BST")
9385
9693
  );
9386
9694
  }
9387
9695
  return 0;
@@ -9895,7 +10203,7 @@ var _BinaryIndexedTree = class _BinaryIndexedTree {
9895
10203
  */
9896
10204
  read(count) {
9897
10205
  if (!Number.isInteger(count)) {
9898
- throw new Error("Invalid count");
10206
+ throw new Error(ERR.invalidArgument("count must be an integer", "BinaryIndexedTree"));
9899
10207
  }
9900
10208
  return this._read(Math.max(Math.min(count, this.max), 0));
9901
10209
  }
@@ -9907,7 +10215,7 @@ var _BinaryIndexedTree = class _BinaryIndexedTree {
9907
10215
  */
9908
10216
  lowerBound(sum) {
9909
10217
  if (this.negativeCount > 0) {
9910
- throw new Error("Sequence is not non-descending");
10218
+ throw new Error(ERR.invalidOperation("Sequence is not non-descending.", "BinaryIndexedTree"));
9911
10219
  }
9912
10220
  return this._binarySearch(sum, (x, y) => x < y);
9913
10221
  }
@@ -9920,7 +10228,7 @@ var _BinaryIndexedTree = class _BinaryIndexedTree {
9920
10228
  */
9921
10229
  upperBound(sum) {
9922
10230
  if (this.negativeCount > 0) {
9923
- throw new Error("Must not be descending");
10231
+ throw new Error(ERR.invalidOperation("Sequence must not be descending.", "BinaryIndexedTree"));
9924
10232
  }
9925
10233
  return this._binarySearch(sum, (x, y) => x <= y);
9926
10234
  }
@@ -9971,10 +10279,10 @@ var _BinaryIndexedTree = class _BinaryIndexedTree {
9971
10279
  */
9972
10280
  _checkIndex(index) {
9973
10281
  if (!Number.isInteger(index)) {
9974
- throw new Error("Invalid index: Index must be an integer.");
10282
+ throw new TypeError(ERR.invalidIndex("BinaryIndexedTree"));
9975
10283
  }
9976
10284
  if (index < 0 || index >= this.max) {
9977
- throw new Error("Index out of range: Index must be within the range [0, this.max).");
10285
+ throw new RangeError(ERR.indexOutOfRange(index, 0, this.max - 1, "BinaryIndexedTree"));
9978
10286
  }
9979
10287
  }
9980
10288
  /**
@@ -11563,6 +11871,24 @@ var _RedBlackTree = class _RedBlackTree extends BST {
11563
11871
  * @param [thisArg] - See parameter type for details.
11564
11872
  * @returns A new RedBlackTree with mapped entries.
11565
11873
  */
11874
+ /**
11875
+ * Red-Black trees are self-balancing — `perfectlyBalance` rebuilds via
11876
+ * sorted bulk insert, which naturally produces a balanced RBT.
11877
+ * @remarks Time O(N), Space O(N)
11878
+ */
11879
+ perfectlyBalance(iterationType) {
11880
+ const entries = [];
11881
+ for (const [key, value] of this) entries.push([key, value]);
11882
+ if (entries.length <= 1) return true;
11883
+ this.clear();
11884
+ this.setMany(
11885
+ entries.map(([k]) => k),
11886
+ entries.map(([, v]) => v),
11887
+ true
11888
+ // isBalanceAdd
11889
+ );
11890
+ return true;
11891
+ }
11566
11892
  map(callback, options, thisArg) {
11567
11893
  const out = this._createLike([], options);
11568
11894
  let index = 0;
@@ -11887,7 +12213,7 @@ var _TreeSet = class _TreeSet {
11887
12213
  static createDefaultComparator() {
11888
12214
  return (a, b) => {
11889
12215
  if (typeof a === "number" && typeof b === "number") {
11890
- if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError("TreeSet: NaN is not a valid key");
12216
+ if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(ERR.invalidNaN("TreeSet"));
11891
12217
  const aa = Object.is(a, -0) ? 0 : a;
11892
12218
  const bb = Object.is(b, -0) ? 0 : b;
11893
12219
  return aa > bb ? 1 : aa < bb ? -1 : 0;
@@ -11898,10 +12224,10 @@ var _TreeSet = class _TreeSet {
11898
12224
  if (a instanceof Date && b instanceof Date) {
11899
12225
  const ta = a.getTime();
11900
12226
  const tb = b.getTime();
11901
- if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError("TreeSet: invalid Date key");
12227
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(ERR.invalidDate("TreeSet"));
11902
12228
  return ta > tb ? 1 : ta < tb ? -1 : 0;
11903
12229
  }
11904
- throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
12230
+ throw new TypeError(ERR.comparatorRequired("TreeSet"));
11905
12231
  };
11906
12232
  }
11907
12233
  /**
@@ -11919,15 +12245,15 @@ var _TreeSet = class _TreeSet {
11919
12245
  _validateKey(key) {
11920
12246
  if (!__privateGet(this, _isDefaultComparator)) return;
11921
12247
  if (typeof key === "number") {
11922
- if (Number.isNaN(key)) throw new TypeError("TreeSet: NaN is not a valid key");
12248
+ if (Number.isNaN(key)) throw new TypeError(ERR.invalidNaN("TreeSet"));
11923
12249
  return;
11924
12250
  }
11925
12251
  if (typeof key === "string") return;
11926
12252
  if (key instanceof Date) {
11927
- if (Number.isNaN(key.getTime())) throw new TypeError("TreeSet: invalid Date key");
12253
+ if (Number.isNaN(key.getTime())) throw new TypeError(ERR.invalidDate("TreeSet"));
11928
12254
  return;
11929
12255
  }
11930
- throw new TypeError("TreeSet: comparator is required for non-number/non-string/non-Date keys");
12256
+ throw new TypeError(ERR.comparatorRequired("TreeSet"));
11931
12257
  }
11932
12258
  /**
11933
12259
  * Add a key to the set (no-op if already present).
@@ -12250,15 +12576,15 @@ var _TreeMultiMap = class _TreeMultiMap {
12250
12576
  _validateKey(key) {
12251
12577
  if (!__privateGet(this, _isDefaultComparator2)) return;
12252
12578
  if (typeof key === "number") {
12253
- if (Number.isNaN(key)) throw new TypeError("TreeMultiMap: NaN is not a valid key");
12579
+ if (Number.isNaN(key)) throw new TypeError(ERR.invalidNaN("TreeMultiMap"));
12254
12580
  return;
12255
12581
  }
12256
12582
  if (typeof key === "string") return;
12257
12583
  if (key instanceof Date) {
12258
- if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiMap: invalid Date key");
12584
+ if (Number.isNaN(key.getTime())) throw new TypeError(ERR.invalidDate("TreeMultiMap"));
12259
12585
  return;
12260
12586
  }
12261
- throw new TypeError("TreeMultiMap: comparator is required for non-number/non-string/non-Date keys");
12587
+ throw new TypeError(ERR.comparatorRequired("TreeMultiMap"));
12262
12588
  }
12263
12589
  /**
12264
12590
  * Number of distinct keys.
@@ -12683,7 +13009,7 @@ var _TreeMap = class _TreeMap {
12683
13009
  [k, v] = toEntryFn(item);
12684
13010
  } else {
12685
13011
  if (!Array.isArray(item) || item.length < 2) {
12686
- throw new TypeError("TreeMap: each entry must be a [key, value] tuple");
13012
+ throw new TypeError(ERR.invalidEntry("TreeMap"));
12687
13013
  }
12688
13014
  k = item[0];
12689
13015
  v = item[1];
@@ -12704,7 +13030,7 @@ var _TreeMap = class _TreeMap {
12704
13030
  static createDefaultComparator() {
12705
13031
  return (a, b) => {
12706
13032
  if (typeof a === "number" && typeof b === "number") {
12707
- if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError("TreeMap: NaN is not a valid key");
13033
+ if (Number.isNaN(a) || Number.isNaN(b)) throw new TypeError(ERR.invalidNaN("TreeMap"));
12708
13034
  const aa = Object.is(a, -0) ? 0 : a;
12709
13035
  const bb = Object.is(b, -0) ? 0 : b;
12710
13036
  return aa > bb ? 1 : aa < bb ? -1 : 0;
@@ -12715,24 +13041,24 @@ var _TreeMap = class _TreeMap {
12715
13041
  if (a instanceof Date && b instanceof Date) {
12716
13042
  const ta = a.getTime();
12717
13043
  const tb = b.getTime();
12718
- if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError("TreeMap: invalid Date key");
13044
+ if (Number.isNaN(ta) || Number.isNaN(tb)) throw new TypeError(ERR.invalidDate("TreeMap"));
12719
13045
  return ta > tb ? 1 : ta < tb ? -1 : 0;
12720
13046
  }
12721
- throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys");
13047
+ throw new TypeError(ERR.comparatorRequired("TreeMap"));
12722
13048
  };
12723
13049
  }
12724
13050
  _validateKey(key) {
12725
13051
  if (!__privateGet(this, _isDefaultComparator3)) return;
12726
13052
  if (typeof key === "number") {
12727
- if (Number.isNaN(key)) throw new TypeError("TreeMap: NaN is not a valid key");
13053
+ if (Number.isNaN(key)) throw new TypeError(ERR.invalidNaN("TreeMap"));
12728
13054
  return;
12729
13055
  }
12730
13056
  if (typeof key === "string") return;
12731
13057
  if (key instanceof Date) {
12732
- if (Number.isNaN(key.getTime())) throw new TypeError("TreeMap: invalid Date key");
13058
+ if (Number.isNaN(key.getTime())) throw new TypeError(ERR.invalidDate("TreeMap"));
12733
13059
  return;
12734
13060
  }
12735
- throw new TypeError("TreeMap: comparator is required for non-number/non-string/non-Date keys");
13061
+ throw new TypeError(ERR.comparatorRequired("TreeMap"));
12736
13062
  }
12737
13063
  /**
12738
13064
  * Number of entries in the map.
@@ -13061,22 +13387,22 @@ var _TreeMultiSet = class _TreeMultiSet {
13061
13387
  _validateKey(key) {
13062
13388
  if (!__privateGet(this, _isDefaultComparator4)) return;
13063
13389
  if (typeof key === "number") {
13064
- if (Number.isNaN(key)) throw new TypeError("TreeMultiSet: NaN is not a valid key");
13390
+ if (Number.isNaN(key)) throw new TypeError(ERR.invalidNaN("TreeMultiSet"));
13065
13391
  return;
13066
13392
  }
13067
13393
  if (typeof key === "string") return;
13068
13394
  if (key instanceof Date) {
13069
- if (Number.isNaN(key.getTime())) throw new TypeError("TreeMultiSet: invalid Date key");
13395
+ if (Number.isNaN(key.getTime())) throw new TypeError(ERR.invalidDate("TreeMultiSet"));
13070
13396
  return;
13071
13397
  }
13072
- throw new TypeError("TreeMultiSet: comparator is required for non-number/non-string/non-Date keys");
13398
+ throw new TypeError(ERR.comparatorRequired("TreeMultiSet"));
13073
13399
  }
13074
13400
  /**
13075
13401
  * Validates that count is a non-negative safe integer.
13076
13402
  * @remarks Time O(1), Space O(1)
13077
13403
  */
13078
13404
  _validateCount(n) {
13079
- if (!Number.isSafeInteger(n) || n < 0) throw new RangeError("TreeMultiSet: count must be a safe integer >= 0");
13405
+ if (!Number.isSafeInteger(n) || n < 0) throw new RangeError(ERR.invalidArgument("count must be a safe integer >= 0.", "TreeMultiSet"));
13080
13406
  }
13081
13407
  /**
13082
13408
  * Total occurrences (sumCounts).
@@ -13235,7 +13561,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13235
13561
  * @remarks Time O(1), Space O(1)
13236
13562
  */
13237
13563
  get comparator() {
13238
- return __privateGet(this, _core4)._comparator;
13564
+ return __privateGet(this, _core4).comparator;
13239
13565
  }
13240
13566
  // ━━━ clear ━━━
13241
13567
  /**
@@ -13372,7 +13698,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13372
13698
  filter(predicate) {
13373
13699
  const result = new _TreeMultiSet([], {
13374
13700
  comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13375
- isMapMode: __privateGet(this, _core4)._isMapMode
13701
+ isMapMode: __privateGet(this, _core4).isMapMode
13376
13702
  });
13377
13703
  for (const [k, c] of this.entries()) {
13378
13704
  if (predicate(k, c)) {
@@ -13412,7 +13738,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13412
13738
  map(mapper, options) {
13413
13739
  const result = new _TreeMultiSet([], {
13414
13740
  comparator: options == null ? void 0 : options.comparator,
13415
- isMapMode: __privateGet(this, _core4)._isMapMode
13741
+ isMapMode: __privateGet(this, _core4).isMapMode
13416
13742
  });
13417
13743
  for (const [k, c] of this.entries()) {
13418
13744
  const [newKey, newCount] = mapper(k, c);
@@ -13432,7 +13758,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13432
13758
  clone() {
13433
13759
  const result = new _TreeMultiSet([], {
13434
13760
  comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13435
- isMapMode: __privateGet(this, _core4)._isMapMode
13761
+ isMapMode: __privateGet(this, _core4).isMapMode
13436
13762
  });
13437
13763
  for (const [k, c] of this.entries()) {
13438
13764
  result.add(k, c);
@@ -13504,9 +13830,7 @@ var _MaxPriorityQueue = class _MaxPriorityQueue extends PriorityQueue {
13504
13830
  super(elements, {
13505
13831
  comparator: /* @__PURE__ */ __name((a, b) => {
13506
13832
  if (typeof a === "object" || typeof b === "object") {
13507
- throw TypeError(
13508
- `When comparing object types, a custom comparator must be defined in the constructor's options parameter.`
13509
- );
13833
+ throw new TypeError(ERR.comparatorRequired("MaxPriorityQueue"));
13510
13834
  }
13511
13835
  if (a < b) return 1;
13512
13836
  if (a > b) return -1;
@@ -13647,7 +13971,7 @@ var _Matrix = class _Matrix {
13647
13971
  */
13648
13972
  add(matrix) {
13649
13973
  if (!this.isMatchForCalculate(matrix)) {
13650
- throw new Error("Matrix dimensions must match for addition.");
13974
+ throw new Error(ERR.matrixDimensionMismatch("addition"));
13651
13975
  }
13652
13976
  const resultData = [];
13653
13977
  for (let i = 0; i < this.rows; i++) {
@@ -13679,7 +14003,7 @@ var _Matrix = class _Matrix {
13679
14003
  */
13680
14004
  subtract(matrix) {
13681
14005
  if (!this.isMatchForCalculate(matrix)) {
13682
- throw new Error("Matrix dimensions must match for subtraction.");
14006
+ throw new Error(ERR.matrixDimensionMismatch("subtraction"));
13683
14007
  }
13684
14008
  const resultData = [];
13685
14009
  for (let i = 0; i < this.rows; i++) {
@@ -13710,7 +14034,7 @@ var _Matrix = class _Matrix {
13710
14034
  */
13711
14035
  multiply(matrix) {
13712
14036
  if (this.cols !== matrix.rows) {
13713
- throw new Error("Matrix dimensions must be compatible for multiplication (A.cols = B.rows).");
14037
+ throw new Error(ERR.matrixDimensionMismatch("multiplication (A.cols must equal B.rows)"));
13714
14038
  }
13715
14039
  const resultData = [];
13716
14040
  for (let i = 0; i < this.rows; i++) {
@@ -13744,7 +14068,7 @@ var _Matrix = class _Matrix {
13744
14068
  */
13745
14069
  transpose() {
13746
14070
  if (this.data.some((row) => row.length !== this.rows)) {
13747
- throw new Error("Matrix must be rectangular for transposition.");
14071
+ throw new Error(ERR.matrixNotRectangular());
13748
14072
  }
13749
14073
  const resultData = [];
13750
14074
  for (let j = 0; j < this.cols; j++) {
@@ -13769,7 +14093,7 @@ var _Matrix = class _Matrix {
13769
14093
  inverse() {
13770
14094
  var _a;
13771
14095
  if (this.rows !== this.cols) {
13772
- throw new Error("Matrix must be square for inversion.");
14096
+ throw new Error(ERR.matrixNotSquare());
13773
14097
  }
13774
14098
  const augmentedMatrixData = [];
13775
14099
  for (let i = 0; i < this.rows; i++) {
@@ -13791,12 +14115,12 @@ var _Matrix = class _Matrix {
13791
14115
  pivotRow++;
13792
14116
  }
13793
14117
  if (pivotRow === this.rows) {
13794
- throw new Error("Matrix is singular, and its inverse does not exist.");
14118
+ throw new Error(ERR.matrixSingular());
13795
14119
  }
13796
14120
  augmentedMatrix._swapRows(i, pivotRow);
13797
14121
  const pivotElement = (_a = augmentedMatrix.get(i, i)) != null ? _a : 1;
13798
14122
  if (pivotElement === 0) {
13799
- throw new Error("Matrix is singular, and its inverse does not exist (division by zero).");
14123
+ throw new Error(ERR.matrixSingular());
13800
14124
  }
13801
14125
  augmentedMatrix._scaleRow(i, 1 / pivotElement);
13802
14126
  for (let j = 0; j < this.rows; j++) {
@@ -13826,9 +14150,7 @@ var _Matrix = class _Matrix {
13826
14150
  */
13827
14151
  dot(matrix) {
13828
14152
  if (this.cols !== matrix.rows) {
13829
- throw new Error(
13830
- "Number of columns in the first matrix must be equal to the number of rows in the second matrix for dot product."
13831
- );
14153
+ throw new Error(ERR.matrixDimensionMismatch("dot product (A.cols must equal B.rows)"));
13832
14154
  }
13833
14155
  const resultData = [];
13834
14156
  for (let i = 0; i < this.rows; i++) {
@@ -14450,7 +14772,7 @@ var _Trie = class _Trie extends IterableElementBase {
14450
14772
  for (const x of this) {
14451
14773
  const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
14452
14774
  if (typeof v !== "string") {
14453
- throw new TypeError(`Trie.map callback must return string; got ${typeof v}`);
14775
+ throw new TypeError(ERR.callbackReturnType("string", typeof v, "Trie.map"));
14454
14776
  }
14455
14777
  newTrie.add(v);
14456
14778
  }
@@ -14480,12 +14802,11 @@ var _Trie = class _Trie extends IterableElementBase {
14480
14802
  */
14481
14803
  _createInstance(options) {
14482
14804
  const Ctor = this.constructor;
14483
- const next = new Ctor([], {
14805
+ return new Ctor([], {
14484
14806
  toElementFn: this.toElementFn,
14485
14807
  caseSensitive: this.caseSensitive,
14486
14808
  ...options != null ? options : {}
14487
14809
  });
14488
- return next;
14489
14810
  }
14490
14811
  /**
14491
14812
  * (Protected) Create a like-kind trie and seed it from an iterable.
@@ -14684,6 +15005,6 @@ var TreeNode = _TreeNode;
14684
15005
  * @license MIT License
14685
15006
  */
14686
15007
 
14687
- export { AVLTree, AVLTreeNode, AbstractEdge, AbstractGraph, AbstractVertex, BST, BSTNode, BinaryIndexedTree, BinaryTree, BinaryTreeNode, Character, DFSOperation, Deque, DirectedEdge, DirectedGraph, DirectedVertex, DoublyLinkedList, DoublyLinkedListNode, FibonacciHeap, FibonacciHeapNode, HashMap, Heap, IterableElementBase, IterableEntryBase, LinkedHashMap, LinkedListQueue, MapEdge, MapGraph, MapVertex, Matrix, MaxHeap, MaxPriorityQueue, MinHeap, MinPriorityQueue, Navigator, PriorityQueue, Queue, Range, RedBlackTree, RedBlackTreeNode, SegmentTree, SegmentTreeNode, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, Stack, TreeMap, TreeMultiMap, TreeMultiMapNode, TreeMultiSet, TreeNode, TreeSet, Trie, TrieNode, UndirectedEdge, UndirectedGraph, UndirectedVertex, arrayRemove, asyncTrampoline, calcMinUnitsRequired, getMSB, isComparable, isTrampolineThunk, isWeakKey, makeAsyncTrampoline, makeTrampoline, makeTrampolineThunk, rangeCheck, roundFixed, throwRangeError, toBinaryString, trampoline, uuidV4 };
15008
+ export { AVLTree, AVLTreeNode, AbstractEdge, AbstractGraph, AbstractVertex, BST, BSTNode, BinaryIndexedTree, BinaryTree, BinaryTreeNode, Character, DFSOperation, Deque, DirectedEdge, DirectedGraph, DirectedVertex, DoublyLinkedList, DoublyLinkedListNode, ERR, FibonacciHeap, FibonacciHeapNode, HashMap, Heap, IterableElementBase, IterableEntryBase, LinkedHashMap, LinkedListQueue, MapEdge, MapGraph, MapVertex, Matrix, MaxHeap, MaxPriorityQueue, MinHeap, MinPriorityQueue, Navigator, PriorityQueue, Queue, Range, RedBlackTree, RedBlackTreeNode, SegmentTree, SegmentTreeNode, SinglyLinkedList, SinglyLinkedListNode, SkipList, SkipListNode, Stack, TreeMap, TreeMultiMap, TreeMultiMapNode, TreeMultiSet, TreeNode, TreeSet, Trie, TrieNode, UndirectedEdge, UndirectedGraph, UndirectedVertex, arrayRemove, asyncTrampoline, calcMinUnitsRequired, getMSB, isComparable, isTrampolineThunk, isWeakKey, makeAsyncTrampoline, makeTrampoline, makeTrampolineThunk, rangeCheck, roundFixed, throwRangeError, toBinaryString, trampoline, uuidV4 };
14688
15009
  //# sourceMappingURL=index.mjs.map
14689
15010
  //# sourceMappingURL=index.mjs.map