min-heap-typed 1.50.1 → 1.50.3
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/base/iterable-base.d.ts +120 -9
- package/dist/data-structures/base/iterable-base.js +143 -7
- package/dist/data-structures/binary-tree/avl-tree.d.ts +72 -47
- package/dist/data-structures/binary-tree/avl-tree.js +101 -72
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
- package/dist/data-structures/binary-tree/binary-tree.js +484 -376
- package/dist/data-structures/binary-tree/bst.d.ts +92 -79
- package/dist/data-structures/binary-tree/bst.js +68 -76
- package/dist/data-structures/binary-tree/rb-tree.d.ts +127 -57
- package/dist/data-structures/binary-tree/rb-tree.js +152 -99
- package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
- package/dist/data-structures/binary-tree/segment-tree.js +127 -10
- package/dist/data-structures/binary-tree/tree-multimap.d.ts +72 -58
- package/dist/data-structures/binary-tree/tree-multimap.js +102 -85
- package/dist/data-structures/graph/abstract-graph.d.ts +1 -78
- package/dist/data-structures/graph/abstract-graph.js +3 -189
- package/dist/data-structures/graph/directed-graph.d.ts +73 -0
- package/dist/data-structures/graph/directed-graph.js +131 -0
- package/dist/data-structures/graph/map-graph.d.ts +8 -0
- package/dist/data-structures/graph/map-graph.js +14 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +76 -7
- package/dist/data-structures/graph/undirected-graph.js +151 -18
- package/dist/data-structures/hash/hash-map.d.ts +254 -28
- package/dist/data-structures/hash/hash-map.js +347 -78
- package/dist/data-structures/heap/heap.d.ts +95 -25
- package/dist/data-structures/heap/heap.js +95 -26
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
- package/dist/data-structures/linked-list/doubly-linked-list.js +141 -77
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +154 -106
- package/dist/data-structures/linked-list/singly-linked-list.js +164 -115
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
- package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
- package/dist/data-structures/matrix/matrix.d.ts +35 -4
- package/dist/data-structures/matrix/matrix.js +50 -11
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
- package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
- package/dist/data-structures/priority-queue/priority-queue.js +8 -0
- package/dist/data-structures/queue/deque.d.ts +139 -35
- package/dist/data-structures/queue/deque.js +200 -62
- package/dist/data-structures/queue/queue.d.ts +103 -49
- package/dist/data-structures/queue/queue.js +111 -49
- package/dist/data-structures/stack/stack.d.ts +51 -21
- package/dist/data-structures/stack/stack.js +58 -22
- package/dist/data-structures/tree/tree.d.ts +57 -3
- package/dist/data-structures/tree/tree.js +77 -11
- package/dist/data-structures/trie/trie.d.ts +135 -34
- package/dist/data-structures/trie/trie.js +153 -33
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +2 -2
- package/src/data-structures/base/iterable-base.ts +184 -19
- package/src/data-structures/binary-tree/avl-tree.ts +134 -100
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
- package/src/data-structures/binary-tree/binary-tree.ts +674 -671
- package/src/data-structures/binary-tree/bst.ts +127 -136
- package/src/data-structures/binary-tree/rb-tree.ts +199 -166
- package/src/data-structures/binary-tree/segment-tree.ts +145 -11
- package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
- package/src/data-structures/graph/abstract-graph.ts +4 -211
- package/src/data-structures/graph/directed-graph.ts +152 -0
- package/src/data-structures/graph/map-graph.ts +15 -0
- package/src/data-structures/graph/undirected-graph.ts +171 -19
- package/src/data-structures/hash/hash-map.ts +389 -96
- package/src/data-structures/heap/heap.ts +97 -26
- package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
- package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
- package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
- package/src/data-structures/matrix/matrix.ts +52 -12
- package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
- package/src/data-structures/priority-queue/priority-queue.ts +8 -0
- package/src/data-structures/queue/deque.ts +225 -70
- package/src/data-structures/queue/queue.ts +118 -49
- package/src/data-structures/stack/stack.ts +63 -23
- package/src/data-structures/tree/tree.ts +89 -15
- package/src/data-structures/trie/trie.ts +173 -38
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/hash/hash-map.ts +4 -3
- package/src/types/utils/utils.ts +2 -0
|
@@ -5,12 +5,33 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import { BinaryTreeDeleteResult,
|
|
8
|
+
import { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
|
|
9
9
|
import { BST, BSTNode } from './bst';
|
|
10
10
|
import { IBinaryTree } from '../../interfaces';
|
|
11
|
-
export declare class RedBlackTreeNode<K = any, V = any,
|
|
12
|
-
|
|
11
|
+
export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
|
|
12
|
+
/**
|
|
13
|
+
* The constructor function initializes a Red-Black Tree Node with a key, an optional value, and a
|
|
14
|
+
* color.
|
|
15
|
+
* @param {K} key - The key parameter is of type K and represents the key of the node in the
|
|
16
|
+
* Red-Black Tree.
|
|
17
|
+
* @param {V} [value] - The `value` parameter is an optional parameter that represents the value
|
|
18
|
+
* associated with the key in the Red-Black Tree Node. It is not required and can be omitted when
|
|
19
|
+
* creating a new instance of the Red-Black Tree Node.
|
|
20
|
+
* @param {RBTNColor} color - The `color` parameter is used to specify the color of the Red-Black
|
|
21
|
+
* Tree Node. It is an optional parameter with a default value of `RBTNColor.BLACK`.
|
|
22
|
+
*/
|
|
13
23
|
constructor(key: K, value?: V, color?: RBTNColor);
|
|
24
|
+
protected _color: RBTNColor;
|
|
25
|
+
/**
|
|
26
|
+
* The function returns the color value of a variable.
|
|
27
|
+
* @returns The color value stored in the protected variable `_color`.
|
|
28
|
+
*/
|
|
29
|
+
get color(): RBTNColor;
|
|
30
|
+
/**
|
|
31
|
+
* The function sets the color property to the specified value.
|
|
32
|
+
* @param {RBTNColor} value - The value parameter is of type RBTNColor.
|
|
33
|
+
*/
|
|
34
|
+
set color(value: RBTNColor);
|
|
14
35
|
}
|
|
15
36
|
/**
|
|
16
37
|
* 1. Each node is either red or black.
|
|
@@ -19,12 +40,11 @@ export declare class RedBlackTreeNode<K = any, V = any, N extends RedBlackTreeNo
|
|
|
19
40
|
* 4. Red nodes must have black children.
|
|
20
41
|
* 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
|
|
21
42
|
*/
|
|
22
|
-
export declare class RedBlackTree<K = any, V = any,
|
|
23
|
-
Sentinel: N;
|
|
43
|
+
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> {
|
|
24
44
|
/**
|
|
25
45
|
* This is the constructor function for a Red-Black Tree data structure in TypeScript, which
|
|
26
46
|
* initializes the tree with optional nodes and options.
|
|
27
|
-
* @param [keysOrNodesOrEntries] - The `keysOrNodesOrEntries` parameter is an optional iterable of `KeyOrNodeOrEntry<K, V,
|
|
47
|
+
* @param [keysOrNodesOrEntries] - The `keysOrNodesOrEntries` parameter is an optional iterable of `KeyOrNodeOrEntry<K, V, NODE>`
|
|
28
48
|
* objects. It represents the initial nodes that will be added to the RBTree during its
|
|
29
49
|
* construction. If this parameter is provided, the `addMany` method is called to add all the
|
|
30
50
|
* nodes to the
|
|
@@ -32,10 +52,24 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
32
52
|
* behavior of the RBTree. It is of type `Partial<RBTreeOptions>`, which means that you can provide
|
|
33
53
|
* only a subset of the properties defined in the `RBTreeOptions` interface.
|
|
34
54
|
*/
|
|
35
|
-
constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V,
|
|
36
|
-
protected
|
|
37
|
-
|
|
55
|
+
constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: RBTreeOptions<K>);
|
|
56
|
+
protected _Sentinel: NODE;
|
|
57
|
+
/**
|
|
58
|
+
* The function returns the value of the `_Sentinel` property.
|
|
59
|
+
* @returns The method is returning the value of the `_Sentinel` property.
|
|
60
|
+
*/
|
|
61
|
+
get Sentinel(): NODE;
|
|
62
|
+
protected _root: NODE;
|
|
63
|
+
/**
|
|
64
|
+
* The function returns the root node.
|
|
65
|
+
* @returns The root node of the data structure.
|
|
66
|
+
*/
|
|
67
|
+
get root(): NODE;
|
|
38
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
|
+
*/
|
|
39
73
|
get size(): number;
|
|
40
74
|
/**
|
|
41
75
|
* The function creates a new Red-Black Tree node with the specified key, value, and color.
|
|
@@ -49,7 +83,7 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
49
83
|
* @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
|
|
50
84
|
* value, and color.
|
|
51
85
|
*/
|
|
52
|
-
createNode(key: K, value?: V, color?: RBTNColor):
|
|
86
|
+
createNode(key: K, value?: V, color?: RBTNColor): NODE;
|
|
53
87
|
/**
|
|
54
88
|
* The function creates a Red-Black Tree with the specified options and returns it.
|
|
55
89
|
* @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
|
|
@@ -59,30 +93,32 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
59
93
|
*/
|
|
60
94
|
createTree(options?: RBTreeOptions<K>): TREE;
|
|
61
95
|
/**
|
|
62
|
-
* The function `
|
|
63
|
-
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V,
|
|
96
|
+
* The function `keyValueOrEntryToNode` takes an keyOrNodeOrEntry and converts it into a node object if possible.
|
|
97
|
+
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`, where:
|
|
64
98
|
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
65
|
-
* `
|
|
99
|
+
* `keyValueOrEntryToNode` function. It represents the value associated with the keyOrNodeOrEntry node. If a value
|
|
66
100
|
* is provided, it will be used when creating the new node. If no value is provided, the new node
|
|
67
|
-
* @returns a node of type
|
|
101
|
+
* @returns a node of type NODE or undefined.
|
|
68
102
|
*/
|
|
69
|
-
|
|
103
|
+
keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined;
|
|
70
104
|
/**
|
|
71
105
|
* The function checks if an keyOrNodeOrEntry is an instance of the RedBlackTreeNode class.
|
|
72
|
-
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V,
|
|
106
|
+
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`.
|
|
73
107
|
* @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the RedBlackTreeNode
|
|
74
108
|
* class.
|
|
75
109
|
*/
|
|
76
|
-
isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V,
|
|
110
|
+
isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
|
|
77
111
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
112
|
+
* The function checks if a given node is a real node in a Red-Black Tree.
|
|
113
|
+
* @param {NODE | undefined} node - The `node` parameter is of type `NODE | undefined`, which means
|
|
114
|
+
* it can either be of type `NODE` or `undefined`.
|
|
115
|
+
* @returns a boolean value.
|
|
80
116
|
*/
|
|
81
|
-
isRealNode(node:
|
|
117
|
+
isRealNode(node: NODE | undefined): node is NODE;
|
|
82
118
|
/**
|
|
83
119
|
* Time Complexity: O(log n)
|
|
84
120
|
* Space Complexity: O(1)
|
|
85
|
-
*
|
|
121
|
+
* On average (where n is the number of nodes in the tree)
|
|
86
122
|
*/
|
|
87
123
|
/**
|
|
88
124
|
* Time Complexity: O(log n)
|
|
@@ -94,13 +130,12 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
94
130
|
* entry.
|
|
95
131
|
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
|
|
96
132
|
* being added to the binary search tree.
|
|
97
|
-
* @returns The method `add` returns either the newly added node (`
|
|
133
|
+
* @returns The method `add` returns either the newly added node (`NODE`) or `undefined`.
|
|
98
134
|
*/
|
|
99
|
-
add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V,
|
|
135
|
+
add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
|
|
100
136
|
/**
|
|
101
137
|
* Time Complexity: O(log n)
|
|
102
138
|
* Space Complexity: O(1)
|
|
103
|
-
* on average (where n is the number of nodes in the tree)
|
|
104
139
|
*/
|
|
105
140
|
/**
|
|
106
141
|
* Time Complexity: O(log n)
|
|
@@ -112,15 +147,49 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
112
147
|
* that you want to use to identify the node that you want to delete from the binary tree. It can be
|
|
113
148
|
* of any type that is returned by the callback function `C`. It can also be `null` or `undefined` if
|
|
114
149
|
* you don't want to
|
|
115
|
-
* @param {C} callback - The `callback` parameter is a function that takes a node of type `
|
|
150
|
+
* @param {C} callback - The `callback` parameter is a function that takes a node of type `NODE` and
|
|
116
151
|
* returns a value of type `ReturnType<C>`. It is used to determine if a node should be deleted based
|
|
117
152
|
* on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
|
|
118
|
-
* @returns an array of `BinaryTreeDeleteResult<
|
|
153
|
+
* @returns an array of `BinaryTreeDeleteResult<NODE>`.
|
|
119
154
|
*/
|
|
120
|
-
delete<C extends BTNCallback<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
155
|
+
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C): BinaryTreeDeleteResult<NODE>[];
|
|
156
|
+
/**
|
|
157
|
+
* Time Complexity: O(log n)
|
|
158
|
+
* Space Complexity: O(1)
|
|
159
|
+
*/
|
|
160
|
+
/**
|
|
161
|
+
* Time Complexity: O(log n)
|
|
162
|
+
* Space Complexity: O(1)
|
|
163
|
+
*
|
|
164
|
+
* The function `getNode` retrieves a single node from a binary tree based on a given identifier and
|
|
165
|
+
* callback function.
|
|
166
|
+
* @param {ReturnType<C> | undefined} identifier - The `identifier` parameter is the value used to
|
|
167
|
+
* identify the node you want to retrieve. It can be of any type that is the return type of the `C`
|
|
168
|
+
* callback function. If the `identifier` is `undefined`, it means you want to retrieve the first
|
|
169
|
+
* node that matches the other criteria
|
|
170
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
171
|
+
* the binary tree. It is used to determine if a node matches the given identifier. The `callback`
|
|
172
|
+
* function should take a single parameter of type `NODE` (the type of the nodes in the binary tree) and
|
|
173
|
+
* @param {K | NODE | undefined} beginRoot - The `beginRoot` parameter is the starting point for
|
|
174
|
+
* searching for a node in a binary tree. It can be either a key value or a node object. If it is not
|
|
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`.
|
|
180
|
+
*/
|
|
181
|
+
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: BSTNKeyOrNode<K, NODE>, iterationType?: import("../../types").IterationType): NODE | null | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Time Complexity: O(1)
|
|
184
|
+
* Space Complexity: O(1)
|
|
185
|
+
*/
|
|
186
|
+
/**
|
|
187
|
+
* Time Complexity: O(1)
|
|
188
|
+
* Space Complexity: O(1)
|
|
189
|
+
*
|
|
190
|
+
* The "clear" function sets the root node to the sentinel node and resets the size to 0.
|
|
191
|
+
*/
|
|
192
|
+
clear(): void;
|
|
124
193
|
/**
|
|
125
194
|
* Time Complexity: O(log n)
|
|
126
195
|
* Space Complexity: O(1)
|
|
@@ -134,13 +203,14 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
134
203
|
* Red-Black Tree.
|
|
135
204
|
* @returns the predecessor of the given RedBlackTreeNode 'x'.
|
|
136
205
|
*/
|
|
137
|
-
getPredecessor(x:
|
|
206
|
+
getPredecessor(x: NODE): NODE;
|
|
138
207
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
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.
|
|
141
212
|
*/
|
|
142
|
-
|
|
143
|
-
protected _setRoot(v: N): void;
|
|
213
|
+
protected _setRoot(v: NODE): void;
|
|
144
214
|
/**
|
|
145
215
|
* Time Complexity: O(1)
|
|
146
216
|
* Space Complexity: O(1)
|
|
@@ -150,9 +220,9 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
150
220
|
* Space Complexity: O(1)
|
|
151
221
|
*
|
|
152
222
|
* The function performs a left rotation on a binary tree node.
|
|
153
|
-
* @param {RedBlackTreeNode} x - The parameter `x` is of type `
|
|
223
|
+
* @param {RedBlackTreeNode} x - The parameter `x` is of type `NODE`, which likely represents a node in a binary tree.
|
|
154
224
|
*/
|
|
155
|
-
protected _leftRotate(x:
|
|
225
|
+
protected _leftRotate(x: NODE): void;
|
|
156
226
|
/**
|
|
157
227
|
* Time Complexity: O(1)
|
|
158
228
|
* Space Complexity: O(1)
|
|
@@ -165,7 +235,7 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
165
235
|
* @param {RedBlackTreeNode} x - x is a RedBlackTreeNode, which represents the node that needs to be right
|
|
166
236
|
* rotated.
|
|
167
237
|
*/
|
|
168
|
-
protected _rightRotate(x:
|
|
238
|
+
protected _rightRotate(x: NODE): void;
|
|
169
239
|
/**
|
|
170
240
|
* Time Complexity: O(log n)
|
|
171
241
|
* Space Complexity: O(1)
|
|
@@ -174,44 +244,44 @@ export declare class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K
|
|
|
174
244
|
* Time Complexity: O(log n)
|
|
175
245
|
* Space Complexity: O(1)
|
|
176
246
|
*
|
|
177
|
-
* The
|
|
178
|
-
* @param {RedBlackTreeNode}
|
|
247
|
+
* The `_fixInsert` function is used to fix the red-black tree after an insertion operation.
|
|
248
|
+
* @param {RedBlackTreeNode} k - The parameter `k` is a RedBlackTreeNode object, which represents a node in a
|
|
249
|
+
* red-black tree.
|
|
179
250
|
*/
|
|
180
|
-
protected
|
|
251
|
+
protected _fixInsert(k: NODE): void;
|
|
181
252
|
/**
|
|
182
|
-
* Time Complexity: O(
|
|
253
|
+
* Time Complexity: O(log n)
|
|
183
254
|
* Space Complexity: O(1)
|
|
184
255
|
*/
|
|
185
256
|
/**
|
|
186
|
-
* Time Complexity: O(
|
|
257
|
+
* Time Complexity: O(log n)
|
|
187
258
|
* Space Complexity: O(1)
|
|
188
259
|
*
|
|
189
|
-
* The function `
|
|
190
|
-
* @param {RedBlackTreeNode}
|
|
191
|
-
* @param {RedBlackTreeNode} v - The parameter "v" is a RedBlackTreeNode object.
|
|
260
|
+
* The function `_fixDelete` is used to fix the red-black tree after a node deletion.
|
|
261
|
+
* @param {RedBlackTreeNode} x - The parameter `x` represents a node in a Red-Black Tree (RBT).
|
|
192
262
|
*/
|
|
193
|
-
protected
|
|
263
|
+
protected _fixDelete(x: NODE): void;
|
|
194
264
|
/**
|
|
195
|
-
* Time Complexity: O(
|
|
265
|
+
* Time Complexity: O(1)
|
|
196
266
|
* Space Complexity: O(1)
|
|
197
267
|
*/
|
|
198
268
|
/**
|
|
199
|
-
* Time Complexity: O(
|
|
269
|
+
* Time Complexity: O(1)
|
|
200
270
|
* Space Complexity: O(1)
|
|
201
271
|
*
|
|
202
|
-
* The `
|
|
203
|
-
* @param {RedBlackTreeNode}
|
|
204
|
-
*
|
|
272
|
+
* The function `_rbTransplant` replaces one node in a red-black tree with another node.
|
|
273
|
+
* @param {RedBlackTreeNode} u - The parameter "u" represents a RedBlackTreeNode object.
|
|
274
|
+
* @param {RedBlackTreeNode} v - The parameter "v" is a RedBlackTreeNode object.
|
|
205
275
|
*/
|
|
206
|
-
protected
|
|
276
|
+
protected _rbTransplant(u: NODE, v: NODE): void;
|
|
207
277
|
/**
|
|
208
278
|
* The function replaces an old node with a new node while preserving the color of the old node.
|
|
209
|
-
* @param {
|
|
210
|
-
* data structure. It is of type `
|
|
211
|
-
* @param {
|
|
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
|
|
212
282
|
* data structure.
|
|
213
283
|
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
214
284
|
* superclass, passing in the `oldNode` and `newNode` as arguments.
|
|
215
285
|
*/
|
|
216
|
-
protected _replaceNode(oldNode:
|
|
286
|
+
protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
|
|
217
287
|
}
|