data-structure-typed 1.51.8 → 1.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +152 -152
  5. package/dist/cjs/data-structures/base/index.d.ts +2 -1
  6. package/dist/cjs/data-structures/base/index.js +2 -1
  7. package/dist/cjs/data-structures/base/index.js.map +1 -1
  8. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +171 -0
  9. package/dist/cjs/data-structures/base/iterable-element-base.js +226 -0
  10. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -0
  11. package/dist/cjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  12. package/dist/cjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +13 -190
  13. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -0
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  15. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  16. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  18. package/dist/cjs/data-structures/binary-tree/avl-tree.js +78 -59
  19. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  21. package/dist/cjs/data-structures/binary-tree/binary-tree.js +475 -363
  22. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  23. package/dist/cjs/data-structures/binary-tree/bst.d.ts +192 -202
  24. package/dist/cjs/data-structures/binary-tree/bst.js +207 -249
  25. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  27. package/dist/cjs/data-structures/binary-tree/rb-tree.js +107 -98
  28. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  30. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  31. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  32. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +10 -15
  33. package/dist/cjs/data-structures/graph/abstract-graph.js +10 -15
  34. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  35. package/dist/cjs/data-structures/hash/hash-map.d.ts +33 -40
  36. package/dist/cjs/data-structures/hash/hash-map.js +40 -55
  37. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  38. package/dist/cjs/data-structures/heap/heap.d.ts +43 -114
  39. package/dist/cjs/data-structures/heap/heap.js +59 -127
  40. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  41. package/dist/cjs/data-structures/heap/max-heap.d.ts +50 -4
  42. package/dist/cjs/data-structures/heap/max-heap.js +76 -10
  43. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  44. package/dist/cjs/data-structures/heap/min-heap.d.ts +51 -5
  45. package/dist/cjs/data-structures/heap/min-heap.js +68 -11
  46. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  48. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  49. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  51. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +29 -26
  52. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  53. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  54. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +79 -10
  55. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  56. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  57. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  58. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  60. package/dist/cjs/data-structures/priority-queue/priority-queue.js +70 -1
  61. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/queue/deque.d.ts +21 -20
  63. package/dist/cjs/data-structures/queue/deque.js +29 -23
  64. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  65. package/dist/cjs/data-structures/queue/queue.d.ts +8 -28
  66. package/dist/cjs/data-structures/queue/queue.js +15 -31
  67. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  68. package/dist/cjs/data-structures/stack/stack.d.ts +17 -22
  69. package/dist/cjs/data-structures/stack/stack.js +25 -24
  70. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  71. package/dist/cjs/data-structures/trie/trie.d.ts +19 -14
  72. package/dist/cjs/data-structures/trie/trie.js +27 -16
  73. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  74. package/dist/cjs/interfaces/binary-tree.d.ts +7 -7
  75. package/dist/cjs/types/common.d.ts +1 -2
  76. package/dist/cjs/types/data-structures/base/base.d.ts +5 -2
  77. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  78. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  79. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  80. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  81. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  82. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  83. package/dist/cjs/types/data-structures/heap/heap.d.ts +3 -2
  84. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  85. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  86. package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  87. package/dist/cjs/types/data-structures/queue/deque.d.ts +3 -2
  88. package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -1
  89. package/dist/cjs/types/data-structures/stack/stack.d.ts +2 -1
  90. package/dist/cjs/types/data-structures/trie/trie.d.ts +3 -2
  91. package/dist/cjs/utils/utils.js +3 -5
  92. package/dist/cjs/utils/utils.js.map +1 -1
  93. package/dist/mjs/data-structures/base/index.d.ts +2 -1
  94. package/dist/mjs/data-structures/base/index.js +2 -1
  95. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +171 -0
  96. package/dist/mjs/data-structures/base/iterable-element-base.js +222 -0
  97. package/dist/mjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  98. package/dist/mjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +10 -186
  99. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  100. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  101. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  102. package/dist/mjs/data-structures/binary-tree/avl-tree.js +78 -59
  103. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  104. package/dist/mjs/data-structures/binary-tree/binary-tree.js +476 -364
  105. package/dist/mjs/data-structures/binary-tree/bst.d.ts +192 -202
  106. package/dist/mjs/data-structures/binary-tree/bst.js +211 -255
  107. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  108. package/dist/mjs/data-structures/binary-tree/rb-tree.js +107 -98
  109. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  110. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  111. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +10 -15
  112. package/dist/mjs/data-structures/graph/abstract-graph.js +10 -15
  113. package/dist/mjs/data-structures/hash/hash-map.d.ts +33 -40
  114. package/dist/mjs/data-structures/hash/hash-map.js +41 -55
  115. package/dist/mjs/data-structures/heap/heap.d.ts +43 -114
  116. package/dist/mjs/data-structures/heap/heap.js +60 -128
  117. package/dist/mjs/data-structures/heap/max-heap.d.ts +50 -4
  118. package/dist/mjs/data-structures/heap/max-heap.js +79 -10
  119. package/dist/mjs/data-structures/heap/min-heap.d.ts +51 -5
  120. package/dist/mjs/data-structures/heap/min-heap.js +68 -11
  121. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  122. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  123. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  124. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +29 -26
  125. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  126. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +82 -10
  127. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  128. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  129. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  130. package/dist/mjs/data-structures/priority-queue/priority-queue.js +70 -1
  131. package/dist/mjs/data-structures/queue/deque.d.ts +21 -20
  132. package/dist/mjs/data-structures/queue/deque.js +29 -23
  133. package/dist/mjs/data-structures/queue/queue.d.ts +8 -28
  134. package/dist/mjs/data-structures/queue/queue.js +15 -31
  135. package/dist/mjs/data-structures/stack/stack.d.ts +17 -22
  136. package/dist/mjs/data-structures/stack/stack.js +25 -24
  137. package/dist/mjs/data-structures/trie/trie.d.ts +19 -14
  138. package/dist/mjs/data-structures/trie/trie.js +27 -16
  139. package/dist/mjs/interfaces/binary-tree.d.ts +7 -7
  140. package/dist/mjs/types/common.d.ts +1 -2
  141. package/dist/mjs/types/data-structures/base/base.d.ts +5 -2
  142. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  143. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  144. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  145. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  146. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  147. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  148. package/dist/mjs/types/data-structures/heap/heap.d.ts +3 -2
  149. package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  150. package/dist/mjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  151. package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  152. package/dist/mjs/types/data-structures/queue/deque.d.ts +3 -2
  153. package/dist/mjs/types/data-structures/queue/queue.d.ts +2 -1
  154. package/dist/mjs/types/data-structures/stack/stack.d.ts +2 -1
  155. package/dist/mjs/types/data-structures/trie/trie.d.ts +3 -2
  156. package/dist/mjs/utils/utils.js +3 -5
  157. package/dist/umd/data-structure-typed.js +1949 -1481
  158. package/dist/umd/data-structure-typed.min.js +2 -2
  159. package/dist/umd/data-structure-typed.min.js.map +1 -1
  160. package/package.json +6 -6
  161. package/src/data-structures/base/index.ts +2 -1
  162. package/src/data-structures/base/iterable-element-base.ts +250 -0
  163. package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
  164. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +144 -95
  165. package/src/data-structures/binary-tree/avl-tree.ts +96 -69
  166. package/src/data-structures/binary-tree/binary-tree.ts +535 -403
  167. package/src/data-structures/binary-tree/bst.ts +247 -277
  168. package/src/data-structures/binary-tree/rb-tree.ts +123 -103
  169. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -102
  170. package/src/data-structures/graph/abstract-graph.ts +10 -10
  171. package/src/data-structures/hash/hash-map.ts +46 -53
  172. package/src/data-structures/heap/heap.ts +71 -152
  173. package/src/data-structures/heap/max-heap.ts +88 -13
  174. package/src/data-structures/heap/min-heap.ts +78 -15
  175. package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
  176. package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
  177. package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
  178. package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
  179. package/src/data-structures/priority-queue/priority-queue.ts +81 -4
  180. package/src/data-structures/queue/deque.ts +37 -26
  181. package/src/data-structures/queue/queue.ts +23 -36
  182. package/src/data-structures/stack/stack.ts +31 -26
  183. package/src/data-structures/trie/trie.ts +35 -20
  184. package/src/interfaces/binary-tree.ts +9 -9
  185. package/src/types/common.ts +1 -2
  186. package/src/types/data-structures/base/base.ts +14 -6
  187. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -4
  188. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -4
  189. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -6
  190. package/src/types/data-structures/binary-tree/bst.ts +4 -5
  191. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -4
  192. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -4
  193. package/src/types/data-structures/heap/heap.ts +4 -1
  194. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
  195. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
  196. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  197. package/src/types/data-structures/queue/deque.ts +3 -1
  198. package/src/types/data-structures/queue/queue.ts +3 -1
  199. package/src/types/data-structures/stack/stack.ts +3 -1
  200. package/src/types/data-structures/trie/trie.ts +3 -1
  201. package/src/utils/utils.ts +3 -3
  202. package/test/integration/avl-tree.test.ts +2 -2
  203. package/test/integration/bst.test.ts +3 -3
  204. package/test/integration/index.html +25 -11
  205. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +68 -0
  206. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +56 -0
  207. package/test/unit/data-structures/graph/directed-graph.test.ts +2 -2
  208. package/test/unit/data-structures/heap/heap.test.ts +80 -0
  209. package/test/unit/data-structures/heap/max-heap.test.ts +44 -1
  210. package/test/unit/data-structures/heap/min-heap.test.ts +18 -1
  211. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +42 -0
  212. package/test/unit/data-structures/queue/deque.test.ts +30 -0
  213. package/test/unit/data-structures/queue/queue.test.ts +56 -0
  214. package/test/utils/big-o.ts +12 -6
  215. package/tsconfig-base.json +1 -0
  216. package/dist/cjs/data-structures/base/iterable-base.js.map +0 -1
