stack-typed 1.53.9 → 1.54.1

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 (84) hide show
  1. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  2. package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
  3. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -189
  4. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -357
  5. package/dist/data-structures/binary-tree/avl-tree.d.ts +108 -78
  6. package/dist/data-structures/binary-tree/avl-tree.js +126 -79
  7. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  8. package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  9. package/dist/data-structures/binary-tree/binary-tree.d.ts +243 -190
  10. package/dist/data-structures/binary-tree/binary-tree.js +273 -229
  11. package/dist/data-structures/binary-tree/bst.d.ts +141 -122
  12. package/dist/data-structures/binary-tree/bst.js +170 -134
  13. package/dist/data-structures/binary-tree/index.d.ts +2 -0
  14. package/dist/data-structures/binary-tree/index.js +2 -0
  15. package/dist/data-structures/binary-tree/red-black-tree.d.ts +84 -80
  16. package/dist/data-structures/binary-tree/red-black-tree.js +101 -79
  17. package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
  18. package/dist/data-structures/binary-tree/tree-counter.js +444 -0
  19. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -186
  20. package/dist/data-structures/binary-tree/tree-multi-map.js +140 -388
  21. package/dist/data-structures/graph/directed-graph.d.ts +3 -0
  22. package/dist/data-structures/graph/directed-graph.js +3 -0
  23. package/dist/data-structures/graph/map-graph.d.ts +3 -0
  24. package/dist/data-structures/graph/map-graph.js +3 -0
  25. package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
  26. package/dist/data-structures/graph/undirected-graph.js +3 -0
  27. package/dist/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  28. package/dist/data-structures/linked-list/singly-linked-list.js +3 -0
  29. package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  30. package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
  31. package/dist/data-structures/matrix/matrix.d.ts +3 -0
  32. package/dist/data-structures/matrix/matrix.js +3 -0
  33. package/dist/data-structures/matrix/navigator.d.ts +3 -0
  34. package/dist/data-structures/matrix/navigator.js +3 -0
  35. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  36. package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
  37. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  38. package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
  39. package/dist/data-structures/trie/trie.d.ts +0 -4
  40. package/dist/data-structures/trie/trie.js +0 -4
  41. package/dist/interfaces/binary-tree.d.ts +7 -6
  42. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  43. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
  44. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -3
  45. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -2
  46. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -2
  47. package/dist/types/data-structures/binary-tree/bst.d.ts +3 -2
  48. package/dist/types/data-structures/binary-tree/index.d.ts +2 -0
  49. package/dist/types/data-structures/binary-tree/index.js +2 -0
  50. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +1 -3
  51. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  52. package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
  53. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -3
  54. package/package.json +2 -2
  55. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  56. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +148 -394
  57. package/src/data-structures/binary-tree/avl-tree.ts +152 -112
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  59. package/src/data-structures/binary-tree/binary-tree.ts +446 -379
  60. package/src/data-structures/binary-tree/bst.ts +224 -201
  61. package/src/data-structures/binary-tree/index.ts +2 -0
  62. package/src/data-structures/binary-tree/red-black-tree.ts +138 -114
  63. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +156 -428
  65. package/src/data-structures/graph/directed-graph.ts +3 -0
  66. package/src/data-structures/graph/map-graph.ts +3 -0
  67. package/src/data-structures/graph/undirected-graph.ts +3 -0
  68. package/src/data-structures/linked-list/singly-linked-list.ts +3 -0
  69. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  70. package/src/data-structures/matrix/matrix.ts +3 -0
  71. package/src/data-structures/matrix/navigator.ts +3 -0
  72. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  73. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  74. package/src/data-structures/trie/trie.ts +0 -4
  75. package/src/interfaces/binary-tree.ts +10 -11
  76. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  77. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -4
  78. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -3
  79. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  80. package/src/types/data-structures/binary-tree/bst.ts +5 -3
  81. package/src/types/data-structures/binary-tree/index.ts +2 -0
  82. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -4
  83. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  84. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -4
