stack-typed 2.4.5 → 2.5.0

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 (76) hide show
  1. package/README.md +6 -36
  2. package/dist/cjs/index.cjs +270 -100
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs-legacy/index.cjs +269 -99
  5. package/dist/cjs-legacy/index.cjs.map +1 -1
  6. package/dist/esm/index.mjs +270 -100
  7. package/dist/esm/index.mjs.map +1 -1
  8. package/dist/esm-legacy/index.mjs +269 -99
  9. package/dist/esm-legacy/index.mjs.map +1 -1
  10. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +128 -51
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +210 -164
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +429 -78
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +311 -28
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +212 -32
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +218 -152
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1281 -5
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1087 -201
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +858 -65
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1133 -5
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +219 -47
  22. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  23. package/dist/types/data-structures/graph/undirected-graph.d.ts +204 -59
  24. package/dist/types/data-structures/hash/hash-map.d.ts +230 -77
  25. package/dist/types/data-structures/heap/heap.d.ts +287 -99
  26. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  27. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  28. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +286 -44
  29. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +278 -65
  30. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +415 -12
  31. package/dist/types/data-structures/matrix/matrix.d.ts +331 -0
  32. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  33. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  34. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  35. package/dist/types/data-structures/queue/deque.d.ts +272 -65
  36. package/dist/types/data-structures/queue/queue.d.ts +211 -42
  37. package/dist/types/data-structures/stack/stack.d.ts +174 -32
  38. package/dist/types/data-structures/trie/trie.d.ts +213 -43
  39. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  40. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  41. package/dist/umd/stack-typed.js +267 -97
  42. package/dist/umd/stack-typed.js.map +1 -1
  43. package/dist/umd/stack-typed.min.js +1 -1
  44. package/dist/umd/stack-typed.min.js.map +1 -1
  45. package/package.json +2 -2
  46. package/src/data-structures/base/iterable-element-base.ts +4 -5
  47. package/src/data-structures/binary-tree/avl-tree.ts +134 -51
  48. package/src/data-structures/binary-tree/binary-indexed-tree.ts +302 -247
  49. package/src/data-structures/binary-tree/binary-tree.ts +429 -79
  50. package/src/data-structures/binary-tree/bst.ts +335 -34
  51. package/src/data-structures/binary-tree/red-black-tree.ts +290 -97
  52. package/src/data-structures/binary-tree/segment-tree.ts +372 -248
  53. package/src/data-structures/binary-tree/tree-map.ts +1284 -6
  54. package/src/data-structures/binary-tree/tree-multi-map.ts +1094 -211
  55. package/src/data-structures/binary-tree/tree-multi-set.ts +858 -65
  56. package/src/data-structures/binary-tree/tree-set.ts +1136 -9
  57. package/src/data-structures/graph/directed-graph.ts +219 -47
  58. package/src/data-structures/graph/map-graph.ts +59 -1
  59. package/src/data-structures/graph/undirected-graph.ts +204 -59
  60. package/src/data-structures/hash/hash-map.ts +230 -77
  61. package/src/data-structures/heap/heap.ts +287 -99
  62. package/src/data-structures/heap/max-heap.ts +46 -0
  63. package/src/data-structures/heap/min-heap.ts +59 -0
  64. package/src/data-structures/linked-list/doubly-linked-list.ts +286 -44
  65. package/src/data-structures/linked-list/singly-linked-list.ts +278 -65
  66. package/src/data-structures/linked-list/skip-linked-list.ts +689 -90
  67. package/src/data-structures/matrix/matrix.ts +416 -12
  68. package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
  69. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  70. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  71. package/src/data-structures/queue/deque.ts +272 -65
  72. package/src/data-structures/queue/queue.ts +211 -42
  73. package/src/data-structures/stack/stack.ts +174 -32
  74. package/src/data-structures/trie/trie.ts +213 -43
  75. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  76. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
