data-structure-typed 1.48.2 → 1.48.4

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/CHANGELOG.md +1 -1
  2. package/README.md +22 -22
  3. package/benchmark/report.html +16 -16
  4. package/benchmark/report.json +184 -184
  5. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +16 -16
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.js +7 -7
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +89 -87
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js +67 -58
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/bst.d.ts +28 -47
  12. package/dist/cjs/data-structures/binary-tree/bst.js +54 -57
  13. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +15 -15
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.js +7 -7
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +22 -22
  18. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +11 -11
  19. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  20. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +1 -0
  21. package/dist/cjs/data-structures/graph/abstract-graph.js +4 -0
  22. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/directed-graph.d.ts +25 -7
  24. package/dist/cjs/data-structures/graph/directed-graph.js +58 -12
  25. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  26. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +25 -6
  27. package/dist/cjs/data-structures/graph/undirected-graph.js +70 -7
  28. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  29. package/dist/cjs/interfaces/binary-tree.d.ts +6 -6
  30. package/dist/cjs/types/common.d.ts +11 -8
  31. package/dist/cjs/types/common.js +6 -1
  32. package/dist/cjs/types/common.js.map +1 -1
  33. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
  34. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  35. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +6 -6
  36. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
  37. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
  38. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +16 -16
  39. package/dist/mjs/data-structures/binary-tree/avl-tree.js +7 -7
  40. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +89 -87
  41. package/dist/mjs/data-structures/binary-tree/binary-tree.js +67 -58
  42. package/dist/mjs/data-structures/binary-tree/bst.d.ts +28 -47
  43. package/dist/mjs/data-structures/binary-tree/bst.js +55 -57
  44. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +15 -15
  45. package/dist/mjs/data-structures/binary-tree/rb-tree.js +7 -7
  46. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +22 -22
  47. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +11 -11
  48. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +1 -0
  49. package/dist/mjs/data-structures/graph/abstract-graph.js +4 -0
  50. package/dist/mjs/data-structures/graph/directed-graph.d.ts +25 -7
  51. package/dist/mjs/data-structures/graph/directed-graph.js +58 -12
  52. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +25 -6
  53. package/dist/mjs/data-structures/graph/undirected-graph.js +70 -7
  54. package/dist/mjs/interfaces/binary-tree.d.ts +6 -6
  55. package/dist/mjs/types/common.d.ts +11 -8
  56. package/dist/mjs/types/common.js +5 -0
  57. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
  58. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  59. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +6 -6
  60. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
  61. package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
  62. package/dist/umd/data-structure-typed.js +276 -158
  63. package/dist/umd/data-structure-typed.min.js +2 -2
  64. package/dist/umd/data-structure-typed.min.js.map +1 -1
  65. package/package.json +2 -2
  66. package/src/data-structures/binary-tree/avl-tree.ts +20 -21
  67. package/src/data-structures/binary-tree/binary-tree.ts +147 -136
  68. package/src/data-structures/binary-tree/bst.ts +86 -82
  69. package/src/data-structures/binary-tree/rb-tree.ts +25 -26
  70. package/src/data-structures/binary-tree/tree-multimap.ts +30 -35
  71. package/src/data-structures/graph/abstract-graph.ts +5 -0
  72. package/src/data-structures/graph/directed-graph.ts +61 -12
  73. package/src/data-structures/graph/undirected-graph.ts +75 -7
  74. package/src/interfaces/binary-tree.ts +5 -6
  75. package/src/types/common.ts +11 -8
  76. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -3
  77. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -5
  78. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  79. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -3
  80. package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -3
  81. package/test/integration/bst.test.ts +1 -1
  82. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +3 -3
  83. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +6 -6
  84. package/test/unit/data-structures/binary-tree/bst.test.ts +10 -9
  85. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  86. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +1 -1
  87. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +5 -5
  88. package/test/unit/data-structures/graph/directed-graph.test.ts +37 -0
  89. package/test/unit/data-structures/graph/undirected-graph.test.ts +37 -0
  90. package/test/unit/unrestricted-interconversion.test.ts +1 -1