@@ -6,30 +6,26 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback } from '../../types';
9
+ import type { AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, OptNodeOrNull } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
- export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
11
+ export declare class AVLTreeNode<K = any, V = any> extends BSTNode<K, V> {
12
12
  /**
13
- * The constructor function initializes a new instance of a class with a key and an optional value,
14
- * and sets the height property to 0.
15
- * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
16
- * constructor. It is used to initialize the key property of the object being created.
17
- * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
18
- * value associated with the key in the constructor.
13
+ * This TypeScript constructor function initializes an instance with a key and an optional value.
14
+ * @param {K} key - The `key` parameter is typically used to uniquely identify an object or element
15
+ * within a data structure. It serves as a reference or identifier for accessing or manipulating the
16
+ * associated value or data.
17
+ * @param {V} [value] - The `value` parameter in the constructor is optional, meaning it does not
18
+ * have to be provided when creating an instance of the class. If a value is not provided, it will
19
+ * default to `undefined`.
19
20
  */
20
21
  constructor(key: K, value?: V);
21
- protected _height: number;
22
- /**
23
- * The function returns the value of the height property.
24
- * @returns The height of the object.
25
- */
26
- get height(): number;
27
- /**
28
- * The above function sets the value of the height property.
29
- * @param {number} value - The value parameter is a number that represents the new height value to be
30
- * set.
31
- */
32
- set height(value: number);
22
+ parent?: AVLTreeNode<K, V>;
23
+ _left?: OptNodeOrNull<AVLTreeNode<K, V>>;
24
+ get left(): OptNodeOrNull<AVLTreeNode<K, V>>;
25
+ set left(v: OptNodeOrNull<AVLTreeNode<K, V>>);
26
+ _right?: OptNodeOrNull<AVLTreeNode<K, V>>;
27
+ get right(): OptNodeOrNull<AVLTreeNode<K, V>>;
28
+ set right(v: OptNodeOrNull<AVLTreeNode<K, V>>);
33
29
  }
34
30
  /**
35
31
  * 1. Height-Balanced: Each node's left and right subtrees differ in height by no more than one.
@@ -40,165 +36,199 @@ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V
40
36
  * 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
41
37
  * 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
42
38
  */
43
- export declare class AVLTree<K = any, V = any, R = object, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>> extends BST<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
39
+ export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends BST<K, V, R, MK, MV, MR> implements IBinaryTree<K, V, R, MK, MV, MR> {
44
40
  /**
45
- * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,
46
- * entries, or raw elements.
47
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
48
- * iterable object that can contain either keys, nodes, entries, or raw elements. These elements will
49
- * be used to initialize the AVLTree.
50
- * @param [options] - The `options` parameter is an optional object that can be used to customize the
51
- * behavior of the AVLTree. It can include properties such as `compareFn` (a function used to compare
52
- * keys), `allowDuplicates` (a boolean indicating whether duplicate keys are allowed), and
53
- * `nodeBuilder` (
41
+ * This TypeScript constructor initializes an AVLTree with keys, nodes, entries, or raw data provided
42
+ * in an iterable format.
43
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
44
+ * iterable that can contain either `BTNRep<K, V, AVLTreeNode<K, V>>` objects or `R` objects. It is
45
+ * used to initialize the AVLTree with key-value pairs or raw data entries. If provided
46
+ * @param [options] - The `options` parameter in the constructor is of type `AVLTreeOptions<K, V,
47
+ * R>`. It is an optional parameter that allows you to specify additional options for configuring the
48
+ * AVL tree. These options could include things like custom comparators, initial capacity, or any
49
+ * other configuration settings specific
54
50
  */
55
- constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
51
+ constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, AVLTreeNode<K, V>> | R>, options?: AVLTreeOptions<K, V, R>);
56
52
  /**
53
+ * Time Complexity: O(1)
54
+ * Space Complexity: O(1)
55
+ *
57
56
  * The function creates a new AVL tree node with the given key and value.
58
57
  * @param {K} key - The key parameter is of type K, which represents the key of the node being
59
58
  * created.
60
59
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
61
60
  * value associated with the key in the node being created.
62
61
  * @returns The method is returning a new instance of the AVLTreeNode class, casted as the generic
63
- * type NODE.
62
+ * type AVLTreeNode<K, V>.
64
63
  */
65
- createNode(key: K, value?: V): NODE;
64
+ createNode(key: K, value?: V): AVLTreeNode<K, V>;
66
65
  /**
67
- * The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
68
- * options.
69
- * @param [options] - The `options` parameter in the `createTree` function is an object that contains
70
- * configuration options for creating an AVL tree. These options can include properties such as
71
- * `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
72
- * creates a
73
- * @returns An AVLTree object is being returned with the specified options and properties inherited
74
- * from the current object.
66
+ * Time Complexity: O(1)
67
+ * Space Complexity: O(1)
68
+ *
69
+ * The function creates a new AVL tree with the specified options and returns it.
70
+ * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
71
+ * passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
72
+ * being created.
73
+ * @returns a new AVLTree object.
75
74
  */
76
- createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R, NODE>;
75
+ createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R, MK, MV, MR>;
77
76
  /**
77
+ * Time Complexity: O(1)
78
+ * Space Complexity: O(1)
79
+ *
78
80
  * The function checks if the input is an instance of AVLTreeNode.
79
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
80
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
81
- * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
81
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
82
+ * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeNode<K, V>>`.
83
+ * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
82
84
  * an instance of the `AVLTreeNode` class.
83
85
  */
