data-structure-typed 1.52.0 → 1.52.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 (132) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +141 -54
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +162 -162
  5. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
  6. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +11 -11
  8. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
  9. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +11 -11
  11. package/dist/cjs/data-structures/binary-tree/avl-tree.js +6 -6
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  13. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +97 -97
  14. package/dist/cjs/data-structures/binary-tree/binary-tree.js +52 -52
  15. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  16. package/dist/cjs/data-structures/binary-tree/bst.d.ts +35 -35
  17. package/dist/cjs/data-structures/binary-tree/bst.js +17 -17
  18. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  19. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +8 -8
  20. package/dist/cjs/data-structures/binary-tree/rb-tree.js +6 -6
  21. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  22. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +10 -10
  23. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +5 -5
  24. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  25. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  26. package/dist/cjs/data-structures/graph/directed-graph.js +2 -1
  27. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  28. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  29. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  30. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  31. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  32. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  33. package/dist/cjs/data-structures/queue/deque.d.ts +7 -0
  34. package/dist/cjs/data-structures/queue/deque.js +16 -1
  35. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  36. package/dist/cjs/data-structures/queue/queue.d.ts +18 -1
  37. package/dist/cjs/data-structures/queue/queue.js +32 -7
  38. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  39. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  40. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  41. package/dist/cjs/interfaces/binary-tree.d.ts +3 -3
  42. package/dist/cjs/types/common.d.ts +1 -22
  43. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +18 -1
  44. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -0
  45. package/dist/cjs/types/data-structures/queue/deque.d.ts +1 -0
  46. package/dist/cjs/types/data-structures/queue/queue.d.ts +3 -1
  47. package/dist/cjs/utils/number.js +1 -2
  48. package/dist/cjs/utils/number.js.map +1 -1
  49. package/dist/cjs/utils/utils.js +2 -2
  50. package/dist/cjs/utils/utils.js.map +1 -1
  51. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +11 -11
  52. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
  53. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +11 -11
  54. package/dist/mjs/data-structures/binary-tree/avl-tree.js +6 -6
  55. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +97 -97
  56. package/dist/mjs/data-structures/binary-tree/binary-tree.js +52 -52
  57. package/dist/mjs/data-structures/binary-tree/bst.d.ts +35 -35
  58. package/dist/mjs/data-structures/binary-tree/bst.js +17 -17
  59. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +8 -8
  60. package/dist/mjs/data-structures/binary-tree/rb-tree.js +6 -6
  61. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +10 -10
  62. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +5 -5
  63. package/dist/mjs/data-structures/graph/directed-graph.js +2 -1
  64. package/dist/mjs/data-structures/queue/deque.d.ts +7 -0
  65. package/dist/mjs/data-structures/queue/deque.js +16 -1
  66. package/dist/mjs/data-structures/queue/queue.d.ts +18 -1
  67. package/dist/mjs/data-structures/queue/queue.js +32 -7
  68. package/dist/mjs/interfaces/binary-tree.d.ts +3 -3
  69. package/dist/mjs/types/common.d.ts +1 -22
  70. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +18 -1
  71. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -0
  72. package/dist/mjs/types/data-structures/queue/deque.d.ts +1 -0
  73. package/dist/mjs/types/data-structures/queue/queue.d.ts +3 -1
  74. package/dist/umd/data-structure-typed.js +137 -95
  75. package/dist/umd/data-structure-typed.min.js +2 -2
  76. package/dist/umd/data-structure-typed.min.js.map +1 -1
  77. package/package.json +8 -8
  78. package/src/data-structures/base/iterable-element-base.ts +2 -2
  79. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  80. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +25 -24
  81. package/src/data-structures/binary-tree/avl-tree.ts +20 -19
  82. package/src/data-structures/binary-tree/binary-tree.ts +162 -157
  83. package/src/data-structures/binary-tree/bst.ts +54 -50
  84. package/src/data-structures/binary-tree/rb-tree.ts +18 -17
  85. package/src/data-structures/binary-tree/tree-multi-map.ts +18 -17
  86. package/src/data-structures/graph/abstract-graph.ts +15 -14
  87. package/src/data-structures/graph/directed-graph.ts +9 -7
  88. package/src/data-structures/graph/undirected-graph.ts +7 -6
  89. package/src/data-structures/hash/hash-map.ts +4 -4
  90. package/src/data-structures/heap/heap.ts +1 -1
  91. package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
  92. package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
  93. package/src/data-structures/queue/deque.ts +18 -4
  94. package/src/data-structures/queue/queue.ts +38 -8
  95. package/src/data-structures/stack/stack.ts +1 -1
  96. package/src/data-structures/trie/trie.ts +1 -1
  97. package/src/interfaces/binary-tree.ts +3 -3
  98. package/src/types/common.ts +2 -24
  99. package/src/types/data-structures/binary-tree/binary-tree.ts +21 -1
  100. package/src/types/data-structures/binary-tree/bst.ts +7 -0
  101. package/src/types/data-structures/graph/abstract-graph.ts +8 -8
  102. package/src/types/data-structures/queue/deque.ts +4 -1
  103. package/src/types/data-structures/queue/queue.ts +3 -1
  104. package/src/types/utils/utils.ts +4 -4
  105. package/test/integration/bst.test.ts +4 -1
  106. package/test/performance/data-structures/comparison/comparison.test.ts +12 -4
  107. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +6 -2
  108. package/test/performance/reportor.ts +23 -8
  109. package/test/performance/types/reportor.ts +5 -1
  110. package/test/types/utils/json2html.ts +5 -1
  111. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +6 -2
  112. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +8 -2
  113. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +36 -11
  114. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -1
  115. package/test/unit/data-structures/binary-tree/bst.test.ts +18 -5
  116. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +3 -1
  117. package/test/unit/data-structures/graph/abstract-graph.test.ts +2 -4
  118. package/test/unit/data-structures/graph/directed-graph.test.ts +27 -0
  119. package/test/unit/data-structures/hash/hash-map.test.ts +6 -2
  120. package/test/unit/data-structures/heap/heap.test.ts +64 -12
  121. package/test/unit/data-structures/heap/max-heap.test.ts +10 -3
  122. package/test/unit/data-structures/heap/min-heap.test.ts +3 -1
  123. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +3 -1
  124. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +6 -2
  125. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +22 -6
  126. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +12 -4
  127. package/test/unit/data-structures/queue/deque.test.ts +31 -6
  128. package/test/unit/data-structures/queue/queue.test.ts +14 -1
  129. package/test/unit/data-structures/trie/trie.test.ts +3 -1
  130. package/test/unit/unrestricted-interconversion.test.ts +3 -1
  131. package/test/utils/big-o.ts +3 -1
  132. package/test/utils/json2html.ts +2 -6
