binary-tree-typed 2.5.0 → 2.5.2

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 (90) hide show
  1. package/dist/cjs/index.cjs +771 -68
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +771 -68
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +771 -69
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +771 -69
  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/base/index.d.ts +1 -0
  12. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  13. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  14. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  26. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  27. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  28. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  32. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  33. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  34. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  35. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  36. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  37. package/dist/types/interfaces/graph.d.ts +1 -1
  38. package/dist/types/types/common.d.ts +2 -2
  39. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  40. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  41. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  42. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  43. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  44. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  45. package/dist/types/types/utils/validate-type.d.ts +4 -4
  46. package/dist/umd/binary-tree-typed.js +773 -71
  47. package/dist/umd/binary-tree-typed.js.map +1 -1
  48. package/dist/umd/binary-tree-typed.min.js +5 -5
  49. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/common/error.ts +19 -1
  52. package/src/common/index.ts +1 -1
  53. package/src/data-structures/base/index.ts +1 -0
  54. package/src/data-structures/base/iterable-element-base.ts +3 -2
  55. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  56. package/src/data-structures/base/linear-base.ts +3 -3
  57. package/src/data-structures/binary-tree/avl-tree.ts +299 -0
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
  59. package/src/data-structures/binary-tree/binary-tree.ts +606 -6
  60. package/src/data-structures/binary-tree/bst.ts +946 -7
  61. package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
  62. package/src/data-structures/binary-tree/segment-tree.ts +145 -2
  63. package/src/data-structures/binary-tree/tree-map.ts +3423 -499
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
  65. package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
  66. package/src/data-structures/binary-tree/tree-set.ts +3209 -413
  67. package/src/data-structures/graph/abstract-graph.ts +6 -6
  68. package/src/data-structures/graph/directed-graph.ts +240 -0
  69. package/src/data-structures/graph/undirected-graph.ts +216 -0
  70. package/src/data-structures/hash/hash-map.ts +281 -19
  71. package/src/data-structures/heap/heap.ts +340 -4
  72. package/src/data-structures/heap/max-heap.ts +2 -2
  73. package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
  74. package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
  75. package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
  76. package/src/data-structures/matrix/matrix.ts +202 -10
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  78. package/src/data-structures/queue/deque.ts +365 -5
  79. package/src/data-structures/queue/queue.ts +288 -0
  80. package/src/data-structures/stack/stack.ts +240 -0
  81. package/src/data-structures/trie/trie.ts +295 -7
  82. package/src/interfaces/graph.ts +1 -1
  83. package/src/types/common.ts +2 -2
  84. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  85. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  86. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  87. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  88. package/src/types/data-structures/heap/heap.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  90. package/src/types/utils/validate-type.ts +4 -4
@@ -61,6 +61,60 @@ function makeTrampoline(fn) {
61
61
  }
62
62
  __name(makeTrampoline, "makeTrampoline");
63
63
 
64
+ // src/common/error.ts
65
+ function raise(ErrorClass, message) {
66
+ throw new ErrorClass(message);
67
+ }
68
+ __name(raise, "raise");
69
+ var ERR = {
70
+ // Range / index
71
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
72
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
73
+ // Type / argument
74
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
75
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
76
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
77
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
78
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
79
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
80
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
81
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
82
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
83
+ // State / operation
84
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
85
+ // Matrix
86
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
87
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
88
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
89
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
90
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
91
+ // Order statistic
92
+ orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
93
+ };
94
+
95
+ // src/common/index.ts
96
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
97
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
98
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
99
+ return DFSOperation2;
100
+ })(DFSOperation || {});
101
+ var _Range = class _Range {
102
+ constructor(low, high, includeLow = true, includeHigh = true) {
103
+ this.low = low;
104
+ this.high = high;
105
+ this.includeLow = includeLow;
106
+ this.includeHigh = includeHigh;
107
+ }
108
+ // Determine whether a key is within the range
109
+ isInRange(key, comparator) {
110
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
111
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
112
+ return lowCheck && highCheck;
113
+ }
114
+ };
115
+ __name(_Range, "Range");
116
+ var Range = _Range;
117
+
64
118
  // src/data-structures/base/iterable-element-base.ts