84
- isNode(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): keyNodeEntryOrRaw is NODE;
86
+ isNode(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): keyNodeOrEntry is AVLTreeNode<K, V>;
85
87
  /**
86
88
  * Time Complexity: O(log n)
87
- * Space Complexity: O(1)
89
+ * Space Complexity: O(log n)
88
90
  *
89
91
  * The function overrides the add method of a class and inserts a key-value pair into a data
90
92
  * structure, then balances the path.
91
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
92
- * `keyNodeEntryOrRaw` can accept values of type `R`, `BTNRep<K, V, NODE>`, or
93
- * `RawElement`.
93
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
94
+ * `keyNodeOrEntry` can accept values of type `R`, `BTNRep<K, V, AVLTreeNode<K, V>>`
94
95
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
95
96
  * the key or node being added to the data structure.
96
97
  * @returns The method is returning a boolean value.
97
98
  */
98
- add(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): boolean;
99
+ add(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>, value?: V): boolean;
99
100
  /**
100
101
  * Time Complexity: O(log n)
101
- * Space Complexity: O(1)
102
+ * Space Complexity: O(log n)
102
103
  *
103
104
  * The function overrides the delete method in a TypeScript class, performs deletion, and then
104
105
  * balances the tree if necessary.
105
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `keyNodeEntryOrRaw`
106
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
106
107
  * parameter in the `override delete` method can be one of the following types:
107
108
  * @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
108
109
  * method from the superclass (presumably a parent class) with the provided `predicate`, which could
109
110
  * be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
110
111
  * `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
111
112
  */
112
- delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): BinaryTreeDeleteResult<NODE>[];
113
- map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR, AVLTreeNode<MK, MV, AVLTreeNodeNested<MK, MV>>>;
113
+ delete(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): BinaryTreeDeleteResult<AVLTreeNode<K, V>>[];
114
+ /**
115
+ * Time Complexity: O(n)
116
+ * Space Complexity: O(n)
117
+ *
118
+ * The `map` function in TypeScript overrides the default map behavior of an AVLTree data structure
119
+ * by applying a callback function to each entry and creating a new AVLTree with the results.
120
+ * @param callback - A function that will be called for each entry in the AVLTree. It takes four
121
+ * arguments: the key, the value (which can be undefined), the index of the entry, and a reference to
122
+ * the AVLTree itself.
123
+ * @param [options] - The `options` parameter in the `override map` function is of type
124
+ * `AVLTreeOptions<MK, MV, MR>`. It is an optional parameter that allows you to specify additional
125
+ * options for the AVL tree being created during the mapping process. These options could include
126
+ * custom comparators, initial
127
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
128
+ * the value of `this` when executing the `callback` function. It allows you to set the context
129
+ * (value of `this`) within the callback function. This can be useful when you want to access
130
+ * properties or
131
+ * @returns The `map` method is returning a new AVLTree instance (`newTree`) with the entries
132
+ * modified by the provided callback function.
133
+ */
134
+ map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR>;
135
+ /**
136
+ * Time Complexity: O(n)
137
+ * Space Complexity: O(n)
138
+ *
139
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
140
+ * structure.
141
+ * @returns A cloned tree object is being returned.
142
+ */
143
+ clone(): AVLTree<K, V, R, MK, MV, MR>;
114
144
  /**
115
145
  * Time Complexity: O(1)
116
146
  * Space Complexity: O(1)
117
147
  *
118
148
  * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a
119
149
  * binary search tree.
120
- * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents either a node
121
- * object (`NODE`) or a key-value pair (`R`) that is being swapped with another node.
122
- * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter is either an instance of
123
- * `R` or an instance of `BSTNOptKeyOrNode<K, NODE>`.
150
+ * @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} srcNode - The `srcNode` parameter represents either a node
151
+ * object (`AVLTreeNode<K, V>`) or a key-value pair (`R`) that is being swapped with another node.
152
+ * @param {BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>} destNode - The `destNode` parameter is either an instance of
153
+ * `R` or an instance of `BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>`.
124
154
  * @returns The method is returning the `destNodeEnsured` object if both `srcNodeEnsured` and
125
155
  * `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
126
156
  */
