linked-list-typed 2.0.5 → 2.1.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 (102) hide show
  1. package/README.md +14 -14
  2. package/dist/data-structures/base/iterable-element-base.d.ts +186 -83
  3. package/dist/data-structures/base/iterable-element-base.js +149 -107
  4. package/dist/data-structures/base/iterable-entry-base.d.ts +95 -119
  5. package/dist/data-structures/base/iterable-entry-base.js +59 -116
  6. package/dist/data-structures/base/linear-base.d.ts +250 -192
  7. package/dist/data-structures/base/linear-base.js +137 -274
  8. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +126 -158
  9. package/dist/data-structures/binary-tree/avl-tree-counter.js +171 -205
  10. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +100 -69
  11. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +135 -87
  12. package/dist/data-structures/binary-tree/avl-tree.d.ts +138 -149
  13. package/dist/data-structures/binary-tree/avl-tree.js +208 -195
  14. package/dist/data-structures/binary-tree/binary-tree.d.ts +476 -632
  15. package/dist/data-structures/binary-tree/binary-tree.js +602 -873
  16. package/dist/data-structures/binary-tree/bst.d.ts +258 -306
  17. package/dist/data-structures/binary-tree/bst.js +505 -481
  18. package/dist/data-structures/binary-tree/red-black-tree.d.ts +107 -179
  19. package/dist/data-structures/binary-tree/red-black-tree.js +114 -209
  20. package/dist/data-structures/binary-tree/tree-counter.d.ts +132 -154
  21. package/dist/data-structures/binary-tree/tree-counter.js +172 -203
  22. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +72 -69
  23. package/dist/data-structures/binary-tree/tree-multi-map.js +105 -85
  24. package/dist/data-structures/graph/abstract-graph.d.ts +238 -233
  25. package/dist/data-structures/graph/abstract-graph.js +267 -237
  26. package/dist/data-structures/graph/directed-graph.d.ts +108 -224
  27. package/dist/data-structures/graph/directed-graph.js +146 -233
  28. package/dist/data-structures/graph/map-graph.d.ts +49 -55
  29. package/dist/data-structures/graph/map-graph.js +56 -59
  30. package/dist/data-structures/graph/undirected-graph.d.ts +103 -146
  31. package/dist/data-structures/graph/undirected-graph.js +129 -149
  32. package/dist/data-structures/hash/hash-map.d.ts +164 -338
  33. package/dist/data-structures/hash/hash-map.js +270 -457
  34. package/dist/data-structures/heap/heap.d.ts +214 -289
  35. package/dist/data-structures/heap/heap.js +340 -349
  36. package/dist/data-structures/heap/max-heap.d.ts +11 -47
  37. package/dist/data-structures/heap/max-heap.js +11 -66
  38. package/dist/data-structures/heap/min-heap.d.ts +12 -47
  39. package/dist/data-structures/heap/min-heap.js +11 -66
  40. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +231 -347
  41. package/dist/data-structures/linked-list/doubly-linked-list.js +368 -494
  42. package/dist/data-structures/linked-list/singly-linked-list.d.ts +261 -310
  43. package/dist/data-structures/linked-list/singly-linked-list.js +447 -466
  44. package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -107
  45. package/dist/data-structures/linked-list/skip-linked-list.js +0 -100
  46. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -56
  47. package/dist/data-structures/priority-queue/max-priority-queue.js +11 -78
  48. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -57
  49. package/dist/data-structures/priority-queue/min-priority-queue.js +10 -79
  50. package/dist/data-structures/priority-queue/priority-queue.d.ts +2 -61
  51. package/dist/data-structures/priority-queue/priority-queue.js +8 -83
  52. package/dist/data-structures/queue/deque.d.ts +227 -254
  53. package/dist/data-structures/queue/deque.js +309 -348
  54. package/dist/data-structures/queue/queue.d.ts +180 -201
  55. package/dist/data-structures/queue/queue.js +265 -248
  56. package/dist/data-structures/stack/stack.d.ts +124 -102
  57. package/dist/data-structures/stack/stack.js +181 -125
  58. package/dist/data-structures/trie/trie.d.ts +164 -165
  59. package/dist/data-structures/trie/trie.js +189 -172
  60. package/dist/interfaces/binary-tree.d.ts +56 -6
  61. package/dist/interfaces/graph.d.ts +16 -0
  62. package/dist/types/data-structures/base/base.d.ts +1 -1
  63. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -0
  64. package/dist/types/utils/utils.d.ts +1 -0
  65. package/dist/utils/utils.d.ts +1 -1
  66. package/dist/utils/utils.js +2 -1
  67. package/package.json +2 -2
  68. package/src/data-structures/base/iterable-element-base.ts +238 -115
  69. package/src/data-structures/base/iterable-entry-base.ts +96 -120
  70. package/src/data-structures/base/linear-base.ts +271 -277
  71. package/src/data-structures/binary-tree/avl-tree-counter.ts +196 -217
  72. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +188 -102
  73. package/src/data-structures/binary-tree/avl-tree.ts +237 -206
  74. package/src/data-structures/binary-tree/binary-tree.ts +665 -896
  75. package/src/data-structures/binary-tree/bst.ts +565 -572
  76. package/src/data-structures/binary-tree/red-black-tree.ts +157 -223
  77. package/src/data-structures/binary-tree/tree-counter.ts +195 -219
  78. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -98
  79. package/src/data-structures/graph/abstract-graph.ts +339 -264
  80. package/src/data-structures/graph/directed-graph.ts +146 -236
  81. package/src/data-structures/graph/map-graph.ts +63 -60
  82. package/src/data-structures/graph/undirected-graph.ts +129 -152
  83. package/src/data-structures/hash/hash-map.ts +274 -496
  84. package/src/data-structures/heap/heap.ts +389 -402
  85. package/src/data-structures/heap/max-heap.ts +12 -76
  86. package/src/data-structures/heap/min-heap.ts +13 -76
  87. package/src/data-structures/linked-list/doubly-linked-list.ts +426 -530
  88. package/src/data-structures/linked-list/singly-linked-list.ts +495 -517
  89. package/src/data-structures/linked-list/skip-linked-list.ts +1 -108
  90. package/src/data-structures/priority-queue/max-priority-queue.ts +12 -87
  91. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -88
  92. package/src/data-structures/priority-queue/priority-queue.ts +3 -92
  93. package/src/data-structures/queue/deque.ts +381 -357
  94. package/src/data-structures/queue/queue.ts +310 -264
  95. package/src/data-structures/stack/stack.ts +217 -131
  96. package/src/data-structures/trie/trie.ts +240 -175
  97. package/src/interfaces/binary-tree.ts +240 -6
  98. package/src/interfaces/graph.ts +37 -0
  99. package/src/types/data-structures/base/base.ts +5 -5
  100. package/src/types/data-structures/graph/abstract-graph.ts +5 -0
  101. package/src/types/utils/utils.ts +2 -0
  102. package/src/utils/utils.ts +9 -14