@@ -85,15 +85,22 @@ export class BinaryTree extends IterablePairBase {
85
85
  constructor(elements, options) {
86
86
  super();
87
87
  if (options) {
88
- const { iterationType } = options;
88
+ const { iterationType, extractor } = options;
89
89
  if (iterationType) {
90
90
  this.iterationType = iterationType;
91
91
  }
92
+ if (extractor) {
93
+ this._extractor = extractor;
94
+ }
92
95
  }
93
96
  this._size = 0;
94
97
  if (elements)
95
98
  this.addMany(elements);
96
99
  }
100
+ _extractor = (key) => Number(key);
101
+ get extractor() {
102
+ return this._extractor;
103
+ }
97
104
  _root;
98
105
  get root() {
99
106
  return this._root;
@@ -104,7 +111,7 @@ export class BinaryTree extends IterablePairBase {
104
111
  }
105
112
  /**
106
113
  * Creates a new instance of BinaryTreeNode with the given key and value.
107
- * @param {BTNKey} key - The key for the new node.
114
+ * @param {K} key - The key for the new node.
108
115
  * @param {V} value - The value for the new node.
109
116
  * @returns {N} - The newly created BinaryTreeNode.
110
117
  */
@@ -123,7 +130,7 @@ export class BinaryTree extends IterablePairBase {
123
130
  }
124
131
  /**
125
132
  * The function "isNode" checks if an exemplar is an instance of the BinaryTreeNode class.
126
- * @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<V, N>`.
133
+ * @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V,N>`.
127
134
  * @returns a boolean value indicating whether the exemplar is an instance of the class N.
128
135
  */
129
136
  isNode(exemplar) {
@@ -132,7 +139,7 @@ export class BinaryTree extends IterablePairBase {
132
139
  /**
133
140
  * The function `exemplarToNode` converts an exemplar of a binary tree node into an actual node
134
141
  * object.
135
- * @param exemplar - BTNodeExemplar<V, N> - A generic type representing the exemplar parameter of the
142
+ * @param exemplar - BTNodeExemplar<K, V,N> - A generic type representing the exemplar parameter of the
136
143
  * function. It can be any type.
137
144
  * @returns a value of type `N` (which represents a node), or `null`, or `undefined`.
138
145
  */
@@ -158,7 +165,7 @@ export class BinaryTree extends IterablePairBase {
158
165
  else if (this.isNode(exemplar)) {
159
166
  node = exemplar;
160
167
  }
161
- else if (this.isNodeKey(exemplar)) {
168
+ else if (this.isNotNodeInstance(exemplar)) {
162
169
  node = this.createNode(exemplar);
163
170
  }
164
171
  else {
@@ -168,7 +175,7 @@ export class BinaryTree extends IterablePairBase {
168
175
  }
169
176
  /**
170
177
  * The function checks if a given value is an entry in a binary tree node.
171
- * @param kne - BTNodeExemplar<V, N> - A generic type representing a node in a binary tree. It has
178
+ * @param kne - BTNodeExemplar<K, V,N> - A generic type representing a node in a binary tree. It has
172
179
  * two type parameters V and N, representing the value and node type respectively.
173
180
  * @returns a boolean value.
174
181
  */
@@ -236,7 +243,7 @@ export class BinaryTree extends IterablePairBase {
236
243
  * The function `addMany` takes in an iterable of `BTNodeExemplar` objects, adds each object to the
237
244
  * current instance, and returns an array of the inserted nodes.
238
245
  * @param nodes - The `nodes` parameter is an iterable (such as an array or a set) of
239
- * `BTNodeExemplar<V, N>` objects.
246
+ * `BTNodeExemplar<K, V,N>` objects.
240
247
  * @returns The function `addMany` returns an array of values, where each value is either of type
241
248
  * `N`, `null`, or `undefined`.
242
249
  */
@@ -336,11 +343,11 @@ export class BinaryTree extends IterablePairBase {
336
343
  * Space Complexity: O(1)
337
344
  *
338
345
  * The function calculates the depth of a given node in a binary tree.
339
- * @param {BTNKey | N | null | undefined} distNode - The `distNode` parameter represents the node in
340
- * the binary tree whose depth we want to find. It can be of type `BTNKey`, `N`, `null`, or
346
+ * @param {K | N | null | undefined} distNode - The `distNode` parameter represents the node in
347
+ * the binary tree whose depth we want to find. It can be of type `K`, `N`, `null`, or
341
348
  * `undefined`.
342
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
343
- * from which we want to calculate the depth. It can be either a `BTNKey` (binary tree node key) or
349
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
350
+ * from which we want to calculate the depth. It can be either a `K` (binary tree node key) or
344
351
  * `N` (binary tree node) or `null` or `undefined`. If no value is provided for `beginRoot
345
352
  * @returns the depth of the `distNode` relative to the `beginRoot`.
346
353
  */
@@ -367,9 +374,9 @@ export class BinaryTree extends IterablePairBase {
367
374
  *
368
375
  * The function `getHeight` calculates the maximum height of a binary tree using either recursive or
369
376
  * iterative traversal.
370
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
377
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
371
378
  * starting node of the binary tree from which we want to calculate the height. It can be of type
372
- * `BTNKey`, `N`, `null`, or `undefined`. If not provided, it defaults to `this.root`.
379
+ * `K`, `N`, `null`, or `undefined`. If not provided, it defaults to `this.root`.
373
380
  * @param iterationType - The `iterationType` parameter is used to determine whether to calculate the
374
381
  * height of the tree using a recursive approach or an iterative approach. It can have two possible
375
382
  * values:
@@ -414,9 +421,9 @@ export class BinaryTree extends IterablePairBase {
414
421
  *
415
422
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a
416
423
  * recursive or iterative approach.
417
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
424
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
418
425
  * starting node of the binary tree from which we want to calculate the minimum height. It can be of
419
- * type `BTNKey`, `N`, `null`, or `undefined`. If no value is provided, it defaults to `this.root`.
426
+ * type `K`, `N`, `null`, or `undefined`. If no value is provided, it defaults to `this.root`.
420
427
  * @param iterationType - The `iterationType` parameter is used to determine the method of iteration
421
428
  * to calculate the minimum height of a binary tree. It can have two possible values:
422
429
  * @returns The function `getMinHeight` returns the minimum height of a binary tree.
@@ -476,8 +483,8 @@ export class BinaryTree extends IterablePairBase {
476
483
  *
477
484
  * The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
478
485
  * height of the tree.
479
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
480
- * for calculating the height and minimum height of a binary tree. It can be either a `BTNKey` (a key
486
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
487
+ * for calculating the height and minimum height of a binary tree. It can be either a `K` (a key
481
488
  * value of a binary tree node), `N` (a node of a binary tree), `null`, or `undefined`. If
482
489
  * @returns a boolean value.
483
490
  */
@@ -502,7 +509,7 @@ export class BinaryTree extends IterablePairBase {
502
509
  * matches the identifier. If set to true, the function will stop iterating once it finds a matching
503
510
  * node and return that node. If set to false (default), the function will continue iterating and
504
511
  * return all nodes that match the identifier.
505
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
512
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
506
513
  * starting node for the traversal. It can be either a key, a node object, or `null`/`undefined`. If
507
514
  * it is `null` or `undefined`, an empty array will be returned.
508
515
  * @param iterationType - The `iterationType` parameter determines the type of iteration used to
@@ -559,8 +566,8 @@ export class BinaryTree extends IterablePairBase {
559
566
  * the binary tree. It is used to filter the nodes based on certain conditions. The `callback`
560
567
  * function should return a boolean value indicating whether the node should be included in the
561
568
  * result or not.
562
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
563
- * for the search in the binary tree. It can be specified as a `BTNKey` (a unique identifier for a
569
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
570
+ * for the search in the binary tree. It can be specified as a `K` (a unique identifier for a
564
571
  * node in the binary tree), a node object (`N`), or `null`/`undefined` to start the search from
565
572
  * @param iterationType - The `iterationType` parameter is a variable that determines the type of
566
573
  * iteration to be performed on the binary tree. It is used to specify whether the iteration should
@@ -585,7 +592,7 @@ export class BinaryTree extends IterablePairBase {
585
592
  * @param {C} callback - The `callback` parameter is a function that will be called for each node in
586
593
  * the binary tree. It is used to determine if a node matches the given identifier. The `callback`
587
594
  * function should take a single parameter of type `N` (the type of the nodes in the binary tree) and
588
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
595
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
589
596
  * for searching the binary tree. It can be either a key value, a node object, or `null`/`undefined`.
590
597
  * If `null` or `undefined` is passed, the search will start from the root of the binary tree.
591
598
  * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
@@ -608,7 +615,7 @@ export class BinaryTree extends IterablePairBase {
608
615
  *
609
616
  * The function `getNodeByKey` searches for a node in a binary tree by its key, using either
610
617
  * recursive or iterative iteration.
611
- * @param {BTNKey} key - The `key` parameter is the key value that we are searching for in the tree.
618
+ * @param {K} key - The `key` parameter is the key value that we are searching for in the tree.
612
619
  * It is used to find the node with the matching key value.
613
620
  * @param iterationType - The `iterationType` parameter is used to determine whether the search for
614
621
  * the node with the given key should be performed iteratively or recursively. It has two possible
@@ -652,7 +659,7 @@ export class BinaryTree extends IterablePairBase {
652
659
  /**
653
660
  * The function `ensureNode` returns the node corresponding to the given key if it is a valid node
654
661
  * key, otherwise it returns the key itself.
655
- * @param {BTNKey | N | null | undefined} key - The `key` parameter can be of type `BTNKey`, `N`,
662
+ * @param {K | N | null | undefined} key - The `key` parameter can be of type `K`, `N`,
656
663
  * `null`, or `undefined`. It represents a key used to identify a node in a binary tree.
657
664
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
658
665
  * type of iteration to be used when searching for a node by key. It has a default value of
@@ -661,7 +668,7 @@ export class BinaryTree extends IterablePairBase {
661
668
  * itself if it is not a valid node key.
662
669
  */
663
670
  ensureNode(key, iterationType = IterationType.ITERATIVE) {
664
- return this.isNodeKey(key) ? this.getNodeByKey(key, iterationType) : key;
671
+ return this.isNotNodeInstance(key) ? this.getNodeByKey(key, iterationType) : key;
665
672
  }
666
673
  /**
667
674
  * Time Complexity: O(n)
@@ -676,8 +683,8 @@ export class BinaryTree extends IterablePairBase {
676
683
  * the binary tree. It is used to determine whether a node matches the given identifier. The callback
677
684
  * function should return a value that can be compared to the identifier to determine if it is a
678
685
  * match.
679
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
680
- * for the search in the binary tree. It can be specified as a `BTNKey` (a unique identifier for a
686
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
687
+ * for the search in the binary tree. It can be specified as a `K` (a unique identifier for a
681
688
  * node), a node object of type `N`, or `null`/`undefined` to start the search from the root of
682
689
  * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
683
690
  * be performed when searching for a node in the binary tree. It is an optional parameter with a
@@ -714,8 +721,8 @@ export class BinaryTree extends IterablePairBase {
714
721
  *
715
722
  * The function `getPathToRoot` returns an array of nodes from a given node to the root of a tree
716
723
  * structure, with the option to reverse the order of the nodes.
717
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
718
- * starting node from which you want to find the path to the root. It can be of type `BTNKey`, `N`,
724
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
725
+ * starting node from which you want to find the path to the root. It can be of type `K`, `N`,
719
726
  * `null`, or `undefined`.
720
727
  * @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
721
728
  * resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be
@@ -747,8 +754,8 @@ export class BinaryTree extends IterablePairBase {
747
754
  *
748
755
  * The function `getLeftMost` returns the leftmost node in a binary tree, either recursively or
749
756
  * iteratively.
750
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
751
- * for finding the leftmost node in a binary tree. It can be either a `BTNKey` (a key value), `N` (a
757
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
758
+ * for finding the leftmost node in a binary tree. It can be either a `K` (a key value), `N` (a
752
759
  * node), `null`, or `undefined`. If not provided, it defaults to `this.root`,
753
760
  * @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
754
761
  * be performed when finding the leftmost node in a binary tree. It can have two possible values:
@@ -787,8 +794,8 @@ export class BinaryTree extends IterablePairBase {
787
794
  *
788
795
  * The function `getRightMost` returns the rightmost node in a binary tree, either recursively or
789
796
  * iteratively.
790
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
791
- * starting node from which we want to find the rightmost node. It can be of type `BTNKey`, `N`,
797
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
798
+ * starting node from which we want to find the rightmost node. It can be of type `K`, `N`,
792
799
  * `null`, or `undefined`. If not provided, it defaults to `this.root`, which is a property of the
793
800
  * current object.
794
801
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
@@ -828,7 +835,7 @@ export class BinaryTree extends IterablePairBase {
828
835
  * Space Complexity: O(1)
829
836
  *
830
837
  * The function `isSubtreeBST` checks if a given binary tree is a valid binary search tree.
831
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the root
838
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the root
832
839
  * node of the binary search tree (BST) that you want to check if it is a subtree of another BST.
833
840
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
834
841
  * type of iteration to use when checking if a subtree is a binary search tree (BST). It can have two
@@ -844,9 +851,10 @@ export class BinaryTree extends IterablePairBase {
844
851
  const dfs = (cur, min, max) => {
845
852
  if (!cur)
846
853
  return true;
847
- if (cur.key <= min || cur.key >= max)
854
+ const numKey = this.extractor(cur.key);
855
+ if (numKey <= min || numKey >= max)
848
856
  return false;
849
- return dfs(cur.left, min, cur.key) && dfs(cur.right, cur.key, max);
857
+ return dfs(cur.left, min, numKey) && dfs(cur.right, numKey, max);
850
858
  };
851
859
  return dfs(beginRoot, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
852
860
  }
@@ -859,9 +867,10 @@ export class BinaryTree extends IterablePairBase {
859
867
  curr = curr.left;
860
868
  }
861
869
  curr = stack.pop();
862
- if (!curr || prev >= curr.key)
870
+ const numKey = this.extractor(curr.key);
871
+ if (!curr || prev >= numKey)
863
872
  return false;
864
- prev = curr.key;
873
+ prev = numKey;
865
874
  curr = curr.right;
866
875
  }
867
876
  return true;
@@ -896,8 +905,8 @@ export class BinaryTree extends IterablePairBase {
896
905
  * @param {C} callback - The `callback` parameter is a function that will be called for each node in
897
906
  * the subtree traversal. It takes a single parameter, which is the current node being traversed, and
898
907
  * returns a value of any type.
899
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
900
- * starting node or key from which the subtree traversal should begin. It can be of type `BTNKey`,
908
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
909
+ * starting node or key from which the subtree traversal should begin. It can be of type `K`,
901
910
  * `N`, `null`, or `undefined`. If not provided, the `root` property of the current object is used as
902
911
  * the default value.
903
912
  * @param iterationType - The `iterationType` parameter determines the type of traversal to be
@@ -979,13 +988,13 @@ export class BinaryTree extends IterablePairBase {
979
988
  return this.isRealNode(node) || node === null;
980
989
  }
981
990
  /**
982
- * The function "isNodeKey" checks if a potential key is a number.
991
+ * The function "isNotNodeInstance" checks if a potential key is a number.
983
992
  * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
984
993
  * data type.
985
994
  * @returns a boolean value indicating whether the potentialKey is of type number or not.
986
995
  */
987
- isNodeKey(potentialKey) {
988
- return typeof potentialKey === 'number';
996
+ isNotNodeInstance(potentialKey) {
997
+ return !(potentialKey instanceof BinaryTreeNode);
989
998
  }
990
999
  /**
991
1000
  * Time complexity: O(n)
@@ -999,7 +1008,7 @@ export class BinaryTree extends IterablePairBase {
999
1008
  * `null`, or `undefined`, and returns a value of any type. The default value for this parameter is
1000
1009
  * @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter determines the order in which the
1001
1010
  * nodes are traversed during the depth-first search. It can have one of the following values:
1002
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
1011
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
1003
1012
  * for the depth-first search traversal. It can be specified as a key, a node object, or
1004
1013
  * `null`/`undefined`. If not provided, the `beginRoot` will default to the root node of the tree.
1005
1014
  * @param {IterationType} iterationType - The `iterationType` parameter determines the type of
@@ -1125,7 +1134,7 @@ export class BinaryTree extends IterablePairBase {
1125
1134
  * @param {C} callback - The `callback` parameter is a function that will be called for each node in
1126
1135
  * the breadth-first search traversal. It takes a single parameter, which is the current node being
1127
1136
  * visited, and returns a value of any type.
1128
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
1137
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
1129
1138
  * starting node for the breadth-first search traversal. It can be specified as a key, a node object,
1130
1139
  * or `null`/`undefined` to indicate the root of the tree. If not provided, the `root` property of
1131
1140
  * the class is used as
@@ -1199,9 +1208,9 @@ export class BinaryTree extends IterablePairBase {
1199
1208
  * @param {C} callback - The `callback` parameter is a function that will be called for each node in
1200
1209
  * the tree. It takes a single parameter, which can be of type `N`, `null`, or `undefined`, and
1201
1210
  * returns a value of any type.
1202
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
1211
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
1203
1212
  * starting node for traversing the tree. It can be either a node object (`N`), a key value
1204
- * (`BTNKey`), `null`, or `undefined`. If not provided, it defaults to the root node of the tree.
1213
+ * (`K`), `null`, or `undefined`. If not provided, it defaults to the root node of the tree.
1205
1214
  * @param iterationType - The `iterationType` parameter determines the type of iteration to be
1206
1215
  * performed on the tree. It can have two possible values:
1207
1216
  * @param [includeNull=false] - The `includeNull` parameter is a boolean value that determines
@@ -1261,7 +1270,7 @@ export class BinaryTree extends IterablePairBase {
1261
1270
  }
1262
1271
  /**
1263
1272
  * The function `getPredecessor` returns the predecessor node of a given node in a binary tree.
1264
- * @param {BTNKey | N | null | undefined} node - The `node` parameter can be of type `BTNKey`, `N`,
1273
+ * @param {K | N | null | undefined} node - The `node` parameter can be of type `K`, `N`,
1265
1274
  * `null`, or `undefined`.
1266
1275
  * @returns The function `getPredecessor` returns a value of type `N | undefined`.
1267
1276
  */
@@ -1284,7 +1293,7 @@ export class BinaryTree extends IterablePairBase {
1284
1293
  }
1285
1294
  /**
1286
1295
  * The function `getSuccessor` returns the next node in a binary tree given a current node.
1287
- * @param {BTNKey | N | null} [x] - The parameter `x` can be of type `BTNKey`, `N`, or `null`.
1296
+ * @param {K | N | null} [x] - The parameter `x` can be of type `K`, `N`, or `null`.
1288
1297
  * @returns the successor of the given node or key. The successor is the node that comes immediately
1289
1298
  * after the given node in the inorder traversal of the binary tree.
1290
1299
  */
@@ -1313,7 +1322,7 @@ export class BinaryTree extends IterablePairBase {
1313
1322
  * @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter in the `morris` function
1314
1323
  * determines the order in which the nodes of a binary tree are traversed. It can have one of the
1315
1324
  * following values:
1316
- * @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
1325
+ * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node
1317
1326
  * for the traversal. It can be specified as a key, a node object, or `null`/`undefined` to indicate
1318
1327
  * the root of the tree. If no value is provided, the default value is the root of the tree.
1319
1328
  * @returns The function `morris` returns an array of values that are the result of invoking the
@@ -1479,7 +1488,7 @@ export class BinaryTree extends IterablePairBase {
1479
1488
  return newTree;
1480
1489
  }
1481
1490
  // // TODO Type error, need to return a TREE<NV> that is a value type only for callback function.
1482
- // // map<NV>(callback: (entry: [BTNKey, V | undefined], tree: this) => NV) {
1491
+ // // map<NV>(callback: (entry: [K, V | undefined], tree: this) => NV) {
1483
1492
  // // const newTree = this.createTree();
1484
1493
  // // for (const [key, value] of this) {
1485
1494
  // // newTree.add(key, callback([key, value], this));
@@ -1489,7 +1498,7 @@ export class BinaryTree extends IterablePairBase {
1489
1498
  //
1490
1499
  /**
1491
1500
  * The `print` function is used to display a binary tree structure in a visually appealing way.
1492
- * @param {BTNKey | N | null | undefined} [beginRoot=this.root] - The `root` parameter is of type `BTNKey | N | null |
1501
+ * @param {K | N | null | undefined} [beginRoot=this.root] - The `root` parameter is of type `K | N | null |
1493
1502
  * undefined`. It represents the root node of a binary tree. The root node can have one of the
1494
1503
  * following types:
1495
1504
  * @param {BinaryTreePrintOptions} [options={ isShowUndefined: false, isShowNull: false, isShowRedBlackNIL: false}] - Options object that controls printing behavior. You can specify whether to display undefined, null, or sentinel nodes.
@@ -1523,23 +1532,23 @@ export class BinaryTree extends IterablePairBase {
1523
1532
  const stack = [];
1524
1533
  let current = node;
1525
1534
  while (current || stack.length > 0) {
1526
- while (current && !isNaN(current.key)) {
1535
+ while (current && !isNaN(this.extractor(current.key))) {
1527
1536
  stack.push(current);
1528
1537
  current = current.left;
1529
1538
  }
1530
1539
  current = stack.pop();
1531
- if (current && !isNaN(current.key)) {
1540
+ if (current && !isNaN(this.extractor(current.key))) {
1532
1541
  yield [current.key, current.value];
1533
1542
  current = current.right;
1534
1543
  }
1535
1544
  }
1536
1545
  }
1537
1546
  else {
1538
- if (node.left && !isNaN(node.key)) {
1547
+ if (node.left && !isNaN(this.extractor(node.key))) {
1539
1548
  yield* this[Symbol.iterator](node.left);
1540
1549
  }
1541
1550
  yield [node.key, node.value];
1542
- if (node.right && !isNaN(node.key)) {
1551
+ if (node.right && !isNaN(this.extractor(node.key))) {
1543
1552
  yield* this[Symbol.iterator](node.right);
1544
1553
  }
1545
1554
  }
@@ -1554,12 +1563,12 @@ export class BinaryTree extends IterablePairBase {
1554
1563
  else if (node === undefined && !isShowUndefined) {
1555
1564
  return emptyDisplayLayout;
1556
1565
  }
1557
- else if (node !== null && node !== undefined && isNaN(node.key) && !isShowRedBlackNIL) {
1566
+ else if (node !== null && node !== undefined && isNaN(this.extractor(node.key)) && !isShowRedBlackNIL) {
1558
1567
  return emptyDisplayLayout;
1559
1568
  }
1560
1569
  else if (node !== null && node !== undefined) {
1561
1570
  // Display logic of normal nodes
1562
- const key = node.key, line = isNaN(key) ? 'S' : key.toString(), width = line.length;
1571
+ const key = node.key, line = isNaN(this.extractor(key)) ? 'S' : this.extractor(key).toString(), width = line.length;
1563
1572
  return _buildNodeDisplay(line, width, this._displayAux(node.left, options), this._displayAux(node.right, options));
1564
1573
  }
1565
1574
  else {
@@ -1647,7 +1656,7 @@ export class BinaryTree extends IterablePairBase {
1647
1656
  * If the parent node is null, the function also returns undefined.
1648
1657
  */
1649
1658
  _addTo(newNode, parent) {
1650
- if (this.isNodeKey(parent))
1659
+ if (this.isNotNodeInstance(parent))
1651
1660
  parent = this.getNode(parent);
1652
1661
  if (parent) {
1653
1662
  // When all leaf nodes are null, it will no longer be possible to add new entity nodes to this binary tree.
@@ -5,13 +5,13 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BSTNested, BSTNodeKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNKey, BTNodeExemplar, Comparator } from '../../types';
9
- import { CP, IterationType } from '../../types';
8
+ import type { BSTNested, BSTNodeKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNodeExemplar } from '../../types';
9
+ import { BSTVariant, CP, IterationType } from '../../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
11
  import { IBinaryTree } from '../../interfaces';
12
- export declare class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>> extends BinaryTreeNode<V, N> {
12
+ export declare class BSTNode<K = any, V = any, N extends BSTNode<K, V, N> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, N> {
13
13
  parent?: N;
14
- constructor(key: BTNKey, value?: V);
14
+ constructor(key: K, value?: V);
15
15
  protected _left?: N;
16
16
  /**
17
17
  * Get the left child node.
@@ -42,7 +42,7 @@ export declare class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>
42
42
  * 6. Balance Variability: Can become unbalanced; special types maintain balance.
43
43
  * 7. No Auto-Balancing: Standard BSTs don't automatically balance themselves.
44
44
  */
45
- export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNested<V>>, TREE extends BST<V, N, TREE> = BST<V, N, BSTNested<V, N>>> extends BinaryTree<V, N, TREE> implements IBinaryTree<V, N, TREE> {
45
+ export declare class BST<K = any, V = any, N extends BSTNode<K, V, N> = BSTNode<K, V, BSTNodeNested<K, V>>, TREE extends BST<K, V, N, TREE> = BST<K, V, N, BSTNested<K, V, N>>> extends BinaryTree<K, V, N, TREE> implements IBinaryTree<K, V, N, TREE> {
46
46
  /**
47
47
  * This is the constructor function for a binary search tree class in TypeScript, which initializes
48
48
  * the tree with optional elements and options.
@@ -51,19 +51,20 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
51
51
  * @param [options] - The `options` parameter is an optional object that can contain additional
52
52
  * configuration options for the binary search tree. It can have the following properties:
53
53
  */
54
- constructor(elements?: Iterable<BTNodeExemplar<V, N>>, options?: Partial<BSTOptions>);
54
+ constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<BSTOptions<K>>);
55
55
  protected _root?: N;
56
56
  get root(): N | undefined;
57
- comparator: Comparator<BTNKey>;
57
+ protected _variant: BSTVariant;
58
+ get variant(): BSTVariant;
58
59
  /**
59
60
  * The function creates a new binary search tree node with the given key and value.
60
- * @param {BTNKey} key - The key parameter is the key value that will be associated with
61
+ * @param {K} key - The key parameter is the key value that will be associated with
61
62
  * the new node. It is used to determine the position of the node in the binary search tree.
62
63
  * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
63
64
  * represents the value associated with the node in a binary search tree.
64
65
  * @returns a new instance of the BSTNode class with the specified key and value.
65
66
  */
66
- createNode(key: BTNKey, value?: V): N;
67
+ createNode(key: K, value?: V): N;
67
68
  /**
68
69
  * The function creates a new binary search tree with the specified options.
69
70
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
@@ -71,20 +72,20 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
71
72
  * that defines various options for creating a binary search tree.
72
73
  * @returns a new instance of the BST class with the specified options.
73
74
  */
74
- createTree(options?: Partial<BSTOptions>): TREE;
75
+ createTree(options?: Partial<BSTOptions<K>>): TREE;
75
76
  /**
76
77
  * The function checks if an exemplar is an instance of BSTNode.
77
- * @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<V, N>`.
78
+ * @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V, N>`.
78
79
  * @returns a boolean value indicating whether the exemplar is an instance of the BSTNode class.
79
80
  */
80
- isNode(exemplar: BTNodeExemplar<V, N>): exemplar is N;
81
+ isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N;
81
82
  /**
82
83
  * The function `exemplarToNode` takes an exemplar and returns a corresponding node if the exemplar
83
84
  * is valid, otherwise it returns undefined.
84
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<V, N>`.
85
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
85
86
  * @returns a variable `node` which is of type `N` or `undefined`.
86
87
  */
87
- exemplarToNode(exemplar: BTNodeExemplar<V, N>): N | undefined;
88
+ exemplarToNode(exemplar: BTNodeExemplar<K, V, N>): N | undefined;
88
89
  /**
89
90
  * Time Complexity: O(log n) - Average case for a balanced tree. In the worst case (unbalanced tree), it can be O(n).
90
91
  * Space Complexity: O(1) - Constant space is used.
@@ -99,7 +100,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
99
100
  * @returns The method returns either the newly added node (`newNode`) or `undefined` if the input
100
101
  * (`keyOrNodeOrEntry`) is null, undefined, or does not match any of the expected types.
101
102
  */
102
- add(keyOrNodeOrEntry: BTNodeExemplar<V, N>): N | undefined;
103
+ add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined;
103
104
  /**
104
105
  * Time Complexity: O(k log n) - Adding each element individually in a balanced tree.
105
106
  * Space Complexity: O(k) - Additional space is required for the sorted array.
@@ -120,27 +121,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
120
121
  * tree instance.
121
122
  * @returns The `addMany` function returns an array of `N` or `undefined` values.
122
123
  */
123
- addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<V, N>>, isBalanceAdd?: boolean, iterationType?: IterationType): (N | undefined)[];
124
- /**
125
- * Time Complexity: O(n log n) - Adding each element individually in a balanced tree.
126
- * Space Complexity: O(n) - Additional space is required for the sorted array.
127
- */
128
- /**
129
- * Time Complexity: O(log n) - Average case for a balanced tree.
130
- * Space Complexity: O(1) - Constant space is used.
131
- *
132
- * The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
133
- * leftmost node if the comparison result is greater than.
134
- * @param {BTNKey | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
135
- * type `BTNKey`, `N`, or `undefined`. It represents the starting point for finding the last key in
136
- * the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
137
- * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
138
- * be performed. It can have one of the following values:
139
- * @returns the key of the rightmost node in the binary tree if the comparison result is less than,
140
- * the key of the leftmost node if the comparison result is greater than, and the key of the
141
- * rightmost node otherwise. If no node is found, it returns 0.
142
- */
143
- lastKey(beginRoot?: BSTNodeKeyOrNode<N>, iterationType?: IterationType): BTNKey;
124
+ addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>, isBalanceAdd?: boolean, iterationType?: IterationType): (N | undefined)[];
144
125
  /**
145
126
  * Time Complexity: O(log n) - Average case for a balanced tree.
146
127
  * Space Complexity: O(1) - Constant space is used.
@@ -151,7 +132,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
151
132
  *
152
133
  * The function `getNodeByKey` searches for a node in a binary tree based on a given key, using
153
134
  * either recursive or iterative methods.
154
- * @param {BTNKey} key - The `key` parameter is the key value that we are searching for in the tree.
135
+ * @param {K} key - The `key` parameter is the key value that we are searching for in the tree.
155
136
  * It is used to identify the node that we want to retrieve.
156
137
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
157
138
  * type of iteration to use when searching for a node in the binary tree. It can have two possible
@@ -159,7 +140,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
159
140
  * @returns The function `getNodeByKey` returns a node (`N`) if a node with the specified key is
160
141
  * found in the binary tree. If no node is found, it returns `undefined`.
161
142
  */
162
- getNodeByKey(key: BTNKey, iterationType?: IterationType): N | undefined;
143
+ getNodeByKey(key: K, iterationType?: IterationType): N | undefined;
163
144
  /**
164
145
  * Time Complexity: O(log n) - Average case for a balanced tree.
165
146
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -167,13 +148,13 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
167
148
  /**
168
149
  * The function `ensureNode` returns the node corresponding to the given key if it is a node key,
169
150
  * otherwise it returns the key itself.
170
- * @param {BTNKey | N | undefined} key - The `key` parameter can be of type `BTNKey`, `N`, or
151
+ * @param {K | N | undefined} key - The `key` parameter can be of type `K`, `N`, or
171
152
  * `undefined`.
172
153
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
173
154
  * type of iteration to be performed. It has a default value of `IterationType.ITERATIVE`.
174
155
  * @returns either a node object (N) or undefined.
175
156
  */
176
- ensureNode(key: BSTNodeKeyOrNode<N>, iterationType?: IterationType): N | undefined;
157
+ ensureNode(key: BSTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | undefined;
177
158
  /**
178
159
  * Time Complexity: O(log n) - Average case for a balanced tree. O(n) - Visiting each node once when identifier is not node's key.
179
160
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -190,14 +171,14 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
190
171
  * first node that matches the identifier. If set to true, the function will return an array
191
172
  * containing only the first matching node. If set to false (default), the function will continue
192
173
  * searching for all nodes that match the identifier and return an array containing
193
- * @param {BTNKey | N | undefined} beginRoot - The `beginRoot` parameter represents the starting node
174
+ * @param {K | N | undefined} beginRoot - The `beginRoot` parameter represents the starting node
194
175
  * for the traversal. It can be either a key value or a node object. If it is undefined, the
195
176
  * traversal will start from the root of the tree.
196
177
  * @param iterationType - The `iterationType` parameter determines the type of iteration to be
197
178
  * performed on the binary tree. It can have two possible values:
198
179
  * @returns The method returns an array of nodes (`N[]`).
199
180
  */
200
- getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BSTNodeKeyOrNode<N>, iterationType?: IterationType): N[];
181
+ getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BSTNodeKeyOrNode<K, N>, iterationType?: IterationType): N[];
201
182
  /**
202
183
  * Time Complexity: O(log n) - Average case for a balanced tree. O(n) - Visiting each node once when identifier is not node's key.
203
184
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -215,7 +196,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
215
196
  * traverse nodes that are lesser than, greater than, or equal to the `targetNode`. It is of type
216
197
  * `CP`, which is a custom type representing the comparison operator. The possible values for
217
198
  * `lesserOrGreater` are
218
- * @param {BTNKey | N | undefined} targetNode - The `targetNode` parameter represents the node in the
199
+ * @param {K | N | undefined} targetNode - The `targetNode` parameter represents the node in the
219
200
  * binary tree that you want to traverse from. It can be specified either by its key, by the node
220
201
  * object itself, or it can be left undefined to start the traversal from the root of the tree.
221
202
  * @param iterationType - The `iterationType` parameter determines the type of traversal to be
@@ -223,7 +204,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
223
204
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
224
205
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
225
206
  */
226
- lesserOrGreaterTraverse<C extends BTNCallback<N>>(callback?: C, lesserOrGreater?: CP, targetNode?: BSTNodeKeyOrNode<N>, iterationType?: IterationType): ReturnType<C>[];
207
+ lesserOrGreaterTraverse<C extends BTNCallback<N>>(callback?: C, lesserOrGreater?: CP, targetNode?: BSTNodeKeyOrNode<K, N>, iterationType?: IterationType): ReturnType<C>[];
227
208
  /**
228
209
  * Time Complexity: O(log n) - Average case for a balanced tree. O(n) - Visiting each node once when identifier is not node's key.
229
210
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -267,10 +248,10 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
267
248
  /**
268
249
  * The function compares two values using a comparator function and returns whether the first value
269
250
  * is greater than, less than, or equal to the second value.
270
- * @param {BTNKey} a - The parameter "a" is of type BTNKey.
271
- * @param {BTNKey} b - The parameter "b" in the above code represents a BTNKey.
251
+ * @param {K} a - The parameter "a" is of type K.
252
+ * @param {K} b - The parameter "b" in the above code represents a K.
272
253
  * @returns a value of type CP (ComparisonResult). The possible return values are CP.gt (greater
273
254
  * than), CP.lt (less than), or CP.eq (equal).
274
255
  */
275
- protected _compare(a: BTNKey, b: BTNKey): CP;
256
+ protected _compare(a: K, b: K): CP;
276
257
  }