127
- protected _swapProperties(srcNode: R | BSTNOptKeyOrNode<K, NODE>, destNode: R | BSTNOptKeyOrNode<K, NODE>): NODE | undefined;
157
+ protected _swapProperties(srcNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>, destNode: BSTNOptKeyOrNode<K, AVLTreeNode<K, V>>): AVLTreeNode<K, V> | undefined;
128
158
  /**
129
159
  * Time Complexity: O(1)
130
160
  * Space Complexity: O(1)
131
161
  *
132
162
  * The function calculates the balance factor of a node in a binary tree.
133
- * @param {NODE} node - The parameter "node" is of type "NODE", which likely represents a node in a
163
+ * @param {AVLTreeNode<K, V>} node - The parameter "node" is of type "AVLTreeNode<K, V>", which likely represents a node in a
134
164
  * binary tree data structure.
135
165
  * @returns the balance factor of a given node. The balance factor is calculated by subtracting the
136
166
  * height of the left subtree from the height of the right subtree.
137
167
  */
138
- protected _balanceFactor(node: NODE): number;
168
+ protected _balanceFactor(node: AVLTreeNode<K, V>): number;
139
169
  /**
140
170
  * Time Complexity: O(1)
141
171
  * Space Complexity: O(1)
142
172
  *
143
173
  * The function updates the height of a node in a binary tree based on the heights of its left and
144
174
  * right children.
145
- * @param {NODE} node - The parameter "node" represents a node in a binary tree data structure.
175
+ * @param {AVLTreeNode<K, V>} node - The parameter "node" represents a node in a binary tree data structure.
146
176
  */
147
- protected _updateHeight(node: NODE): void;
177
+ protected _updateHeight(node: AVLTreeNode<K, V>): void;
148
178
  /**
149
179
  * Time Complexity: O(1)
150
180
  * Space Complexity: O(1)
151
181
  *
152
182
  * The `_balanceLL` function performs a left-left rotation to balance a binary search tree.
153
- * @param {NODE} A - A is a node in a binary tree.
183
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
154
184
  */
155
- protected _balanceLL(A: NODE): void;
185
+ protected _balanceLL(A: AVLTreeNode<K, V>): void;
156
186
  /**
157
187
  * Time Complexity: O(1)
158
188
  * Space Complexity: O(1)
159
189
  *
160
190
  * The `_balanceLR` function performs a left-right rotation to balance a binary tree.
161
- * @param {NODE} A - A is a node in a binary tree.
191
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
162
192
  */
163
- protected _balanceLR(A: NODE): void;
193
+ protected _balanceLR(A: AVLTreeNode<K, V>): void;
164
194
  /**
165
195
  * Time Complexity: O(1)
166
196
  * Space Complexity: O(1)
167
197
  *
168
198
  * The function `_balanceRR` performs a right-right rotation to balance a binary tree.
169
- * @param {NODE} A - A is a node in a binary tree.
199
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
170
200
  */
171
- protected _balanceRR(A: NODE): void;
201
+ protected _balanceRR(A: AVLTreeNode<K, V>): void;
172
202
  /**
173
203
  * Time Complexity: O(1)
174
204
  * Space Complexity: O(1)
175
205
  *
176
206
  * The function `_balanceRL` performs a right-left rotation to balance a binary tree.
177
- * @param {NODE} A - A is a node in a binary tree.
207
+ * @param {AVLTreeNode<K, V>} A - A is a node in a binary tree.
178
208
  */
179
- protected _balanceRL(A: NODE): void;
209
+ protected _balanceRL(A: AVLTreeNode<K, V>): void;
180
210
  /**
181
211
  * Time Complexity: O(log n)
182
212
  * Space Complexity: O(1)
183
213
  *
184
214
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
185
215
  * to restore balance in an AVL tree after inserting a node.
186
- * @param {BTNRep<K, V, NODE> | R} node - The `node` parameter can be of type `R` or
187
- * `BTNRep<K, V, NODE>`.
216
+ * @param {BTNRep<K, V, AVLTreeNode<K, V>>} node - The `node` parameter can be of type `R` or
217
+ * `BTNRep<K, V, AVLTreeNode<K, V>>`.
188
218
  */
189
- protected _balancePath(node: BTNRep<K, V, NODE> | R): void;
219
+ protected _balancePath(node: BTNRep<K, V, AVLTreeNode<K, V>>): void;
190
220
  /**
191
221
  * Time Complexity: O(1)
192
222
  * Space Complexity: O(1)
193
223
  *
194
224
  * The function replaces an old node with a new node and sets the height of the new node to be the
195
225
  * same as the old node.
196
- * @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
226
+ * @param {AVLTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
197
227
  * the data structure.
198
- * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
228
+ * @param {AVLTreeNode<K, V>} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
199
229
  * the data structure.
200
230
  * @returns The method is returning the result of calling the `_replaceNode` method from the
201
231
  * superclass, with the `oldNode` and `newNode` as arguments.
202
232
  */
203
- protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
233
+ protected _replaceNode(oldNode: AVLTreeNode<K, V>, newNode: AVLTreeNode<K, V>): AVLTreeNode<K, V>;
204
234
  }