65
119
  var _IterableElementBase = class _IterableElementBase {
66
120
  /**
@@ -83,7 +137,7 @@ var _IterableElementBase = class _IterableElementBase {
83
137
  if (options) {
84
138
  const { toElementFn } = options;
85
139
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
86
- else if (toElementFn) throw new TypeError("toElementFn must be a function type");
140
+ else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
87
141
  }
88
142
  }
89
143
  /**
@@ -239,7 +293,7 @@ var _IterableElementBase = class _IterableElementBase {
239
293
  acc = initialValue;
240
294
  } else {
241
295
  const first = iter.next();
242
- if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
296
+ if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
243
297
  acc = first.value;
244
298
  index = 1;
245
299
  }
@@ -475,54 +529,6 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
475
529
  __name(_LinearBase, "LinearBase");
476
530
  var LinearBase = _LinearBase;
477
531
 
478
- // src/common/error.ts
479
- var ERR = {
480
- // Range / index
481
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
482
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
483
- // Type / argument
484
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
485
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
486
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
487
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
488
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
489
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
490
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
491
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
492
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
493
- // State / operation
494
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
495
- // Matrix
496
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
497
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
498
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
499
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
500
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
501
- };
502
-
503
- // src/common/index.ts
504
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
505
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
506
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
507
- return DFSOperation2;
508
- })(DFSOperation || {});
509
- var _Range = class _Range {
510
- constructor(low, high, includeLow = true, includeHigh = true) {
511
- this.low = low;
512
- this.high = high;
513
- this.includeLow = includeLow;
514
- this.includeHigh = includeHigh;
515
- }
516
- // Determine whether a key is within the range
517
- isInRange(key, comparator) {
518
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
519
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
520
- return lowCheck && highCheck;
521
- }
522
- };
523
- __name(_Range, "Range");
524
- var Range = _Range;
525
-
526
532
  // src/data-structures/base/iterable-entry-base.ts
527
533
  var _IterableEntryBase = class _IterableEntryBase {
528
534
  /**
@@ -772,6 +778,30 @@ var _Queue = class _Queue extends LinearBase {
772
778
 
773
779
 
774
780
 
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+
775
805
  * @example
776
806
  * // Track queue length
777
807
  * const q = new Queue<number>();
@@ -798,6 +828,30 @@ var _Queue = class _Queue extends LinearBase {
798
828
 
799
829
 
800
830
 
831
+
832
+
833
+
834
+
835
+
836
+
837
+
838
+
839
+
840
+
841
+
842
+
843
+
844
+
845
+
846
+
847
+
848
+
849
+
850
+
851
+
852
+
853
+
854
+
801
855
  * @example
802
856
  * // View the front element
803
857
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -840,6 +894,30 @@ var _Queue = class _Queue extends LinearBase {
840
894
 
841
895
 
842
896
 
897
+
898
+
899
+
900
+
901
+
902
+
903
+
904
+
905
+
906
+
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
916
+
917
+
918
+
919
+
920
+
843
921
  * @example
844
922
  * // Queue for...of iteration and isEmpty check
845
923
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -878,6 +956,30 @@ var _Queue = class _Queue extends LinearBase {
878
956
 
879
957
 
880
958
 
959
+
960
+
961
+
962
+
963
+
964
+
965
+
966
+
967
+
968
+
969
+
970
+
971
+
972
+
973
+
974
+
975
+
976
+
977
+
978
+
979
+
980
+
981
+
982
+
881
983
  * @example
882
984
  * // basic Queue creation and push operation
883
985
  * // Create a simple Queue with initial values
@@ -923,6 +1025,30 @@ var _Queue = class _Queue extends LinearBase {
923
1025
 
924
1026
 
925
1027
 
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+
926
1052
  * @example
927
1053
  * // Queue shift and peek operations
928
1054
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -958,6 +1084,30 @@ var _Queue = class _Queue extends LinearBase {
958
1084
 
959
1085
 
960
1086
 
1087
+
1088
+
1089
+
1090
+
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
961
1111
  * @example
962
1112
  * // Remove specific element
963
1113
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -986,23 +1136,47 @@ var _Queue = class _Queue extends LinearBase {
986
1136
 
987
1137
 
988
1138
 
989
- * @example
990
- * // Access element by index
991
- * const q = new Queue<string>(['a', 'b', 'c']);
992
- * console.log(q.at(0)); // 'a';
993
- * console.log(q.at(2)); // 'c';
994
- */
995
- at(index) {
996
- if (index < 0 || index >= this.length) return void 0;
997
- return this._elements[this._offset + index];
998
- }
999
- /**
1000
- * Delete the element at a given index.
1001
- * @remarks Time O(N), Space O(1)
1002
- * @param index - Zero-based index from the front.
1003
- * @returns Removed element or undefined.
1004
- */
1005
- deleteAt(index) {
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+
1145
+
1146
+
1147
+
1148
+
1149
+
1150
+
1151
+
1152
+
1153
+
1154
+
1155
+
1156
+
1157
+
1158
+
1159
+
1160
+
1161
+
1162
+
1163
+ * @example
1164
+ * // Access element by index
1165
+ * const q = new Queue<string>(['a', 'b', 'c']);
1166
+ * console.log(q.at(0)); // 'a';
1167
+ * console.log(q.at(2)); // 'c';
1168
+ */
1169
+ at(index) {
1170
+ if (index < 0 || index >= this.length) return void 0;
1171
+ return this._elements[this._offset + index];
1172
+ }
1173
+ /**
1174
+ * Delete the element at a given index.
1175
+ * @remarks Time O(N), Space O(1)
1176
+ * @param index - Zero-based index from the front.
1177
+ * @returns Removed element or undefined.
1178
+ */
1179
+ deleteAt(index) {
1006
1180
  if (index < 0 || index >= this.length) return void 0;
1007
1181
  const gi = this._offset + index;
1008
1182
  const [deleted] = this.elements.splice(gi, 1);
@@ -1055,6 +1229,30 @@ var _Queue = class _Queue extends LinearBase {
1055
1229
 
1056
1230
 
1057
1231
 
1232
+
1233
+
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+
1247
+
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+
1255
+
1058
1256
  * @example
1059
1257
  * // Remove all elements
1060
1258
  * const q = new Queue<number>([1, 2, 3]);
@@ -1077,6 +1275,30 @@ var _Queue = class _Queue extends LinearBase {
1077
1275
 
1078
1276
 
1079
1277
 
1278
+
1279
+
1280
+
1281
+
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+
1296
+
1297
+
1298
+
1299
+
1300
+
1301
+
1080
1302
  * @example
1081
1303
  * // Reclaim unused memory
1082
1304
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -1122,6 +1344,30 @@ var _Queue = class _Queue extends LinearBase {
1122
1344
 
1123
1345
 
1124
1346
 
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+
1353
+
1354
+
1355
+
1356
+
1357
+
1358
+
1359
+
1360
+
1361
+
1362
+
1363
+
1364
+
1365
+
1366
+
1367
+
1368
+
1369
+
1370
+
1125
1371
  * @example
1126
1372
  * // Create independent copy
1127
1373
  * const q = new Queue<number>([1, 2, 3]);
@@ -1151,6 +1397,30 @@ var _Queue = class _Queue extends LinearBase {
1151
1397
 
1152
1398
 
1153
1399
 
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+
1406
+
1407
+
1408
+
1409
+
1410
+
1411
+
1412
+
1413
+
1414
+
1415
+
1416
+
1417
+
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1154
1424
  * @example
1155
1425
  * // Filter elements
1156
1426
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -1184,6 +1454,30 @@ var _Queue = class _Queue extends LinearBase {
1184
1454
 
1185
1455
 
1186
1456
 
1457
+
1458
+
1459
+
1460
+
1461
+
1462
+
1463
+
1464
+
1465
+
1466
+
1467
+
1468
+
1469
+
1470
+
1471
+
1472
+
1473
+
1474
+
1475
+
1476
+
1477
+
1478
+
1479
+
1480
+
1187
1481
  * @example
1188
1482
  * // Transform elements
1189
1483
  * const q = new Queue<number>([1, 2, 3]);
@@ -1452,7 +1746,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1452
1746
  if (isMapMode !== void 0) this._isMapMode = isMapMode;
1453
1747
  if (isDuplicate !== void 0) this._isDuplicate = isDuplicate;
1454
1748
  if (typeof toEntryFn === "function") this._toEntryFn = toEntryFn;
1455
- else if (toEntryFn) throw new TypeError(ERR.notAFunction("toEntryFn", "BinaryTree"));
1749
+ else if (toEntryFn) raise(TypeError, ERR.notAFunction("toEntryFn", "BinaryTree"));
1456
1750
  }
1457
1751
  if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
1458
1752
  }
@@ -1668,6 +1962,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1668
1962
 
1669
1963
 
1670
1964
 
1965
+
1966
+
1967
+
1968
+
1969
+
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+
1977
+
1978
+
1979
+
1980
+
1981
+
1982
+
1983
+
1984
+
1985
+
1986
+
1987
+
1988
+
1671
1989
  * @example
1672
1990
  * // Add a single node
1673
1991
  * const tree = new BinaryTree<number>();
@@ -1698,6 +2016,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1698
2016
 
1699
2017
 
1700
2018
 
2019
+
2020
+
2021
+
2022
+
2023
+
2024
+
2025
+
2026
+
2027
+
2028
+
2029
+
2030
+
2031
+
2032
+
2033
+
2034
+
2035
+
2036
+
2037
+
2038
+
2039
+
2040
+
2041
+
2042
+
1701
2043
  * @example
1702
2044
  * // basic BinaryTree creation and insertion
1703
2045
  * // Create a BinaryTree with entries
@@ -1780,6 +2122,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1780
2122
 
1781
2123
 
1782
2124
 
2125
+
2126
+
2127
+
2128
+
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
2135
+
2136
+
2137
+
2138
+
2139
+
2140
+
2141
+
2142
+
2143
+
2144
+
2145
+
2146
+
2147
+
2148
+
1783
2149
  * @example
1784
2150
  * // Bulk add
1785
2151
  * const tree = new BinaryTree<number>();
@@ -1798,6 +2164,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1798
2164
  * @returns An array of booleans indicating the success of each individual `set` operation.
1799
2165
 
1800
2166
 
2167
+
2168
+
2169
+
2170
+
2171
+
2172
+
2173
+
2174
+
2175
+
2176
+
2177
+
2178
+
2179
+
2180
+
2181
+
2182
+
2183
+
2184
+
2185
+
2186
+
2187
+
2188
+
2189
+
2190
+
1801
2191
  * @example
1802
2192
  * // Set multiple entries
1803
2193
  * const tree = new BinaryTree<number, string>();
@@ -1837,6 +2227,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1837
2227
 
1838
2228
 
1839
2229
 
2230
+
2231
+
2232
+
2233
+
2234
+
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+
2244
+
2245
+
2246
+
2247
+
2248
+
2249
+
2250
+
2251
+
2252
+
2253
+
1840
2254
  * @example
1841
2255
  * // Combine trees
1842
2256
  * const t1 = new BinaryTree<number>([1, 2]);
@@ -1875,6 +2289,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1875
2289
 
1876
2290
 
1877
2291
 
2292
+
2293
+
2294
+
2295
+
2296
+
2297
+
2298
+
2299
+
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+
2306
+
2307
+
2308
+
2309
+
2310
+
2311
+
2312
+
2313
+
2314
+
2315
+
1878
2316
  * @example
1879
2317
  * // Remove a node
1880
2318
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1991,6 +2429,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1991
2429
 
1992
2430
 
1993
2431
 
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2446
+
2447
+
2448
+
2449
+
2450
+
2451
+
2452
+
2453
+
2454
+
2455
+
1994
2456
  * @example
1995
2457
  * // Get node by key
1996
2458
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
@@ -2025,6 +2487,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2025
2487
 
2026
2488
 
2027
2489
 
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+
2496
+
2497
+
2498
+
2499
+
2500
+
2501
+
2502
+
2503
+
2504
+
2505
+
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2028
2514
  * @example
2029
2515
  * // Retrieve value by key
2030
2516
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
@@ -2062,6 +2548,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2062
2548
 
2063
2549
 
2064
2550
 
2551
+
2552
+
2553
+
2554
+
2555
+
2556
+
2557
+
2558
+
2559
+
2560
+
2561
+
2562
+
2563
+
2564
+
2565
+
2566
+
2567
+
2568
+
2569
+
2570
+
2571
+
2572
+
2573
+
2574
+
2065
2575
  * @example
2066
2576
  * // Remove all nodes
2067
2577
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2086,6 +2596,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2086
2596
 
2087
2597
 
2088
2598
 
2599
+
2600
+
2601
+
2602
+
2603
+
2604
+
2605
+
2606
+
2607
+
2608
+
2609
+
2610
+
2611
+
2612
+
2613
+
2614
+
2615
+
2616
+
2617
+
2618
+
2619
+
2620
+
2621
+
2622
+
2089
2623
  * @example
2090
2624
  * // Check empty
2091
2625
  * console.log(new BinaryTree().isEmpty()); // true;
@@ -2119,6 +2653,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2119
2653
 
2120
2654
 
2121
2655
 
2656
+
2657
+
2658
+
2659
+
2660
+
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2122
2680
  * @example
2123
2681
  * // Check BST property
2124
2682
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2179,6 +2737,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2179
2737
 
2180
2738
 
2181
2739
 
2740
+
2741
+
2742
+
2743
+
2744
+
2745
+
2746
+
2747
+
2748
+
2749
+
2750
+
2751
+
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2763
+
2182
2764
  * @example
2183
2765
  * // Get depth of a node
2184
2766
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -2216,6 +2798,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2216
2798
 
2217
2799
 
2218
2800
 
2801
+
2802
+
2803
+
2804
+
2805
+
2806
+
2807
+
2808
+
2809
+
2810
+
2811
+
2812
+
2813
+
2814
+
2815
+
2816
+
2817
+
2818
+
2819
+
2820
+
2821
+
2822
+
2823
+
2824
+
2219
2825
  * @example
2220
2826
  * // Get tree height
2221
2827
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -2669,6 +3275,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2669
3275
 
2670
3276
 
2671
3277
 
3278
+
3279
+
3280
+
3281
+
3282
+
3283
+
3284
+
3285
+
3286
+
3287
+
3288
+
3289
+
3290
+
3291
+
3292
+
3293
+
3294
+
3295
+
3296
+
3297
+
3298
+
3299
+
3300
+
3301
+
2672
3302
  * @example
2673
3303
  * // Deep copy
2674
3304
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2697,6 +3327,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2697
3327
 
2698
3328
 
2699
3329
 
3330
+
3331
+
3332
+
3333
+
3334
+
3335
+
3336
+
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+
3343
+
3344
+
3345
+
3346
+
3347
+
3348
+
3349
+
3350
+
3351
+
3352
+
3353
+
2700
3354
  * @example
2701
3355
  * // Filter nodes by condition
2702
3356
  * const tree = new BinaryTree<number>([1, 2, 3, 4]);
@@ -2729,6 +3383,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2729
3383
 
2730
3384
 
2731
3385
 
3386
+
3387
+
3388
+
3389
+
3390
+
3391
+
3392
+
3393
+
3394
+
3395
+
3396
+
3397
+
3398
+
3399
+
3400
+
3401
+
3402
+
3403
+
3404
+
3405
+
3406
+
3407
+
3408
+
3409
+
2732
3410
  * @example
2733
3411
  * // Transform to new tree
2734
3412
  * const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
@@ -2786,6 +3464,30 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2786
3464
 
2787
3465
 
2788
3466
 
3467
+
3468
+
3469
+
3470
+
3471
+
3472
+
3473
+
3474
+
3475
+
3476
+
3477
+
3478
+
3479
+
3480
+
3481
+
3482
+
3483
+
3484
+
3485
+
3486
+
3487
+
3488
+
3489
+
3490
+
2789
3491
  * @example
2790
3492
  * // Display tree
2791
3493
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -3266,5 +3968,6 @@ exports.BinaryTreeNode = BinaryTreeNode;
3266
3968
  exports.DFSOperation = DFSOperation;
3267
3969
  exports.ERR = ERR;
3268
3970
  exports.Range = Range;
3971
+ exports.raise = raise;
3269
3972
  //# sourceMappingURL=index.cjs.map
3270
3973
  //# sourceMappingURL=index.cjs.map