@@ -1,27 +1,59 @@
1
- import type { BinaryTreeDeleteResult, CRUD, EntryCallback, RBTNColor, RedBlackTreeOptions } from '../../types';
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ import type { BinaryTreeDeleteResult, BinaryTreeOptions, CRUD, EntryCallback, RBTNColor, RedBlackTreeOptions } from '../../types';
2
9
  import { BST, BSTNode } from './bst';
3
10
  import { IBinaryTree } from '../../interfaces';
4
11
  export declare class RedBlackTreeNode<K = any, V = any> extends BSTNode<K, V> {
5
12
  parent?: RedBlackTreeNode<K, V>;
6
13
  /**
7
- * The constructor initializes a node with a key, value, and color for a Red-Black Tree.
8
- * @param {K} key - The `key` parameter is a key of type `K` that is used to identify the node in a
9
- * Red-Black Tree data structure.
10
- * @param {V} [value] - The `value` parameter in the constructor is an optional parameter of type
11
- * `V`. It represents the value associated with the key in the data structure being constructed.
12
- * @param {RBTNColor} [color=BLACK] - The `color` parameter in the constructor is used to specify the
13
- * color of the node in a Red-Black Tree. It has a default value of 'BLACK' if not provided
14
- * explicitly.
14
+ * Create a Red-Black Tree and optionally bulk-insert items.
15
+ * @remarks Time O(n log n), Space O(n)
16
+ * @param key - See parameter type for details.
17
+ * @param [value]- See parameter type for details.
18
+ * @param color - See parameter type for details.
19
+ * @returns New RedBlackTree instance.
15
20
  */
16
21
  constructor(key: K, value?: V, color?: RBTNColor);
17
22
  _left?: RedBlackTreeNode<K, V> | null | undefined;
23
+ /**
24
+ * Get the left child pointer.
25
+ * @remarks Time O(1), Space O(1)
26
+ * @returns Left child node, or null/undefined.
27
+ */
18
28
  get left(): RedBlackTreeNode<K, V> | null | undefined;
29
+ /**
30
+ * Set the left child and update its parent pointer.
31
+ * @remarks Time O(1), Space O(1)
32
+ * @param v - New left node, or null/undefined.
33
+ * @returns void
34
+ */
19
35
  set left(v: RedBlackTreeNode<K, V> | null | undefined);
20
36
  _right?: RedBlackTreeNode<K, V> | null | undefined;
37
+ /**
38
+ * Get the right child pointer.
39
+ * @remarks Time O(1), Space O(1)
40
+ * @returns Right child node, or null/undefined.
41
+ */
21
42
  get right(): RedBlackTreeNode<K, V> | null | undefined;
43
+ /**
44
+ * Set the right child and update its parent pointer.
45
+ * @remarks Time O(1), Space O(1)
46
+ * @param v - New right node, or null/undefined.
47
+ * @returns void
48
+ */
22
49
  set right(v: RedBlackTreeNode<K, V> | null | undefined);
23
50
  }