@@ -5,54 +5,6 @@ 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
- var ERR = {
10
- // Range / index
11
- indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
12
- invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
13
- // Type / argument
14
- invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
15
- comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
16
- invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
17
- notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
18
- invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
19
- invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
20
- invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
21
- reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
22
- callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
23
- // State / operation
24
- invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
25
- // Matrix
26
- matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
27
- matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
28
- matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
29
- matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
30
- matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
31
- };
32
-
33
- // src/common/index.ts
34
- var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
35
- DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
36
- DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
37
- return DFSOperation2;
38
- })(DFSOperation || {});
39
- var _Range = class _Range {
40
- constructor(low, high, includeLow = true, includeHigh = true) {
41
- this.low = low;
42
- this.high = high;
43
- this.includeLow = includeLow;
44
- this.includeHigh = includeHigh;
45
- }
46
- // Determine whether a key is within the range
47
- isInRange(key, comparator) {
48
- const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
49
- const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
50
- return lowCheck && highCheck;
51
- }
52
- };
53
- __name(_Range, "Range");
54
- var Range = _Range;
55
-
56
8
  // src/data-structures/base/iterable-element-base.ts
57
9
  var _IterableElementBase = class _IterableElementBase {
58
10
  /**
@@ -75,7 +27,7 @@ var _IterableElementBase = class _IterableElementBase {
75
27
  if (options) {
76
28
  const { toElementFn } = options;
77
29
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
78
- else if (toElementFn) throw new TypeError(ERR.notAFunction("toElementFn"));
30
+ else if (toElementFn) throw new TypeError("toElementFn must be a function type");
79
31
  }
80
32
  }
81
33
  /**
@@ -231,7 +183,7 @@ var _IterableElementBase = class _IterableElementBase {
231
183
  acc = initialValue;
232
184
  } else {
233
185
  const first = iter.next();
234
- if (first.done) throw new TypeError(ERR.reduceEmpty());
186
+ if (first.done) throw new TypeError("Reduce of empty structure with no initial value");
235
187
  acc = first.value;
236
188
  index = 1;
237
189
  }
@@ -299,10 +251,23 @@ var _Stack = class _Stack extends IterableElementBase {
299
251
  return this._elements;
300
252
  }
301
253
  /**
302
- * Get the number of stored elements.
303
- * @remarks Time O(1), Space O(1)
304
- * @returns Current size.
305
- */
254
+ * Get the number of stored elements.
255
+ * @remarks Time O(1), Space O(1)
256
+ * @returns Current size.
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+ * @example
267
+ * // Get number of elements
268
+ * const stack = new Stack<number>([1, 2, 3]);
269
+ * console.log(stack.size); // 3;
270
+ */
306
271
  get size() {
307
272
  return this.elements.length;
308
273
  }
@@ -320,36 +285,123 @@ var _Stack = class _Stack extends IterableElementBase {
320
285
  return new this(elements, options);
321
286
  }
322
287
  /**
323
- * Check whether the stack is empty.
324
- * @remarks Time O(1), Space O(1)
325
- * @returns True if size is 0.
326
- */
288
+ * Check whether the stack is empty.
289
+ * @remarks Time O(1), Space O(1)
290
+ * @returns True if size is 0.
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+ * @example
303
+ * // Check if stack has elements
304
+ * const stack = new Stack<number>();
305
+ * console.log(stack.isEmpty()); // true;
306
+ * stack.push(1);
307
+ * console.log(stack.isEmpty()); // false;
308
+ */
327
309
  isEmpty() {
328
310
  return this.elements.length === 0;
329
311
  }
330
312
  /**
331
- * Get the top element without removing it.
332
- * @remarks Time O(1), Space O(1)
333
- * @returns Top element or undefined.
334
- */
313
+ * Get the top element without removing it.
314
+ * @remarks Time O(1), Space O(1)
315
+ * @returns Top element or undefined.
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+ * @example
328
+ * // View the top element without removing it
329
+ * const stack = new Stack<string>(['a', 'b', 'c']);
330
+ * console.log(stack.peek()); // 'c';
331
+ * console.log(stack.size); // 3;
332
+ */
335
333
  peek() {
336
334
  return this.isEmpty() ? void 0 : this.elements[this.elements.length - 1];
337
335
  }
338
336
  /**
339
- * Push one element onto the top.
340
- * @remarks Time O(1), Space O(1)
341
- * @param element - Element to push.
342
- * @returns True when pushed.
343
- */
337
+ * Push one element onto the top.
338
+ * @remarks Time O(1), Space O(1)
339
+ * @param element - Element to push.
340
+ * @returns True when pushed.
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+ * @example
353
+ * // basic Stack creation and push operation
354
+ * // Create a simple Stack with initial values
355
+ * const stack = new Stack([1, 2, 3, 4, 5]);
356
+ *
357
+ * // Verify the stack maintains insertion order (LIFO will be shown in pop)
358
+ * console.log([...stack]); // [1, 2, 3, 4, 5];
359
+ *
360
+ * // Check length
361
+ * console.log(stack.size); // 5;
362
+ *
363
+ * // Push a new element to the top
364
+ * stack.push(6);
365
+ * console.log(stack.size); // 6;
366
+ */
344
367
  push(element) {
345
368
  this.elements.push(element);
346
369
  return true;
347
370
  }
348
371
  /**
349
- * Pop and return the top element.
350
- * @remarks Time O(1), Space O(1)
351
- * @returns Removed element or undefined.
352
- */
372
+ * Pop and return the top element.
373
+ * @remarks Time O(1), Space O(1)
374
+ * @returns Removed element or undefined.
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+ * @example
387
+ * // Stack pop operation (LIFO - Last In First Out)
388
+ * const stack = new Stack<number>([10, 20, 30, 40, 50]);
389
+ *
390
+ * // Peek at the top element without removing
391
+ * const top = stack.peek();
392
+ * console.log(top); // 50;
393
+ *
394
+ * // Pop removes from the top (LIFO order)
395
+ * const popped = stack.pop();
396
+ * console.log(popped); // 50;
397
+ *
398
+ * // Next pop gets the previous element
399
+ * const next = stack.pop();
400
+ * console.log(next); // 40;
401
+ *
402
+ * // Verify length decreased
403
+ * console.log(stack.size); // 3;
404
+ */
353
405
  pop() {
354
406
  return this.isEmpty() ? void 0 : this.elements.pop();
355
407
  }
@@ -368,11 +420,24 @@ var _Stack = class _Stack extends IterableElementBase {
368
420
  return ans;
369
421
  }
370
422
  /**
371
- * Delete the first occurrence of a specific element.
372
- * @remarks Time O(N), Space O(1)
373
- * @param element - Element to remove (using the configured equality).
374
- * @returns True if an element was removed.
375
- */
423
+ * Delete the first occurrence of a specific element.
424
+ * @remarks Time O(N), Space O(1)
425
+ * @param element - Element to remove (using the configured equality).
426
+ * @returns True if an element was removed.
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+ * @example
436
+ * // Remove element
437
+ * const stack = new Stack<number>([1, 2, 3]);
438
+ * stack.delete(2);
439
+ * console.log(stack.toArray()); // [1, 3];
440
+ */
376
441
  delete(element) {
377
442
  const idx = this._indexOfByEquals(element);
378
443
  return this.deleteAt(idx);
@@ -404,30 +469,74 @@ var _Stack = class _Stack extends IterableElementBase {
404
469
  return false;
405
470
  }
406
471
  /**
407
- * Remove all elements and reset storage.
408
- * @remarks Time O(1), Space O(1)
409
- * @returns void
410
- */
472
+ * Remove all elements and reset storage.
473
+ * @remarks Time O(1), Space O(1)
474
+ * @returns void
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+ * @example
485
+ * // Remove all elements
486
+ * const stack = new Stack<number>([1, 2, 3]);
487
+ * stack.clear();
488
+ * console.log(stack.isEmpty()); // true;
489
+ */
411
490
  clear() {
412
491
  this._elements = [];
413
492
  }
414
493
  /**
415
- * Deep clone this stack.
416
- * @remarks Time O(N), Space O(N)
417
- * @returns A new stack with the same content.
418
- */
494
+ * Deep clone this stack.
495
+ * @remarks Time O(N), Space O(N)
496
+ * @returns A new stack with the same content.
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+ * @example
507
+ * // Create independent copy
508
+ * const stack = new Stack<number>([1, 2, 3]);
509
+ * const copy = stack.clone();
510
+ * copy.pop();
511
+ * console.log(stack.size); // 3;
512
+ * console.log(copy.size); // 2;
513
+ */
419
514
  clone() {
420
515
  const out = this._createInstance({ toElementFn: this.toElementFn });
421
516
  for (const v of this) out.push(v);
422
517
  return out;
423
518
  }
424
519
  /**
425
- * Filter elements into a new stack of the same class.
426
- * @remarks Time O(N), Space O(N)
427
- * @param predicate - Predicate (value, index, stack) → boolean to keep value.
428
- * @param [thisArg] - Value for `this` inside the predicate.
429
- * @returns A new stack with kept values.
430
- */
520
+ * Filter elements into a new stack of the same class.
521
+ * @remarks Time O(N), Space O(N)
522
+ * @param predicate - Predicate (value, index, stack) → boolean to keep value.
523
+ * @param [thisArg] - Value for `this` inside the predicate.
524
+ * @returns A new stack with kept values.
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+ * @example
535
+ * // Filter elements
536
+ * const stack = new Stack<number>([1, 2, 3, 4, 5]);
537
+ * const evens = stack.filter(x => x % 2 === 0);
538
+ * console.log(evens.toArray()); // [2, 4];
539
+ */
431
540
  filter(predicate, thisArg) {
432
541
  const out = this._createInstance({ toElementFn: this.toElementFn });
433
542
  let index = 0;
@@ -454,15 +563,28 @@ var _Stack = class _Stack extends IterableElementBase {
454
563
  return out;
455
564
  }
456
565
  /**
457
- * Map values into a new stack (possibly different element type).
458
- * @remarks Time O(N), Space O(N)
459
- * @template EM
460
- * @template RM
461
- * @param callback - Mapping function (value, index, stack) → newElement.
462
- * @param [options] - Options for the output stack (e.g., toElementFn).
463
- * @param [thisArg] - Value for `this` inside the callback.
464
- * @returns A new Stack with mapped elements.
465
- */
566
+ * Map values into a new stack (possibly different element type).
567
+ * @remarks Time O(N), Space O(N)
568
+ * @template EM
569
+ * @template RM
570
+ * @param callback - Mapping function (value, index, stack) → newElement.
571
+ * @param [options] - Options for the output stack (e.g., toElementFn).
572
+ * @param [thisArg] - Value for `this` inside the callback.
573
+ * @returns A new Stack with mapped elements.
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+ * @example
583
+ * // Transform elements
584
+ * const stack = new Stack<number>([1, 2, 3]);
585
+ * const doubled = stack.map(x => x * 2);
586
+ * console.log(doubled.toArray()); // [2, 4, 6];
587
+ */
466
588
  map(callback, options, thisArg) {
467
589
  const out = this._createLike([], { ...options != null ? options : {} });
468
590
  let index = 0;
@@ -526,6 +648,54 @@ var _Stack = class _Stack extends IterableElementBase {
526
648
  };
527
649
  __name(_Stack, "Stack");
528
650
  var Stack = _Stack;
651
+
652
+ // src/common/error.ts
653
+ var ERR = {
654
+ // Range / index
655
+ indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
656
+ invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
657
+ // Type / argument
658
+ invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
659
+ comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
660
+ invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
661
+ notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
662
+ invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
663
+ invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
664
+ invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
665
+ reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
666
+ callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
667
+ // State / operation
668
+ invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
669
+ // Matrix
670
+ matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
671
+ matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
672
+ matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
673
+ matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
674
+ matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
675
+ };
676
+
677
+ // src/common/index.ts
678
+ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
679
+ DFSOperation2[DFSOperation2["VISIT"] = 0] = "VISIT";
680
+ DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
681
+ return DFSOperation2;
682
+ })(DFSOperation || {});
683
+ var _Range = class _Range {
684
+ constructor(low, high, includeLow = true, includeHigh = true) {
685
+ this.low = low;
686
+ this.high = high;
687
+ this.includeLow = includeLow;
688
+ this.includeHigh = includeHigh;
689
+ }
690
+ // Determine whether a key is within the range
691
+ isInRange(key, comparator) {
692
+ const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
693
+ const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
694
+ return lowCheck && highCheck;
695
+ }
696
+ };
697
+ __name(_Range, "Range");
698
+ var Range = _Range;
529
699
  /**
530
700
  * data-structure-typed
531
701
  *