graph-typed 1.50.5 → 1.50.7
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.
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -0
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +3 -0
- package/dist/data-structures/binary-tree/binary-tree.js +32 -28
- package/dist/data-structures/binary-tree/bst.js +17 -17
- package/dist/data-structures/binary-tree/rb-tree.d.ts +158 -141
- package/dist/data-structures/binary-tree/rb-tree.js +416 -396
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +1 -0
- package/dist/data-structures/binary-tree/tree-multi-map.js +84 -76
- package/dist/types/common.d.ts +6 -0
- package/dist/types/common.js +8 -1
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +5 -1
- package/src/data-structures/binary-tree/avl-tree.ts +1 -1
- package/src/data-structures/binary-tree/binary-tree.ts +31 -29
- package/src/data-structures/binary-tree/bst.ts +18 -18
- package/src/data-structures/binary-tree/rb-tree.ts +436 -405
- package/src/data-structures/binary-tree/tree-multi-map.ts +85 -82
- package/src/types/common.ts +7 -0
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @author Tyler Zeng
|
|
5
|
-
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
-
* @license MIT License
|
|
7
|
-
*/
|
|
8
|
-
import { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
|
|
1
|
+
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
|
|
2
|
+
import { CRUD, RBTNColor } from '../../types';
|
|
9
3
|
import { BST, BSTNode } from './bst';
|
|
10
4
|
import { IBinaryTree } from '../../interfaces';
|
|
11
5
|
export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
|
|
@@ -24,7 +18,7 @@ export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTre
|
|
|
24
18
|
protected _color: RBTNColor;
|
|
25
19
|
/**
|
|
26
20
|
* The function returns the color value of a variable.
|
|
27
|
-
* @returns The color value stored in the
|
|
21
|
+
* @returns The color value stored in the private variable `_color`.
|
|
28
22
|
*/
|
|
29
23
|
get color(): RBTNColor;
|
|
30
24
|
/**
|
|
@@ -33,82 +27,88 @@ export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTre
|
|
|
33
27
|
*/
|
|
34
28
|
set color(value: RBTNColor);
|
|
35
29
|
}
|
|
36
|
-
/**
|
|
37
|
-
* 1. Each node is either red or black.
|
|
38
|
-
* 2. The root node is always black.
|
|
39
|
-
* 3. Leaf nodes are typically Sentinel nodes and are considered black.
|
|
40
|
-
* 4. Red nodes must have black children.
|
|
41
|
-
* 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
|
|
42
|
-
*/
|
|
43
30
|
export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, NODE, TREE> = RedBlackTree<K, V, NODE, RedBlackTreeNested<K, V, NODE>>> extends BST<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
|
|
44
31
|
/**
|
|
45
|
-
* This is the constructor function for a Red-Black Tree data structure in TypeScript
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* only a subset of the properties defined in the `RBTreeOptions` interface.
|
|
32
|
+
* This is the constructor function for a Red-Black Tree data structure in TypeScript.
|
|
33
|
+
* @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
|
|
34
|
+
* contain keys, nodes, or entries. It is used to initialize the RBTree with the provided keys,
|
|
35
|
+
* nodes, or entries.
|
|
36
|
+
* @param [options] - The `options` parameter is an optional object that can be passed to the
|
|
37
|
+
* constructor. It allows you to customize the behavior of the RBTree. It can include properties such
|
|
38
|
+
* as `compareKeys`, `compareValues`, `allowDuplicates`, etc. These properties define how the RBTree
|
|
39
|
+
* should compare keys and
|
|
54
40
|
*/
|
|
55
41
|
constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: RBTreeOptions<K>);
|
|
56
|
-
protected
|
|
42
|
+
protected _SENTINEL: NODE;
|
|
57
43
|
/**
|
|
58
|
-
* The function returns the value of the
|
|
59
|
-
* @returns The method is returning the value of the `
|
|
44
|
+
* The function returns the value of the _SENTINEL property.
|
|
45
|
+
* @returns The method is returning the value of the `_SENTINEL` property.
|
|
60
46
|
*/
|
|
61
|
-
get
|
|
62
|
-
protected _root: NODE;
|
|
47
|
+
get SENTINEL(): NODE;
|
|
48
|
+
protected _root: NODE | undefined;
|
|
63
49
|
/**
|
|
64
|
-
* The function returns the root node.
|
|
65
|
-
* @returns The root node of the
|
|
50
|
+
* The function returns the root node of a tree or undefined if there is no root.
|
|
51
|
+
* @returns The root node of the tree structure, or undefined if there is no root node.
|
|
66
52
|
*/
|
|
67
|
-
get root(): NODE;
|
|
68
|
-
protected _size: number;
|
|
69
|
-
/**
|
|
70
|
-
* The function returns the size of an object.
|
|
71
|
-
* @returns The size of the object, which is a number.
|
|
72
|
-
*/
|
|
73
|
-
get size(): number;
|
|
53
|
+
get root(): NODE | undefined;
|
|
74
54
|
/**
|
|
75
55
|
* The function creates a new Red-Black Tree node with the specified key, value, and color.
|
|
76
|
-
* @param {K} key - The key parameter
|
|
77
|
-
*
|
|
56
|
+
* @param {K} key - The key parameter represents the key of the node being created. It is of type K,
|
|
57
|
+
* which is a generic type representing the key's data type.
|
|
78
58
|
* @param {V} [value] - The `value` parameter is an optional parameter that represents the value
|
|
79
|
-
* associated with the node. It is
|
|
80
|
-
* specific type when using the `createNode` method.
|
|
59
|
+
* associated with the key in the node. It is not required and can be omitted if not needed.
|
|
81
60
|
* @param {RBTNColor} color - The "color" parameter is used to specify the color of the node in a
|
|
82
|
-
* Red-Black Tree. It
|
|
61
|
+
* Red-Black Tree. It is an optional parameter with a default value of "RBTNColor.BLACK". The color
|
|
62
|
+
* can be either "RBTNColor.RED" or "RBTNColor.BLACK".
|
|
83
63
|
* @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
|
|
84
64
|
* value, and color.
|
|
85
65
|
*/
|
|
86
66
|
createNode(key: K, value?: V, color?: RBTNColor): NODE;
|
|
87
67
|
/**
|
|
88
|
-
* The function creates a Red-Black Tree with the
|
|
89
|
-
* @param
|
|
90
|
-
*
|
|
91
|
-
*
|
|
68
|
+
* The function creates a Red-Black Tree with the given options and returns it.
|
|
69
|
+
* @param [options] - The `options` parameter is an optional object that contains configuration
|
|
70
|
+
* options for creating the Red-Black Tree. It is of type `RBTreeOptions<K>`, where `K` represents
|
|
71
|
+
* the type of keys in the tree.
|
|
92
72
|
* @returns a new instance of a RedBlackTree object.
|
|
93
73
|
*/
|
|
94
74
|
createTree(options?: RBTreeOptions<K>): TREE;
|
|
95
75
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
*
|
|
76
|
+
* Time Complexity: O(1)
|
|
77
|
+
* Space Complexity: O(1)
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Time Complexity: O(1)
|
|
81
|
+
* Space Complexity: O(1)
|
|
82
|
+
*
|
|
83
|
+
* The function `keyValueOrEntryToNode` takes a key, value, or entry and returns a node if it is
|
|
84
|
+
* valid, otherwise it returns undefined.
|
|
85
|
+
* @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The key, value, or entry to convert.
|
|
86
|
+
* @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntry` is a key).
|
|
87
|
+
* @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
|
|
102
88
|
*/
|
|
103
89
|
keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined;
|
|
104
90
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
|
|
91
|
+
* Time Complexity: O(1)
|
|
92
|
+
* Space Complexity: O(1)
|
|
93
|
+
* /
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Time Complexity: O(1)
|
|
97
|
+
* Space Complexity: O(1)
|
|
98
|
+
*
|
|
99
|
+
* The function checks if the input is an instance of the RedBlackTreeNode class.
|
|
100
|
+
* @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntry - The object to check.
|
|
101
|
+
* @returns {boolean} - `true` if the object is a Red-Black Tree node, `false` otherwise.
|
|
109
102
|
*/
|
|
110
103
|
isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
|
|
111
104
|
/**
|
|
105
|
+
* Time Complexity: O(1)
|
|
106
|
+
* Space Complexity: O(1)
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* Time Complexity: O(1)
|
|
110
|
+
* Space Complexity: O(1)
|
|
111
|
+
*
|
|
112
112
|
* The function checks if a given node is a real node in a Red-Black Tree.
|
|
113
113
|
* @param {NODE | undefined} node - The `node` parameter is of type `NODE | undefined`, which means
|
|
114
114
|
* it can either be of type `NODE` or `undefined`.
|
|
@@ -118,21 +118,41 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
118
118
|
/**
|
|
119
119
|
* Time Complexity: O(log n)
|
|
120
120
|
* Space Complexity: O(1)
|
|
121
|
-
* On average (where n is the number of nodes in the tree)
|
|
122
121
|
*/
|
|
123
122
|
/**
|
|
124
123
|
* Time Complexity: O(log n)
|
|
125
124
|
* Space Complexity: O(1)
|
|
126
125
|
*
|
|
127
|
-
* The `
|
|
128
|
-
*
|
|
129
|
-
* @param
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
126
|
+
* The `getNode` function retrieves a node from a Red-Black Tree based on the provided identifier and
|
|
127
|
+
* callback function.
|
|
128
|
+
* @param {ReturnType<C> | undefined} identifier - The `identifier` parameter is the value or key
|
|
129
|
+
* that you want to search for in the binary search tree. It can be of any type that is compatible
|
|
130
|
+
* with the type of nodes in the tree.
|
|
131
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
132
|
+
* the tree. It is used to determine whether a node matches the given identifier. The `callback`
|
|
133
|
+
* function should take a node as its parameter and return a value that can be compared to the
|
|
134
|
+
* `identifier` parameter.
|
|
135
|
+
* @param beginRoot - The `beginRoot` parameter is the starting point for the search in the binary
|
|
136
|
+
* search tree. It can be either a key or a node. If it is a key, it will be converted to a node
|
|
137
|
+
* using the `ensureNode` method. If it is not provided, the `root`
|
|
138
|
+
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
|
|
139
|
+
* be performed when searching for nodes in the binary search tree. It is an optional parameter and
|
|
140
|
+
* its default value is taken from the `iterationType` property of the class.
|
|
141
|
+
* @returns The method is returning a value of type `NODE | null | undefined`.
|
|
142
|
+
*/
|
|
143
|
+
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: BSTNKeyOrNode<K, NODE>, iterationType?: import("../../types").IterationType): NODE | null | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Time Complexity: O(1)
|
|
146
|
+
* Space Complexity: O(1)
|
|
134
147
|
*/
|
|
135
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Time Complexity: O(1)
|
|
150
|
+
* Space Complexity: O(1)
|
|
151
|
+
*
|
|
152
|
+
* The "clear" function sets the root node of a data structure to a sentinel value and resets the
|
|
153
|
+
* size counter to zero.
|
|
154
|
+
*/
|
|
155
|
+
clear(): void;
|
|
136
156
|
/**
|
|
137
157
|
* Time Complexity: O(log n)
|
|
138
158
|
* Space Complexity: O(1)
|
|
@@ -141,18 +161,16 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
141
161
|
* Time Complexity: O(log n)
|
|
142
162
|
* Space Complexity: O(1)
|
|
143
163
|
*
|
|
144
|
-
* The
|
|
145
|
-
* the
|
|
146
|
-
* @param
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @
|
|
151
|
-
*
|
|
152
|
-
* on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
|
|
153
|
-
* @returns an array of `BinaryTreeDeleteResult<NODE>`.
|
|
164
|
+
* The function adds a new node to a Red-Black Tree data structure and returns a boolean indicating
|
|
165
|
+
* whether the operation was successful.
|
|
166
|
+
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
|
|
167
|
+
* entry.
|
|
168
|
+
* @param {V} [value] - The `value` parameter is the value associated with the key that is being
|
|
169
|
+
* added to the tree.
|
|
170
|
+
* @returns The method is returning a boolean value. It returns true if the node was successfully
|
|
171
|
+
* added or updated, and false otherwise.
|
|
154
172
|
*/
|
|
155
|
-
|
|
173
|
+
add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
|
|
156
174
|
/**
|
|
157
175
|
* Time Complexity: O(log n)
|
|
158
176
|
* Space Complexity: O(1)
|
|
@@ -161,24 +179,25 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
161
179
|
* Time Complexity: O(log n)
|
|
162
180
|
* Space Complexity: O(1)
|
|
163
181
|
*
|
|
164
|
-
* The function `
|
|
165
|
-
*
|
|
166
|
-
* @param {ReturnType<C> | undefined} identifier - The `identifier` parameter is the
|
|
167
|
-
*
|
|
168
|
-
* callback function
|
|
169
|
-
*
|
|
170
|
-
* @param {C} callback - The `callback` parameter is a function that
|
|
171
|
-
* the binary tree. It is
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* provided, the search will start from the root of the binary tree.
|
|
176
|
-
* @param iterationType - The `iterationType` parameter is a variable that determines the type of
|
|
177
|
-
* iteration to be performed when searching for nodes in the binary tree. It is used in the
|
|
178
|
-
* `getNodes` method, which is called within the `getNode` method.
|
|
179
|
-
* @returns a value of type `NODE`, `null`, or `undefined`.
|
|
182
|
+
* The function `delete` in a binary tree class deletes a node from the tree and fixes the tree if
|
|
183
|
+
* necessary.
|
|
184
|
+
* @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the
|
|
185
|
+
* identifier of the node that needs to be deleted from the binary tree. It can be of any type that
|
|
186
|
+
* is returned by the callback function `C`. It can also be `null` or `undefined` if the node to be
|
|
187
|
+
* deleted is not found.
|
|
188
|
+
* @param {C} callback - The `callback` parameter is a function that is used to retrieve a node from
|
|
189
|
+
* the binary tree based on its identifier. It is an optional parameter and if not provided, the
|
|
190
|
+
* `_defaultOneParamCallback` function is used as the default callback. The callback function should
|
|
191
|
+
* return the identifier of the node to
|
|
192
|
+
* @returns an array of BinaryTreeDeleteResult<NODE> objects.
|
|
180
193
|
*/
|
|
181
|
-
|
|
194
|
+
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C): BinaryTreeDeleteResult<NODE>[];
|
|
195
|
+
/**
|
|
196
|
+
* The function sets the root of a tree-like structure and updates the parent property of the new
|
|
197
|
+
* root.
|
|
198
|
+
* @param {NODE | undefined} v - v is a parameter of type NODE or undefined.
|
|
199
|
+
*/
|
|
200
|
+
protected _setRoot(v: NODE | undefined): void;
|
|
182
201
|
/**
|
|
183
202
|
* Time Complexity: O(1)
|
|
184
203
|
* Space Complexity: O(1)
|
|
@@ -187,9 +206,15 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
187
206
|
* Time Complexity: O(1)
|
|
188
207
|
* Space Complexity: O(1)
|
|
189
208
|
*
|
|
190
|
-
* The
|
|
209
|
+
* The function replaces an old node with a new node while preserving the color of the old node.
|
|
210
|
+
* @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
|
|
211
|
+
* the data structure.
|
|
212
|
+
* @param {NODE} newNode - The `newNode` parameter is the new node that will replace the old node in
|
|
213
|
+
* the data structure.
|
|
214
|
+
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
215
|
+
* superclass, with the `oldNode` and `newNode` parameters.
|
|
191
216
|
*/
|
|
192
|
-
|
|
217
|
+
protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
|
|
193
218
|
/**
|
|
194
219
|
* Time Complexity: O(log n)
|
|
195
220
|
* Space Complexity: O(1)
|
|
@@ -198,19 +223,14 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
198
223
|
* Time Complexity: O(log n)
|
|
199
224
|
* Space Complexity: O(1)
|
|
200
225
|
*
|
|
201
|
-
* The function
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* The function sets the root node of a tree structure and updates the parent property of the new
|
|
209
|
-
* root node.
|
|
210
|
-
* @param {NODE} v - The parameter "v" is of type "NODE", which represents a node in a data
|
|
211
|
-
* structure.
|
|
226
|
+
* The `_insert` function inserts or updates a node in a binary search tree and performs necessary
|
|
227
|
+
* fix-ups to maintain the red-black tree properties.
|
|
228
|
+
* @param {NODE} node - The `node` parameter represents the node that needs to be inserted into a
|
|
229
|
+
* binary search tree. It contains a `key` property that is used to determine the position of the
|
|
230
|
+
* node in the tree.
|
|
231
|
+
* @returns {'inserted' | 'updated'} - The result of the insertion.
|
|
212
232
|
*/
|
|
213
|
-
protected
|
|
233
|
+
protected _insert(node: NODE): CRUD;
|
|
214
234
|
/**
|
|
215
235
|
* Time Complexity: O(1)
|
|
216
236
|
* Space Complexity: O(1)
|
|
@@ -219,23 +239,25 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
219
239
|
* Time Complexity: O(1)
|
|
220
240
|
* Space Complexity: O(1)
|
|
221
241
|
*
|
|
222
|
-
* The function
|
|
223
|
-
* @param {
|
|
242
|
+
* The function `_transplant` is used to replace a node `u` with another node `v` in a binary tree.
|
|
243
|
+
* @param {NODE} u - The parameter "u" represents a node in a binary tree.
|
|
244
|
+
* @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`, which means it can
|
|
245
|
+
* either be a `NODE` object or `undefined`.
|
|
224
246
|
*/
|
|
225
|
-
protected
|
|
247
|
+
protected _transplant(u: NODE, v: NODE | undefined): void;
|
|
226
248
|
/**
|
|
227
|
-
* Time Complexity: O(
|
|
249
|
+
* Time Complexity: O(log n)
|
|
228
250
|
* Space Complexity: O(1)
|
|
229
251
|
*/
|
|
230
252
|
/**
|
|
231
|
-
* Time Complexity: O(
|
|
253
|
+
* Time Complexity: O(log n)
|
|
232
254
|
* Space Complexity: O(1)
|
|
233
255
|
*
|
|
234
|
-
* The function
|
|
235
|
-
* @param {
|
|
236
|
-
*
|
|
256
|
+
* The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
|
|
257
|
+
* @param {NODE | undefined} z - The parameter `z` represents a node in the Red-Black Tree. It can
|
|
258
|
+
* either be a valid node object or `undefined`.
|
|
237
259
|
*/
|
|
238
|
-
protected
|
|
260
|
+
protected _insertFixup(z: NODE | undefined): void;
|
|
239
261
|
/**
|
|
240
262
|
* Time Complexity: O(log n)
|
|
241
263
|
* Space Complexity: O(1)
|
|
@@ -244,23 +266,27 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
244
266
|
* Time Complexity: O(log n)
|
|
245
267
|
* Space Complexity: O(1)
|
|
246
268
|
*
|
|
247
|
-
* The `
|
|
248
|
-
*
|
|
249
|
-
*
|
|
269
|
+
* The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
|
|
270
|
+
* the colors and performing rotations.
|
|
271
|
+
* @param {NODE | undefined} node - The `node` parameter represents a node in a Red-Black Tree data
|
|
272
|
+
* structure. It can be either a valid node object or `undefined`.
|
|
273
|
+
* @returns The function does not return any value. It has a return type of `void`.
|
|
250
274
|
*/
|
|
251
|
-
protected
|
|
275
|
+
protected _deleteFixup(node: NODE | undefined): void;
|
|
252
276
|
/**
|
|
253
|
-
* Time Complexity: O(
|
|
277
|
+
* Time Complexity: O(1)
|
|
254
278
|
* Space Complexity: O(1)
|
|
255
279
|
*/
|
|
256
280
|
/**
|
|
257
|
-
* Time Complexity: O(
|
|
281
|
+
* Time Complexity: O(1)
|
|
258
282
|
* Space Complexity: O(1)
|
|
259
283
|
*
|
|
260
|
-
* The
|
|
261
|
-
* @param {
|
|
284
|
+
* The `_leftRotate` function performs a left rotation on a given node in a binary tree.
|
|
285
|
+
* @param {NODE | undefined} x - The parameter `x` is of type `NODE | undefined`. It represents a
|
|
286
|
+
* node in a binary tree or `undefined` if there is no node.
|
|
287
|
+
* @returns void, which means it does not return any value.
|
|
262
288
|
*/
|
|
263
|
-
protected
|
|
289
|
+
protected _leftRotate(x: NODE | undefined): void;
|
|
264
290
|
/**
|
|
265
291
|
* Time Complexity: O(1)
|
|
266
292
|
* Space Complexity: O(1)
|
|
@@ -269,19 +295,10 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
|
|
|
269
295
|
* Time Complexity: O(1)
|
|
270
296
|
* Space Complexity: O(1)
|
|
271
297
|
*
|
|
272
|
-
* The
|
|
273
|
-
* @param {
|
|
274
|
-
*
|
|
275
|
-
|
|
276
|
-
protected _rbTransplant(u: NODE, v: NODE): void;
|
|
277
|
-
/**
|
|
278
|
-
* The function replaces an old node with a new node while preserving the color of the old node.
|
|
279
|
-
* @param {NODE} oldNode - The `oldNode` parameter represents the node that needs to be replaced in a
|
|
280
|
-
* data structure. It is of type `NODE`, which is the type of the nodes in the data structure.
|
|
281
|
-
* @param {NODE} newNode - The `newNode` parameter is the node that will replace the `oldNode` in the
|
|
282
|
-
* data structure.
|
|
283
|
-
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
284
|
-
* superclass, passing in the `oldNode` and `newNode` as arguments.
|
|
298
|
+
* The `_rightRotate` function performs a right rotation on a given node in a binary tree.
|
|
299
|
+
* @param {NODE | undefined} y - The parameter `y` is of type `NODE | undefined`. It represents a
|
|
300
|
+
* node in a binary tree or `undefined` if there is no node.
|
|
301
|
+
* @returns void, which means it does not return any value.
|
|
285
302
|
*/
|
|
286
|
-
protected
|
|
303
|
+
protected _rightRotate(y: NODE | undefined): void;
|
|
287
304
|
}
|