@@ -47,27 +47,29 @@ export class AVLTreeNode extends BSTNode {
47
47
  */
48
48
  export class AVLTree extends BST {
49
49
  /**
50
- * The constructor function initializes an AVLTree object with optional keysOrNodesOrEntries and options.
51
- * @param [keysOrNodesOrEntries] - The `keysOrNodesOrEntries` parameter is an optional iterable of `KeyOrNodeOrEntry<K, V, NODE>`
52
- * objects. It represents a collection of nodes that will be added to the AVL tree during
53
- * initialization.
54
- * @param [options] - The `options` parameter is an optional object that allows you to customize the
55
- * behavior of the AVL tree. It is of type `Partial<AVLTreeOptions>`, which means that you can
56
- * provide only a subset of the properties defined in the `AVLTreeOptions` interface.
50
+ * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,
51
+ * entries, or raw elements.
52
+ * @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
53
+ * iterable object that can contain either keys, nodes, entries, or raw elements. These elements will
54
+ * be used to initialize the AVLTree.
55
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
56
+ * behavior of the AVLTree. It can include properties such as `compareFn` (a function used to compare
57
+ * keys), `allowDuplicates` (a boolean indicating whether duplicate keys are allowed), and
58
+ * `nodeBuilder` (
57
59
  */
58
- constructor(keysOrNodesOrEntries = [], options) {
60
+ constructor(keysOrNodesOrEntriesOrRawElements = [], options) {
59
61
  super([], options);
60
- if (keysOrNodesOrEntries)
61
- super.addMany(keysOrNodesOrEntries);
62
+ if (keysOrNodesOrEntriesOrRawElements)
63
+ super.addMany(keysOrNodesOrEntriesOrRawElements);
62
64
  }
63
65
  /**
64
- * The function creates a new AVL tree node with the specified key and value.
65
- * @param {K} key - The key parameter is the key value that will be associated with
66
- * the new node. It is used to determine the position of the node in the binary search tree.
67
- * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
68
- * type `V`, which means it can be any value that is assignable to the `value` property of the
69
- * node type `NODE`.
70
- * @returns a new AVLTreeNode object with the specified key and value.
66
+ * The function creates a new AVL tree node with the given key and value.
67
+ * @param {K} key - The key parameter is of type K, which represents the key of the node being
68
+ * created.
69
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
70
+ * value associated with the key in the node being created.
71
+ * @returns The method is returning a new instance of the AVLTreeNode class, casted as the generic
72
+ * type NODE.
71
73
  */
72
74
  createNode(key, value) {
73
75
  return new AVLTreeNode(key, value);
@@ -87,12 +89,14 @@ export class AVLTree extends BST {
87
89
  });
88
90
  }
89
91
  /**
90
- * The function checks if an keyOrNodeOrEntry is an instance of AVLTreeNode.
91
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
92
- * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the AVLTreeNode class.
92
+ * The function checks if the input is an instance of AVLTreeNode.
93
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
94
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
95
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
96
+ * an instance of the `AVLTreeNode` class.
93
97
  */
94
- isNode(keyOrNodeOrEntry) {
95
- return keyOrNodeOrEntry instanceof AVLTreeNode;
98
+ isNode(keyOrNodeOrEntryOrRawElement) {
99
+ return keyOrNodeOrEntryOrRawElement instanceof AVLTreeNode;
96
100
  }
97
101
  /**
98
102
  * Time Complexity: O(log n)
@@ -103,20 +107,21 @@ export class AVLTree extends BST {
103
107
  * Time Complexity: O(log n)
104
108
  * Space Complexity: O(1)
105
109
  *
106
- * The function overrides the add method of a binary tree node and balances the tree after inserting
107
- * a new node.
108
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
109
- * entry.
110
- * @param {V} [value] - The `value` parameter represents the value associated with the key that is
111
- * being added to the binary tree.
112
- * @returns The method is returning either the inserted node or undefined.
110
+ * The function overrides the add method of a class and inserts a key-value pair into a data
111
+ * structure, then balances the path.
112
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
113
+ * `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or
114
+ * `RawElement`.
115
+ * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
116
+ * the key or node being added to the data structure.
117
+ * @returns The method is returning a boolean value.
113
118
  */
114
- add(keyOrNodeOrEntry, value) {
115
- if (keyOrNodeOrEntry === null)
119
+ add(keyOrNodeOrEntryOrRawElement, value) {
120
+ if (keyOrNodeOrEntryOrRawElement === null)
116
121
  return false;
117
- const inserted = super.add(keyOrNodeOrEntry, value);
122
+ const inserted = super.add(keyOrNodeOrEntryOrRawElement, value);
118
123
  if (inserted)
119
- this._balancePath(keyOrNodeOrEntry);
124
+ this._balancePath(keyOrNodeOrEntryOrRawElement);
120
125
  return inserted;
121
126
  }
122
127
  /**
@@ -127,16 +132,14 @@ export class AVLTree extends BST {
127
132
  * Time Complexity: O(log n)
128
133
  * Space Complexity: O(1)
129
134
  *
130
- * The function overrides the delete method of a binary tree, performs the deletion, and then
131
- * balances the tree if necessary.
135
+ * The function overrides the delete method of a binary tree class and performs additional operations
136
+ * to balance the tree after deletion.
132
137
  * @param identifier - The `identifier` parameter is the value or condition used to identify the
133
- * node(s) to be deleted from the binary tree. It can be of any type and is the return type of the
134
- * `callback` function.
135
- * @param {C} callback - The `callback` parameter is a function that will be called for each node
136
- * that is deleted from the binary tree. It is an optional parameter and if not provided, it will
137
- * default to the `_DEFAULT_CALLBACK` function. The `callback` function should have a single
138
- * parameter of type `NODE
139
- * @returns The method is returning an array of `BinaryTreeDeleteResult<NODE>`.
138
+ * node(s) to be deleted from the binary tree. It can be of any type that is compatible with the
139
+ * binary tree's node type.
140
+ * @param {C} callback - The `callback` parameter is a function that will be used to determine if a
141
+ * node should be deleted or not. It is optional and has a default value of `this._DEFAULT_CALLBACK`.
142
+ * @returns The method is returning an array of BinaryTreeDeleteResult<NODE> objects.
140
143
  */
141
144
  delete(identifier, callback = this._DEFAULT_CALLBACK) {
142
145
  const deletedResults = super.delete(identifier, callback);
@@ -148,14 +151,21 @@ export class AVLTree extends BST {
148
151
  return deletedResults;
149
152
  }
150
153
  /**
151
- * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a binary
152
- * tree.
153
- * @param {K | NODE | undefined} srcNode - The `srcNode` parameter represents the source node that
154
- * needs to be swapped with the destination node. It can be of type `K`, `NODE`, or `undefined`.
155
- * @param {K | NODE | undefined} destNode - The `destNode` parameter represents the destination
156
- * node where the values from the source node will be swapped to.
157
- * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
158
- * if either `srcNode` or `destNode` is undefined.
154
+ * Time Complexity: O(1)
155
+ * Space Complexity: O(1)
156
+ */
157
+ /**
158
+ * Time Complexity: O(1)
159
+ * Space Complexity: O(1)
160
+ *
161
+ * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a
162
+ * binary search tree.
163
+ * @param {R | BSTNKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents either a node
164
+ * object (`NODE`) or a key-value pair (`R`) that is being swapped with another node.
165
+ * @param {R | BSTNKeyOrNode<K, NODE>} destNode - The `destNode` parameter is either an instance of
166
+ * `R` or an instance of `BSTNKeyOrNode<K, NODE>`.
167
+ * @returns The method is returning the `destNodeEnsured` object if both `srcNodeEnsured` and
168
+ * `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
159
169
  */
160
170
  _swapProperties(srcNode, destNode) {
161
171
  const srcNodeEnsured = this.ensureNode(srcNode);
@@ -185,7 +195,8 @@ export class AVLTree extends BST {
185
195
  * Space Complexity: O(1)
186
196
  *
187
197
  * The function calculates the balance factor of a node in a binary tree.
188
- * @param {NODE} node - The parameter "node" represents a node in a binary tree data structure.
198
+ * @param {NODE} node - The parameter "node" is of type "NODE", which likely represents a node in a
199
+ * binary tree data structure.
189
200
  * @returns the balance factor of a given node. The balance factor is calculated by subtracting the
190
201
  * height of the left subtree from the height of the right subtree.
191
202
  */
@@ -231,7 +242,7 @@ export class AVLTree extends BST {
231
242
  * Time Complexity: O(1)
232
243
  * Space Complexity: O(1)
233
244
  *
234
- * The function `_balanceLL` performs a left-left rotation to balance a binary tree.
245
+ * The `_balanceLL` function performs a left-left rotation to balance a binary search tree.
235
246
  * @param {NODE} A - A is a node in a binary tree.
236
247
  */
237
248
  _balanceLL(A) {
@@ -429,8 +440,8 @@ export class AVLTree extends BST {
429
440
  *
430
441
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
431
442
  * to restore balance in an AVL tree after inserting a node.
432
- * @param {NODE} node - The `node` parameter in the `_balancePath` function represents the node in the
433
- * AVL tree that needs to be balanced.
443
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or
444
+ * `KeyOrNodeOrEntry<K, V, NODE>`.
434
445
  */
435
446
  _balancePath(node) {
436
447
  node = this.ensureNode(node);
@@ -473,13 +484,21 @@ export class AVLTree extends BST {
473
484
  }
474
485
  }
475
486
  /**
476
- * The function replaces an old node with a new node while preserving the height of the old node.
477
- * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace with the
478
- * `newNode`.
487
+ * Time Complexity: O(1)
488
+ * Space Complexity: O(1)
489
+ */
490
+ /**
491
+ * Time Complexity: O(1)
492
+ * Space Complexity: O(1)
493
+ *
494
+ * The function replaces an old node with a new node and sets the height of the new node to be the
495
+ * same as the old node.
496
+ * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
497
+ * the data structure.
479
498
  * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
480
499
  * the data structure.
481
- * @returns the result of calling the `_replaceNode` method on the superclass, passing in the
482
- * `oldNode` and `newNode` as arguments.
500
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
501
+ * superclass, with the `oldNode` and `newNode` as arguments.
483
502
  */
484
503
  _replaceNode(oldNode, newNode) {
485
504
  newNode.height = oldNode.height;