@@ -40,7 +40,7 @@ export class BinaryTreeNode {
40
40
  }
41
41
  /**
42
42
  * The function sets the left child of a node and updates its parent reference.
43
- * @param {NODE | null | undefined} v - The parameter `v` can be of type `NODE`, `null`, or
43
+ * @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or
44
44
  * `undefined`.
45
45
  */
46
46
  set left(v) {
@@ -60,7 +60,7 @@ export class BinaryTreeNode {
60
60
  }
61
61
  /**
62
62
  * The function sets the right child of a node and updates its parent.
63
- * @param {NODE | null | undefined} v - The parameter `v` can be of type `NODE`, `null`, or
63
+ * @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or
64
64
  * `undefined`.
65
65
  */
66
66
  set right(v) {
@@ -98,7 +98,7 @@ export class BinaryTree extends IterableEntryBase {
98
98
  iterationType = 'ITERATIVE';
99
99
  /**
100
100
  * The constructor function initializes a binary tree object with optional keysOrNodesOrEntriesOrRawElements and options.
101
- * @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of KeyOrNodeOrEntry objects. These objects represent the
101
+ * @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of BTNKeyOrNodeOrEntry objects. These objects represent the
102
102
  * nodes to be added to the binary tree.
103
103
  * @param [options] - The `options` parameter is an optional object that can contain additional
104
104
  * configuration options for the binary tree. In this case, it is of type
@@ -174,8 +174,8 @@ export class BinaryTree extends IterableEntryBase {
174
174
  /**
175
175
  * The function `keyValueOrEntryOrRawElementToNode` converts a key-value pair, entry, or raw element
176
176
  * into a node object.
177
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
178
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
177
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
178
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
179
179
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
180
180
  * `keyValueOrEntryOrRawElementToNode` function. It represents the value associated with a key in a
181
181
  * key-value pair. If provided, it will be used to create a node with the specified key and value.
@@ -219,8 +219,8 @@ export class BinaryTree extends IterableEntryBase {
219
219
  *
220
220
  * The `ensureNode` function checks if the input is a valid node and returns it, or converts it to a
221
221
  * node if it is a key or entry.
222
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
223
- * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or
222
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
223
+ * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
224
224
  * a raw element.
225
225
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
226
226
  * parameter that specifies the type of iteration to be used when searching for a node. It has a
@@ -255,8 +255,8 @@ export class BinaryTree extends IterableEntryBase {
255
255
  }
256
256
  /**
257
257
  * The function checks if the input is an instance of the BinaryTreeNode class.
258
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
259
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
258
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
259
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
260
260
  * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
261
261
  * an instance of the `BinaryTreeNode` class.
262
262
  */
@@ -265,8 +265,8 @@ export class BinaryTree extends IterableEntryBase {
265
265
  }
266
266
  /**
267
267
  * The function checks if a given node is a valid node in a binary search tree.
268
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
269
- * `KeyOrNodeOrEntry<K, V, NODE>`.
268
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
269
+ * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
270
270
  * @returns a boolean value.
271
271
  */
272
272
  isRealNode(node) {
@@ -276,8 +276,8 @@ export class BinaryTree extends IterableEntryBase {
276
276
  }
277
277
  /**
278
278
  * The function checks if a given node is a real node or null.
279
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
280
- * `KeyOrNodeOrEntry<K, V, NODE>`.
279
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
280
+ * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
281
281
  * @returns a boolean value.
282
282
  */
283
283
  isNodeOrNull(node) {
@@ -285,8 +285,8 @@ export class BinaryTree extends IterableEntryBase {
285
285
  }
286
286
  /**
287
287
  * The function checks if a given node is equal to the NIL value.
288
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
289
- * `KeyOrNodeOrEntry<K, V, NODE>`.
288
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
289
+ * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
290
290
  * @returns a boolean value.
291
291
  */
292
292
  isNIL(node) {
@@ -295,8 +295,8 @@ export class BinaryTree extends IterableEntryBase {
295
295
  /**
296
296
  * The function checks if the input is an array with two elements, indicating it is a binary tree
297
297
  * node entry.
298
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
299
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
298
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
299
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
300
300
  * @returns a boolean value.
301
301
  */
302
302
  isEntry(keyOrNodeOrEntryOrRawElement) {
@@ -344,10 +344,10 @@ export class BinaryTree extends IterableEntryBase {
344
344
  *
345
345
  * The `add` function is used to insert a new node into a binary tree, checking for duplicate keys
346
346
  * and finding the appropriate insertion position.
347
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
347
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
348
348
  * `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which represents the key,
349
349
  * node, entry, or raw element to be added to the tree. It can also accept a value of type
350
- * `KeyOrNodeOrEntry<K, V, NODE>
350
+ * `BTNKeyOrNodeOrEntry<K, V, NODE>
351
351
  * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
352
352
  * key being added to the tree. It represents the value that will be stored in the tree for the given
353
353
  * key.
@@ -449,7 +449,7 @@ export class BinaryTree extends IterableEntryBase {
449
449
  *
450
450
  * The `refill` function clears the current data and adds new data to the collection.
451
451
  * @param keysOrNodesOrEntriesOrRawElements - An iterable collection of keys, nodes, entries, or raw
452
- * elements. These can be of any type (R) or a specific type (KeyOrNodeOrEntry<K, V, NODE>).
452
+ * elements. These can be of any type (R) or a specific type (BTNKeyOrNodeOrEntry<K, V, NODE>).
453
453
  * @param [values] - The `values` parameter is an optional iterable of values that will be associated
454
454
  * with the keys or nodes being added. If provided, the values will be assigned to the corresponding
455
455
  * keys or nodes. If not provided, the values will be set to `undefined`.
@@ -544,7 +544,7 @@ export class BinaryTree extends IterableEntryBase {
544
544
  * the identifier or all nodes that match the identifier. If set to true, only the first matching
545
545
  * node will be returned. If set to false, all matching nodes will be returned. The default value is
546
546
  * false.
547
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
547
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
548
548
  * point for the search. It can be either a node object, a key-value pair, or a key. If it is not
549
549
  * provided, the `root` of the data structure is used as the starting point.
550
550
  * @param {IterationType} iterationType - The `iterationType` parameter determines the type of
@@ -603,7 +603,7 @@ export class BinaryTree extends IterableEntryBase {
603
603
  * the `C` callback function, or it can be `null` or `undefined`.
604
604
  * @param {C} callback - The `callback` parameter is a function that will be used to determine if a
605
605
  * node matches the desired criteria. It should return a value that can be used to identify the node.
606
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
606
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
607
607
  * point for searching nodes in a tree structure. It can be either a root node, a key-value pair, or
608
608
  * a node entry. If not provided, the search will start from the root of the tree.
609
609
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
@@ -647,7 +647,7 @@ export class BinaryTree extends IterableEntryBase {
647
647
  * callback function `C`. It can also be `null` or `undefined` if no identifier is provided.
648
648
  * @param {C} callback - The `callback` parameter is a function that will be used to determine if a
649
649
  * node matches the given identifier. It is optional and defaults to `this._DEFAULT_CALLBACK`.
650
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
650
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
651
651
  * point for the search in the binary tree. It can be either a root node of the tree or a key, node,
652
652
  * or entry object that exists in the tree. If no specific starting point is provided, the search
653
653
  * will begin from the root of the
@@ -677,7 +677,7 @@ export class BinaryTree extends IterableEntryBase {
677
677
  * @param {C} callback - The `callback` parameter is a function that will be used to determine
678
678
  * whether a node should be included in the result or not. It is of type `C`, which extends the
679
679
  * `BTNCallback<NODE>` type.
680
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
680
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
681
681
  * point for the iteration in the data structure. It can be either a root node, a key-value pair, or
682
682
  * a node entry. If not specified, it defaults to the root of the data structure.
683
683
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
@@ -726,10 +726,10 @@ export class BinaryTree extends IterableEntryBase {
726
726
  *
727
727
  * The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
728
728
  * height of the tree.
729
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The parameter `beginRoot` is optional and
729
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The parameter `beginRoot` is optional and
730
730
  * has a default value of `this.root`. It represents the starting point for checking if the tree is
731
731
  * perfectly balanced. It can be either a root node (`R`), a key or node or entry
732
- * (`KeyOrNodeOrEntry<K, V, NODE
732
+ * (`BTNKeyOrNodeOrEntry<K, V, NODE
733
733
  * @returns a boolean value.
734
734
  */
735
735
  isPerfectlyBalanced(beginRoot = this.root) {
@@ -744,7 +744,7 @@ export class BinaryTree extends IterableEntryBase {
744
744
  * Space Complexity: O(1)
745
745
  *
746
746
  * The function `isBST` checks if a binary search tree is valid, either recursively or iteratively.
747
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
747
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
748
748
  * starting point for checking if a binary search tree (BST) is valid. It can be either a root node
749
749
  * of the BST, a key value of a node in the BST, or an entry object containing both the key and value
750
750
  * of a node in the BST
@@ -804,10 +804,10 @@ export class BinaryTree extends IterableEntryBase {
804
804
  * Space Complexity: O(1)
805
805
  *
806
806
  * The function calculates the depth of a given node or key in a tree-like data structure.
807
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} dist - The `dist` parameter can be either a `R`
808
- * (representing a root node), or a `KeyOrNodeOrEntry<K, V, NODE>` (representing a key, node, or
807
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} dist - The `dist` parameter can be either a `R`
808
+ * (representing a root node), or a `BTNKeyOrNodeOrEntry<K, V, NODE>` (representing a key, node, or
809
809
  * entry).
810
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is optional and
810
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is optional and
811
811
  * represents the starting point from which to calculate the depth. It can be either a reference to a
812
812
  * node in the tree or a key-value pair or an entry object. If not provided, the default value is
813
813
  * `this.root`, which refers to the root node
@@ -836,9 +836,9 @@ export class BinaryTree extends IterableEntryBase {
836
836
  *
837
837
  * The `getHeight` function calculates the maximum height of a binary tree using either a recursive
838
838
  * or iterative approach.
839
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
839
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
840
840
  * starting point for calculating the height of a tree. It can be either a root node (`R`), a key or
841
- * node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current tree.
841
+ * node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current tree.
842
842
  * @param {IterationType} iterationType - The `iterationType` parameter determines the type of
843
843
  * iteration used to calculate the height of the tree. It can have two possible values:
844
844
  * @returns the maximum height of the binary tree.
@@ -881,9 +881,9 @@ export class BinaryTree extends IterableEntryBase {
881
881
  *
882
882
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a
883
883
  * recursive or iterative approach.
884
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
884
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
885
885
  * starting point for calculating the minimum height of a tree. It can be either a root node (`R`), a
886
- * key or node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current
886
+ * key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current
887
887
  * tree.
888
888
  * @param {IterationType} iterationType - The `iterationType` parameter determines the type of
889
889
  * iteration to be used when calculating the minimum height of the tree. It can have two possible
@@ -921,8 +921,8 @@ export class BinaryTree extends IterableEntryBase {
921
921
  if (!this.isRealNode(node.right) || last === node.right) {
922
922
  node = stack.pop();
923
923
  if (this.isRealNode(node)) {
924
- const leftMinHeight = this.isRealNode(node.left) ? depths.get(node.left) ?? -1 : -1;
925
- const rightMinHeight = this.isRealNode(node.right) ? depths.get(node.right) ?? -1 : -1;
924
+ const leftMinHeight = this.isRealNode(node.left) ? (depths.get(node.left) ?? -1) : -1;
925
+ const rightMinHeight = this.isRealNode(node.right) ? (depths.get(node.right) ?? -1) : -1;
926
926
  depths.set(node, 1 + Math.min(leftMinHeight, rightMinHeight));
927
927
  last = node;
928
928
  node = null;
@@ -945,8 +945,8 @@ export class BinaryTree extends IterableEntryBase {
945
945
  *
946
946
  * The function `getPathToRoot` returns an array of nodes starting from a given node and traversing
947
947
  * up to the root node, with an option to reverse the order of the nodes.
948
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginNode - The `beginNode` parameter can be either of
949
- * type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
948
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginNode - The `beginNode` parameter can be either of
949
+ * type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
950
950
  * @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
951
951
  * resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be
952
952
  * reversed before returning it. If `isReverse` is set to `false` or not provided, the path will
@@ -975,9 +975,9 @@ export class BinaryTree extends IterableEntryBase {
975
975
  *
976
976
  * The `getLeftMost` function returns the leftmost node in a binary tree, either using recursive or
977
977
  * iterative traversal.
978
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
978
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
979
979
  * starting point for finding the leftmost node in a binary tree. It can be either a root node (`R`),
980
- * a key or node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
980
+ * a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
981
981
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
982
982
  * of iteration to be performed. It can have two possible values:
983
983
  * @returns The function `getLeftMost` returns the leftmost node in a binary tree.
@@ -1016,9 +1016,9 @@ export class BinaryTree extends IterableEntryBase {
1016
1016
  *
1017
1017
  * The `getRightMost` function returns the rightmost node in a binary tree, either recursively or
1018
1018
  * iteratively.
1019
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
1019
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
1020
1020
  * starting point for finding the rightmost node in a binary tree. It can be either a root node
1021
- * (`R`), a key or node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
1021
+ * (`R`), a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
1022
1022
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
1023
1023
  * of iteration to be performed when finding the rightmost node in a binary tree. It can have two
1024
1024
  * possible values:
@@ -1118,7 +1118,7 @@ export class BinaryTree extends IterableEntryBase {
1118
1118
  * return type of the callback function is determined by the generic type `C`.
1119
1119
  * @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter determines the order in which the
1120
1120
  * nodes are visited during the depth-first search. It can have one of the following values:
1121
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
1121
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
1122
1122
  * point of the depth-first search. It can be either a node object, a key-value pair, or a key. If it
1123
1123
  * is a key or key-value pair, the method will find the corresponding node in the tree and start the
1124
1124
  * search from there.
@@ -1249,7 +1249,7 @@ export class BinaryTree extends IterableEntryBase {
1249
1249
  * @param {C} callback - The `callback` parameter is a function that will be called for each node in
1250
1250
  * the breadth-first search traversal. It takes a single argument, which is the current node being
1251
1251
  * visited, and returns a value of any type.
1252
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
1252
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
1253
1253
  * starting point of the breadth-first search. It can be either a root node of a tree or a key, node,
1254
1254
  * or entry object. If no value is provided, the `root` property of the class is used as the default
1255
1255
  * starting point.
@@ -1327,7 +1327,7 @@ export class BinaryTree extends IterableEntryBase {
1327
1327
  * @param {C} callback - The `callback` parameter is a function that will be called for each node in
1328
1328
  * the tree. It takes a node as an argument and returns a value. The return type of the callback
1329
1329
  * function is determined by the generic type `C` which extends `BTNCallback<NODE | null>`.
1330
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
1330
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
1331
1331
  * starting point for traversing the tree. It can be either a root node, a key-value pair, or a node
1332
1332
  * entry. If no value is provided, the `root` property of the class is used as the default starting
1333
1333
  * point.
@@ -1405,7 +1405,7 @@ export class BinaryTree extends IterableEntryBase {
1405
1405
  * @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `morris` function is used
1406
1406
  * to specify the order in which the nodes of a binary tree are traversed. It can take one of the
1407
1407
  * following values:
1408
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
1408
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
1409
1409
  * point for the traversal. It can be either a node object, a key, or an entry object. If no value is
1410
1410
  * provided, the `root` of the tree is used as the starting point.
1411
1411
  * @returns The function `morris` returns an array of values that are the return values of the
@@ -1591,7 +1591,7 @@ export class BinaryTree extends IterableEntryBase {
1591
1591
  * Space Complexity: O(n)
1592
1592
  *
1593
1593
  * The `print` function in TypeScript prints the binary tree structure with customizable options.
1594
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
1594
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
1595
1595
  * point for printing the binary tree. It can be either a node of the binary tree or a key or entry
1596
1596
  * that exists in the binary tree. If no value is provided, the root of the binary tree will be used
1597
1597
  * as the starting point.
@@ -1674,7 +1674,7 @@ export class BinaryTree extends IterableEntryBase {
1674
1674
  *
1675
1675
  * The `_displayAux` function is responsible for generating the display layout of a binary tree node,
1676
1676
  * taking into account various options such as whether to show null, undefined, or NaN nodes.
1677
- * @param {NODE | null | undefined} node - The `node` parameter represents a node in a binary tree.
1677
+ * @param {OptBTNOrNull<NODE>} node - The `node` parameter represents a node in a binary tree.
1678
1678
  * It can be of type `NODE`, `null`, or `undefined`.
1679
1679
  * @param {BinaryTreePrintOptions} options - The `options` parameter is an object that contains the
1680
1680
  * following properties:
@@ -1747,10 +1747,10 @@ export class BinaryTree extends IterableEntryBase {
1747
1747
  * Space Complexity: O(1)
1748
1748
  *
1749
1749
  * The function `_swapProperties` swaps the key-value properties between two nodes.
1750
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} srcNode - The source node that will be swapped with the
1750
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} srcNode - The source node that will be swapped with the
1751
1751
  * destination node. It can be either an instance of the class `R`, or an object of type
1752
- * `KeyOrNodeOrEntry<K, V, NODE>`.
1753
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} destNode - The `destNode` parameter is the node where
1752
+ * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
1753
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} destNode - The `destNode` parameter is the node where
1754
1754
  * the properties will be swapped with the `srcNode`.
1755
1755
  * @returns either the `destNode` object with its properties swapped with the `srcNode` object's
1756
1756
  * properties, or `undefined` if either `srcNode` or `destNode` is falsy.
@@ -1814,7 +1814,7 @@ export class BinaryTree extends IterableEntryBase {
1814
1814
  *
1815
1815
  * The function sets the root property of an object to the provided value, and also updates the
1816
1816
  * parent property of the new root.
1817
- * @param {NODE | null | undefined} v - The parameter `v` is of type `NODE | null | undefined`. This
1817
+ * @param {OptBTNOrNull<NODE>} v - The parameter `v` is of type `OptBTNOrNull<NODE>`. This
1818
1818
  * means that it can accept a value of type `NODE`, `null`, or `undefined`.
1819
1819
  */
1820
1820
  _setRoot(v) {
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, Comparator, CP, DFSOrderPattern, IterationType, KeyOrNodeOrEntry } from '../../types';
8
+ import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNKeyOrNodeOrEntry, Comparator, CP, DFSOrderPattern, IterationType, OptBSTN } from '../../types';
9
9
  import { BTNEntry } from '../../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
11
  import { IBinaryTree } from '../../interfaces';
@@ -17,26 +17,26 @@ export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE>
17
17
  * The function returns the value of the `_left` property.
18
18
  * @returns The `_left` property of the current object is being returned.
19
19
  */
20
- get left(): NODE | undefined;
20
+ get left(): OptBSTN<NODE>;
21
21
  /**
22
22
  * The function sets the left child of a node and updates the parent reference of the child.
23
- * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an
23
+ * @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be an
24
24
  * instance of the `NODE` class or `undefined`.
25
25
  */
26
- set left(v: NODE | undefined);
26
+ set left(v: OptBSTN<NODE>);
27
27
  protected _right?: NODE;
28
28
  /**
29
29
  * The function returns the right node of a binary tree or undefined if there is no right node.
30
30
  * @returns The method is returning the value of the `_right` property, which is of type `NODE` or
31
31
  * `undefined`.
32
32
  */
33
- get right(): NODE | undefined;
33
+ get right(): OptBSTN<NODE>;
34
34
  /**
35
35
  * The function sets the right child of a node and updates the parent reference of the child.
36
- * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a
36
+ * @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be a
37
37
  * `NODE` object or `undefined`.
38
38
  */
39
- set right(v: NODE | undefined);
39
+ set right(v: OptBSTN<NODE>);
40
40
  }
41
41
  /**
42
42
  * 1. Node Order: Each node's left child has a lesser value, and the right child has a greater value.
@@ -56,13 +56,13 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
56
56
  * @param [options] - An optional object that contains additional options for the Binary Search Tree.
57
57
  * It can include a comparator function that defines the order of the elements in the tree.
58
58
  */
59
- constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>);
59
+ constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>);
60
60
  protected _root?: NODE;
61
61
  /**
62
62
  * The function returns the root node of a tree structure.
63
63
  * @returns The `_root` property of the object, which is of type `NODE` or `undefined`.
64
64
  */
65
- get root(): NODE | undefined;
65
+ get root(): OptBSTN<NODE>;
66
66
  /**
67
67
  * The function creates a new BSTNode with the given key and value and returns it.
68
68
  * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
@@ -82,21 +82,21 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
82
82
  createTree(options?: Partial<BSTOptions<K, V, R>>): TREE;
83
83
  /**
84
84
  * The function overrides a method and converts a key, value pair or entry or raw element to a node.
85
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of
86
- * type R or KeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw
85
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of
86
+ * type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw
87
87
  * element.
88
88
  * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
89
89
  * value associated with a key in a key-value pair.
90
90
  * @returns either a NODE object or undefined.
91
91
  */
92
- keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined;
92
+ keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): OptBSTN<NODE>;
93
93
  /**
94
94
  * Time Complexity: O(log n)
95
95
  * Space Complexity: O(log n)
96
96
  *
97
97
  * The function ensures the existence of a node in a data structure and returns it, or undefined if
98
98
  * it doesn't exist.
99
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
99
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
100
100
  * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node,
101
101
  * entry, or raw element that needs to be ensured in the tree.
102
102
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
@@ -105,27 +105,27 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
105
105
  * @returns The method is returning either the node that was ensured or `undefined` if the node could
106
106
  * not be ensured.
107
107
  */
108
- ensureNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | undefined;
108
+ ensureNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
109
109
  /**
110
110
  * The function checks if the input is an instance of the BSTNode class.
111
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
112
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
111
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
112
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
113
113
  * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
114
114
  * an instance of the `BSTNode` class.
115
115
  */
116
- isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
116
+ isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
117
117
  /**
118
118
  * Time Complexity: O(log n)
119
119
  * Space Complexity: O(1)
120
120
  *
121
121
  * The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
122
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
123
- * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
122
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
123
+ * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
124
124
  * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
125
125
  * key in the binary search tree. If provided, it will be stored in the node along with the key.
126
126
  * @returns a boolean value.
127
127
  */
128
- add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
128
+ add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
129
129
  /**
130
130
  * Time Complexity: O(log n)
131
131
  * Space Complexity: O(log n)
@@ -151,7 +151,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
151
151
  * @returns The function `addMany` returns an array of booleans indicating whether each element was
152
152
  * successfully inserted into the data structure.
153
153
  */
154
- addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
154
+ addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
155
155
  /**
156
156
  * Time Complexity: O(log n)
157
157
  * Space Complexity: O(k + log n)
@@ -167,14 +167,14 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
167
167
  * @param [onlyOne=false] - A boolean value indicating whether to return only the first matching node
168
168
  * or all matching nodes. If set to true, only the first matching node will be returned. If set to
169
169
  * false, all matching nodes will be returned. The default value is false.
170
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
170
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
171
171
  * point for the search in the binary tree. It can be either a node object, a key-value pair, or an
172
172
  * entry object. If it is not provided, the `root` of the binary tree is used as the starting point.
173
173
  * @param {IterationType} iterationType - The `iterationType` parameter determines the type of
174
174
  * iteration to be performed. It can have two possible values:
175
175
  * @returns The method `getNodes` returns an array of `NODE` objects.
176
176
  */
177
- getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
177
+ getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
178
178
  /**
179
179
  * Time Complexity: O(log n)
180
180
  * Space Complexity: O(1)
@@ -200,7 +200,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
200
200
  * of the following values:
201
201
  * @returns The method is returning a NODE object or undefined.
202
202
  */
203
- getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): NODE | undefined;
203
+ getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
204
204
  /**
205
205
  * Time Complexity: O(k log n)
206
206
  * Space Complexity: O(k + log n)
@@ -218,7 +218,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
218
218
  * It has a default value of `'ITERATIVE'`.
219
219
  * @returns The method is returning a NODE object or undefined.
220
220
  */
221
- getNodeByKey(key: K, iterationType?: IterationType): NODE | undefined;
221
+ getNodeByKey(key: K, iterationType?: IterationType): OptBSTN<NODE>;
222
222
  /**
223
223
  * Time Complexity: O(log n)
224
224
  * Space Complexity: O(k + log n)
@@ -235,7 +235,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
235
235
  * @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
236
236
  * order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
237
237
  * take one of the following values:
238
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
238
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
239
239
  * point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
240
240
  * node entry. If not specified, the default value is the root of the tree.
241
241
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
@@ -243,7 +243,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
243
243
  * following values:
244
244
  * @returns The method is returning an array of the return type of the callback function.
245
245
  */
246
- dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
246
+ dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
247
247
  /**
248
248
  * Time Complexity: O(log n)
249
249
  * Space Complexity: O(1)
@@ -257,7 +257,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
257
257
  * @param {C} callback - The `callback` parameter is a function that will be called for each node
258
258
  * visited during the breadth-first search. It should take a single argument, which is the current
259
259
  * node being visited, and it can return a value of any type.
260
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
260
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
261
261
  * point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
262
262
  * object. If no value is provided, the default value is the root of the tree.
263
263
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
@@ -265,7 +265,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
265
265
  * the following values:
266
266
  * @returns an array of the return type of the callback function.
267
267
  */
268
- bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
268
+ bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
269
269
  /**
270
270
  * Time Complexity: O(log n)
271
271
  * Space Complexity: O(1)
@@ -279,7 +279,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
279
279
  * @param {C} callback - The `callback` parameter is a generic type `C` that extends
280
280
  * `BTNCallback<NODE>`. It represents a callback function that will be called for each node in the
281
281
  * tree during the iteration process.
282
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
282
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
283
283
  * point for listing the levels of the binary tree. It can be either a root node of the tree, a
284
284
  * key-value pair representing a node in the tree, or a key representing a node in the tree. If no
285
285
  * value is provided, the root of
@@ -288,7 +288,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
288
288
  * @returns The method is returning a two-dimensional array of the return type of the callback
289
289
  * function.
290
290
  */
291
- listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[][];
291
+ listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[][];
292
292
  /**
293
293
  * Time complexity: O(n)
294
294
  * Space complexity: O(n)
@@ -305,7 +305,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
305
305
  * @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
306
306
  * traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
307
307
  * 0, or 1, where:
308
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in
308
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in
309
309
  * the binary tree that you want to start traversing from. It can be specified either by providing
310
310
  * the key of the node, the node itself, or an entry containing the key and value of the node. If no
311
311
  * `targetNode` is provided,
@@ -314,7 +314,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
314
314
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
315
315
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
316
316
  */
317
- lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
317
+ lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
318
318
  /**
319
319
  * Time complexity: O(n)
320
320
  * Space complexity: O(n)
@@ -363,7 +363,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
363
363
  /**
364
364
  * The function sets the root of a tree-like structure and updates the parent property of the new
365
365
  * root.
366
- * @param {NODE | undefined} v - v is a parameter of type NODE or undefined.
366
+ * @param {OptBSTN<NODE>} v - v is a parameter of type NODE or undefined.
367
367
  */
368
- protected _setRoot(v: NODE | undefined): void;
368
+ protected _setRoot(v: OptBSTN<NODE>): void;
369
369
  }