24
51
  /**
52
+ * RRRRRRRRRRRRRRRRRRRed-Black Tree (self-balancing BST) supporting map-like mode and stable O(log n) updates.
53
+ * @remarks Time O(1), Space O(1)
54
+ * @template K
55
+ * @template V
56
+ * @template R
25
57
  * 1. Efficient self-balancing, but not completely balanced. Compared with AVLTree, the addition and deletion efficiency is high but the query efficiency is slightly lower.
26
58
  * 2. It is BST itself. Compared with Heap which is not completely ordered, RedBlackTree is completely ordered.
27
59
  * @example
@@ -68,213 +100,109 @@ export declare class RedBlackTreeNode<K = any, V = any> extends BSTNode<K, V> {
68
100
  * );
69
101
  * console.log(stocksInRange); // ['GOOGL', 'META', 'MSFT']
70
102
  */
71
- export declare class RedBlackTree<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> {
72
- /**
73
- * This TypeScript constructor initializes a Red-Black Tree with optional keys, nodes, entries, or
74
- * raw data.
75
- * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
76
- * iterable that can contain either `K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined` objects or `R` objects. It
77
- * is used to initialize the Red-Black Tree with keys, nodes, entries, or
78
- * @param [options] - The `options` parameter in the constructor is of type `RedBlackTreeOptions<K,
79
- * V, R>`. It is an optional parameter that allows you to specify additional options for the
80
- * RedBlackTree class. These options could include configuration settings, behavior customization, or
81
- * any other parameters that are specific to
82
- */
103
+ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R> implements IBinaryTree<K, V, R> {
83
104
  constructor(keysNodesEntriesOrRaws?: Iterable<K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: RedBlackTreeOptions<K, V, R>);
84
105
  protected _root: RedBlackTreeNode<K, V> | undefined;
85
- get root(): RedBlackTreeNode<K, V> | undefined;
86
106
  /**
87
- * Time Complexity: O(1)
88
- * Space Complexity: O(1)
89
- *
90
- * The function creates a new Red-Black Tree node with the specified key, value, and color.
91
- * @param {K} key - The key parameter represents the key value of the node being created. It is of
92
- * type K, which is a generic type that can be replaced with any specific type when using the
93
- * function.
94
- * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
95
- * associated with the key in the node. It is not required and can be omitted if you only need to
96
- * create a node with a key.
97
- * @param {RBTNColor} [color=BLACK] - The "color" parameter is used to specify the color of the node
98
- * in a Red-Black Tree. It can have two possible values: "RED" or "BLACK". By default, the color is
99
- * set to "BLACK" if not specified.
100
- * @returns A new instance of a RedBlackTreeNode with the specified key, value, and color is being
101
- * returned.
107
+ * Get the current root node.
108
+ * @remarks Time O(1), Space O(1)
109
+ * @returns Root node, or undefined.
102
110
  */
103
- createNode(key: K, value?: V, color?: RBTNColor): RedBlackTreeNode<K, V>;
111
+ get root(): RedBlackTreeNode<K, V> | undefined;
104
112
  /**
105
- * Time Complexity: O(1)
106
- * Space Complexity: O(1)
107
- *
108
- * The function creates a new Red-Black Tree with the specified options.
109
- * @param [options] - The `options` parameter is an optional object that contains additional
110
- * configuration options for creating the Red-Black Tree. It has the following properties:
111
- * @returns a new instance of a RedBlackTree object.
113
+ * Create a red-black node for the given key/value (value ignored in map mode).
114
+ * @remarks Time O(1), Space O(1)
115
+ * @param key - See parameter type for details.
116
+ * @param [value] - See parameter type for details.
117
+ * @param color - See parameter type for details.
118
+ * @returns A new RedBlackTreeNode instance.
112
119
  */
113
- createTree(options?: RedBlackTreeOptions<K, V, R>): RedBlackTree<K, V, R, MK, MV, MR>;
120
+ _createNode(key: K, value?: V, color?: RBTNColor): RedBlackTreeNode<K, V>;
114
121
  /**
115
- * Time Complexity: O(1)
116
- * Space Complexity: O(1)
117
- *
118
- * The function checks if the input is an instance of the RedBlackTreeNode class.
119
- * @param {K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
120
- * `keyNodeOrEntry` can be of type `R` or `K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
121
- * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
122
- * an instance of the `RedBlackTreeNode` class.
122
+ * Type guard: check whether the input is a RedBlackTreeNode.
123
+ * @remarks Time O(1), Space O(1)
124
+ * @param keyNodeOrEntry - See parameter type for details.
125
+ * @returns True if the value is a RedBlackTreeNode.
123
126
  */
124
127
  isNode(keyNodeOrEntry: K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is RedBlackTreeNode<K, V>;
125
128
  /**
126
- * Time Complexity: O(1)
127
- * Space Complexity: O(1)
128
- *
129
- * The "clear" function sets the root node of a data structure to a sentinel value and resets the
130
- * size counter to zero.
129
+ * Remove all nodes and clear the key→value store (if in map mode).
130
+ * @remarks Time O(n), Space O(1)
131
+ * @returns void
131
132
  */
132
133
  clear(): void;
133
134
  /**
134
- * Time Complexity: O(log n)
135
- * Space Complexity: O(log n)
136
- *
137
- * The function adds a new node to a binary search tree and returns true if the node was successfully
138
- * added.
139
- * @param {K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
140
- * `keyNodeOrEntry` can accept a value of type `R` or `K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
141
- * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
142
- * the key in the data structure. It represents the value that you want to add or update in the data
143
- * structure.
144
- * @returns The method is returning a boolean value. If a new node is successfully added to the tree,
145
- * the method returns true. If the node already exists and its value is updated, the method also
146
- * returns true. If the node cannot be added or updated, the method returns false.
135
+ * Insert or replace an entry using BST order and red-black fix-up.
136
+ * @remarks Time O(log n), Space O(1)
137
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
138
+ * @param [value]- See parameter type for details.
139
+ * @returns True if inserted or updated; false if ignored.
147
140
  */
148
141
  add(keyNodeOrEntry: K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
149
142
  /**
150
- * Time Complexity: O(log n)
151
- * Space Complexity: O(log n)
152
- *
153
- * The function overrides the delete method in a binary tree data structure to remove a node based on
154
- * a given predicate and maintain the binary search tree properties.
155
- * @param {K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The `keyNodeOrEntry`
156
- * parameter in the `override delete` method is used to specify the condition or key based on which a
157
- * node should be deleted from the binary tree. It can be a key, a node, an entry, or a predicate
158
- * function that determines which node(s) should be deleted.
159
- * @returns The `override delete` method is returning an array of `BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>`
160
- * objects. Each object in the array contains information about the deleted node and whether
161
- * balancing is needed.
143
+ * Delete a node by key/node/entry and rebalance as needed.
144
+ * @remarks Time O(log n), Space O(1)
145
+ * @param keyNodeOrEntry - Key, node, or [key, value] entry identifying the node to delete.
146
+ * @returns Array with deletion metadata (removed node, rebalancing hint if any).
162
147
  */
163
148
  delete(keyNodeOrEntry: K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>[];
164
149
  /**
165
- * Time Complexity: O(n)
166
- * Space Complexity: O(n)
167
- *
168
- * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
169
- * applying a callback to each entry in the original tree.
170
- * @param callback - A function that will be called for each entry in the tree, with parameters
171
- * representing the key, value, index, and the tree itself. It should return an entry for the new
172
- * tree.
173
- * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
174
- * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
175
- * Tree that will be created during the mapping process. These options could include things like
176
- * custom comparators
177
- * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
178
- * the value of `this` when executing the `callback` function. It allows you to set the context
179
- * (value of `this`) for the callback function. This can be useful when you want to access properties
180
- * or
181
- * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
182
- * provided callback function.
183
- */
184
- map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: RedBlackTreeOptions<MK, MV, MR>, thisArg?: any): RedBlackTree<MK, MV, MR>;
185
- /**
186
- * Time Complexity: O(n)
187
- * Space Complexity: O(n)
188
- *
189
- * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
190
- * structure.
191
- * @returns The `cloned` object is being returned.
192
- */
193
- clone(): RedBlackTree<K, V, R, MK, MV, MR>;
194
- /**
195
- * Time Complexity: O(1)
196
- * Space Complexity: O(1)
197
- *
198
- * The function sets the root of a tree-like structure and updates the parent property of the new
199
- * root.
200
- * @param {RedBlackTreeNode<K, V> | undefined} v - v is a parameter of type RedBlackTreeNode<K, V> or undefined.
201
- */
150
+ * Transform entries into a like-kind red-black tree with possibly different key/value types.
151
+ * @remarks Time O(n), Space O(n)
152
+ * @template MK
153
+ * @template MV
154
+ * @template MR
155
+ * @param callback - Mapping function from (key, value, index, tree) to a new [key, value].
156
+ * @param [options] - See parameter type for details.
157
+ * @param [thisArg] - See parameter type for details.
158
+ * @returns A new RedBlackTree with mapped entries.
159
+ */
160
+ map<MK = K, MV = V, MR = any>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: Partial<BinaryTreeOptions<MK, MV, MR>>, thisArg?: unknown): RedBlackTree<MK, MV, MR>;
161
+ protected _createInstance<TK = K, TV = V, TR = R>(options?: Partial<RedBlackTreeOptions<TK, TV, TR>>): this;
162
+ protected _createLike<TK = K, TV = V, TR = R>(iter?: Iterable<TK | RedBlackTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>, options?: Partial<RedBlackTreeOptions<TK, TV, TR>>): RedBlackTree<TK, TV, TR>;
202
163
  protected _setRoot(v: RedBlackTreeNode<K, V> | undefined): void;
203
- /**
204
- * Time Complexity: O(1)
205
- * Space Complexity: O(1)
206
- *
207
- * The function replaces an old node with a new node while preserving the color of the old node.
208
- * @param {RedBlackTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
209
- * the data structure.
210
- * @param {RedBlackTreeNode<K, V>} newNode - The `newNode` parameter is of type `RedBlackTreeNode<K, V>`, which represents a node in a
211
- * data structure.
212
- * @returns The method is returning the result of calling the `_replaceNode` method from the
213
- * superclass, with the `oldNode` and `newNode` parameters.
214
- */
215
164
  protected _replaceNode(oldNode: RedBlackTreeNode<K, V>, newNode: RedBlackTreeNode<K, V>): RedBlackTreeNode<K, V>;
216
165
  /**
217
- * Time Complexity: O(log n)
218
- * Space Complexity: O(log n)
219
- *
220
- * The `_insert` function inserts a node into a binary search tree and performs necessary fix-ups to
221
- * maintain the red-black tree properties.
222
- * @param {RedBlackTreeNode<K, V>} node - The `node` parameter represents the node that needs to be inserted into the
223
- * binary search tree.
224
- * @returns a string value indicating the result of the insertion operation. It can return either
225
- * 'UPDATED' if the node with the same key already exists and was updated, or 'CREATED' if a new node
226
- * was created and inserted into the tree.
166
+ * (Protected) Standard BST insert followed by red-black fix-up.
167
+ * @remarks Time O(log n), Space O(1)
168
+ * @param node - Node to insert.
169
+ * @returns Status string: 'CREATED' or 'UPDATED'.
227
170
  */
228
171
  protected _insert(node: RedBlackTreeNode<K, V>): CRUD;
229
172
  /**
230
- * Time Complexity: O(1)
231
- * Space Complexity: O(1)
232
- *
233
- * The function `_transplant` is used to replace a node `u` with another node `v` in a binary tree.
234
- * @param {RedBlackTreeNode<K, V>} u - The parameter "u" represents a node in a binary tree.
235
- * @param {RedBlackTreeNode<K, V> | undefined} v - The parameter `v` is of type `RedBlackTreeNode<K, V> | undefined`, which means it can
236
- * either be a `RedBlackTreeNode<K, V>` object or `undefined`.
173
+ * (Protected) Transplant a subtree in place of another during deletion.
174
+ * @remarks Time O(1), Space O(1)
175
+ * @param u - Node to replace.
176
+ * @param v - Replacement subtree root (may be undefined).
177
+ * @returns void
237
178
  */
238
179
  protected _transplant(u: RedBlackTreeNode<K, V>, v: RedBlackTreeNode<K, V> | undefined): void;
239
180
  /**
240
- * Time Complexity: O(log n)
241
- * Space Complexity: O(1)
242
- *
243
- * The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
244
- * @param {RedBlackTreeNode<K, V> | undefined} z - The parameter `z` represents a node in the Red-Black Tree data
245
- * structure. It can either be a valid node or `undefined`.
181
+ * (Protected) Restore red-black properties after insertion (recolor/rotate).
182
+ * @remarks Time O(log n), Space O(1)
183
+ * @param z - Recently inserted node.
184
+ * @returns void
246
185
  */
247
186
  protected _insertFixup(z: RedBlackTreeNode<K, V> | undefined): void;
248
187
  /**
249
- * Time Complexity: O(log n)
250
- * Space Complexity: O(1)
251
- *
252
- * The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
253
- * the colors and performing rotations.
254
- * @param {RedBlackTreeNode<K, V> | undefined} node - The `node` parameter represents a node in a binary tree. It can
255
- * be either a valid node object or `undefined`.
256
- * @returns The function does not return any value. It has a return type of `void`, which means it
257
- * does not return anything.
188
+ * (Protected) Restore red-black properties after deletion (recolor/rotate).
189
+ * @remarks Time O(log n), Space O(1)
190
+ * @param node - Child that replaced the deleted node (may be undefined).
191
+ * @returns void
258
192
  */
259
193
  protected _deleteFixup(node: RedBlackTreeNode<K, V> | undefined): void;
260
194
  /**
261
- * Time Complexity: O(1)
262
- * Space Complexity: O(1)
263
- *
264
- * The `_leftRotate` function performs a left rotation on a given node in a binary tree.
265
- * @param {RedBlackTreeNode<K, V> | undefined} x - The parameter `x` is of type `RedBlackTreeNode<K, V> | undefined`. It represents a
266
- * node in a binary tree or `undefined` if there is no node.
267
- * @returns void, which means it does not return any value.
195
+ * (Protected) Perform a left rotation around x.
196
+ * @remarks Time O(1), Space O(1)
197
+ * @param x - Pivot node to rotate around.
198
+ * @returns void
268
199
  */
269
200
  protected _leftRotate(x: RedBlackTreeNode<K, V> | undefined): void;
270
201
  /**
271
- * Time Complexity: O(1)
272
- * Space Complexity: O(1)
273
- *
274
- * The `_rightRotate` function performs a right rotation on a given node in a binary tree.
275
- * @param {RedBlackTreeNode<K, V> | undefined} y - The parameter `y` is of type `RedBlackTreeNode<K, V> | undefined`. It represents a
276
- * node in a binary tree or `undefined` if there is no node.
277
- * @returns void, which means it does not return any value.
202
+ * (Protected) Perform a right rotation around y.
203
+ * @remarks Time O(1), Space O(1)
204
+ * @param y - Pivot node to rotate around.
205
+ * @returns void
278
206
  */
279
207
  protected _rightRotate(y: RedBlackTreeNode<K, V> | undefined): void;
280
208
  }