binary-tree-typed 1.53.8 → 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.
- package/dist/data-structures/base/iterable-entry-base.js +4 -4
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
- package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -170
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -328
- package/dist/data-structures/binary-tree/avl-tree.d.ts +103 -69
- package/dist/data-structures/binary-tree/avl-tree.js +130 -70
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +268 -202
- package/dist/data-structures/binary-tree/binary-tree.js +311 -263
- package/dist/data-structures/binary-tree/bst.d.ts +145 -121
- package/dist/data-structures/binary-tree/bst.js +195 -145
- package/dist/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/data-structures/binary-tree/index.js +2 -0
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +100 -72
- package/dist/data-structures/binary-tree/red-black-tree.js +127 -107
- package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
- package/dist/data-structures/binary-tree/tree-counter.js +444 -0
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -170
- package/dist/data-structures/binary-tree/tree-multi-map.js +140 -362
- package/dist/data-structures/graph/abstract-graph.js +2 -2
- package/dist/data-structures/graph/directed-graph.d.ts +3 -0
- package/dist/data-structures/graph/directed-graph.js +3 -0
- package/dist/data-structures/graph/map-graph.d.ts +3 -0
- package/dist/data-structures/graph/map-graph.js +3 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
- package/dist/data-structures/graph/undirected-graph.js +3 -0
- package/dist/data-structures/hash/hash-map.d.ts +1 -1
- package/dist/data-structures/hash/hash-map.js +5 -5
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +10 -10
- package/dist/data-structures/linked-list/doubly-linked-list.js +12 -12
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +13 -10
- package/dist/data-structures/linked-list/singly-linked-list.js +19 -16
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
- package/dist/data-structures/matrix/matrix.d.ts +3 -0
- package/dist/data-structures/matrix/matrix.js +3 -0
- package/dist/data-structures/matrix/navigator.d.ts +3 -0
- package/dist/data-structures/matrix/navigator.js +3 -0
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
- package/dist/data-structures/trie/trie.d.ts +0 -4
- package/dist/data-structures/trie/trie.js +0 -4
- package/dist/interfaces/binary-tree.d.ts +8 -8
- package/dist/types/data-structures/base/base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
- package/dist/types/data-structures/binary-tree/bst.d.ts +4 -4
- package/dist/types/data-structures/binary-tree/index.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/index.js +2 -0
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +2 -5
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -5
- package/package.json +2 -2
- package/src/data-structures/base/iterable-entry-base.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +151 -370
- package/src/data-structures/binary-tree/avl-tree.ts +162 -105
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
- package/src/data-structures/binary-tree/binary-tree.ts +488 -416
- package/src/data-structures/binary-tree/bst.ts +270 -234
- package/src/data-structures/binary-tree/index.ts +2 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +170 -145
- package/src/data-structures/binary-tree/tree-counter.ts +504 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +159 -401
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +3 -0
- package/src/data-structures/graph/map-graph.ts +3 -0
- package/src/data-structures/graph/undirected-graph.ts +3 -0
- package/src/data-structures/hash/hash-map.ts +7 -7
- package/src/data-structures/linked-list/doubly-linked-list.ts +13 -13
- package/src/data-structures/linked-list/singly-linked-list.ts +20 -17
- package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
- package/src/data-structures/matrix/matrix.ts +3 -0
- package/src/data-structures/matrix/navigator.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
- package/src/data-structures/trie/trie.ts +0 -4
- package/src/interfaces/binary-tree.ts +10 -21
- package/src/types/data-structures/base/base.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
- package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
- package/src/types/data-structures/binary-tree/bst.ts +6 -6
- package/src/types/data-structures/binary-tree/index.ts +2 -0
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -7
- package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -7
|
@@ -22,3 +22,5 @@ __exportStar(require("./avl-tree"), exports);
|
|
|
22
22
|
__exportStar(require("./red-black-tree"), exports);
|
|
23
23
|
__exportStar(require("./avl-tree-multi-map"), exports);
|
|
24
24
|
__exportStar(require("./tree-multi-map"), exports);
|
|
25
|
+
__exportStar(require("./tree-counter"), exports);
|
|
26
|
+
__exportStar(require("./avl-tree-counter"), exports);
|
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
import type { BinaryTreeDeleteResult, BTNRep, CRUD,
|
|
1
|
+
import type { BinaryTreeDeleteResult, BTNRep, CRUD, EntryCallback, OptNodeOrNull, RBTNColor, RedBlackTreeOptions } from '../../types';
|
|
2
2
|
import { BST, BSTNode } from './bst';
|
|
3
3
|
import { IBinaryTree } from '../../interfaces';
|
|
4
|
-
export declare class RedBlackTreeNode<K = any, V = any
|
|
4
|
+
export declare class RedBlackTreeNode<K = any, V = any> extends BSTNode<K, V> {
|
|
5
5
|
/**
|
|
6
|
-
* The constructor
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Tree Node. It is an optional parameter with a default value of `'BLACK'`.
|
|
6
|
+
* The constructor initializes a node with a key, value, and color for a Red-Black Tree.
|
|
7
|
+
* @param {K} key - The `key` parameter is a key of type `K` that is used to identify the node in a
|
|
8
|
+
* Red-Black Tree data structure.
|
|
9
|
+
* @param {V} [value] - The `value` parameter in the constructor is an optional parameter of type
|
|
10
|
+
* `V`. It represents the value associated with the key in the data structure being constructed.
|
|
11
|
+
* @param {RBTNColor} [color=BLACK] - The `color` parameter in the constructor is used to specify the
|
|
12
|
+
* color of the node in a Red-Black Tree. It has a default value of 'BLACK' if not provided
|
|
13
|
+
* explicitly.
|
|
15
14
|
*/
|
|
16
15
|
constructor(key: K, value?: V, color?: RBTNColor);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
get
|
|
23
|
-
|
|
24
|
-
* The function sets the color property to the specified value.
|
|
25
|
-
* @param {RBTNColor} value - The value parameter is of type RBTNColor.
|
|
26
|
-
*/
|
|
27
|
-
set color(value: RBTNColor);
|
|
16
|
+
parent?: RedBlackTreeNode<K, V>;
|
|
17
|
+
_left?: OptNodeOrNull<RedBlackTreeNode<K, V>>;
|
|
18
|
+
get left(): OptNodeOrNull<RedBlackTreeNode<K, V>>;
|
|
19
|
+
set left(v: OptNodeOrNull<RedBlackTreeNode<K, V>>);
|
|
20
|
+
_right?: OptNodeOrNull<RedBlackTreeNode<K, V>>;
|
|
21
|
+
get right(): OptNodeOrNull<RedBlackTreeNode<K, V>>;
|
|
22
|
+
set right(v: OptNodeOrNull<RedBlackTreeNode<K, V>>);
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
25
|
* 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.
|
|
@@ -79,25 +74,25 @@ export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTre
|
|
|
79
74
|
* );
|
|
80
75
|
* console.log(stocksInRange); // ['GOOGL', 'MSFT', 'META']
|
|
81
76
|
*/
|
|
82
|
-
export declare class RedBlackTree<K = any, V = any, R = object,
|
|
83
|
-
/**
|
|
84
|
-
* This is the constructor function for a Red-Black Tree data structure in TypeScript.
|
|
85
|
-
* @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
|
|
86
|
-
* iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
|
|
87
|
-
* initialize the RBTree with the provided elements.
|
|
88
|
-
* @param [options] - The `options` parameter is an optional object that can be passed to the
|
|
89
|
-
* constructor. It is of type `RBTreeOptions<K, V, R>`. This object can contain various options for
|
|
90
|
-
* configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
|
|
91
|
-
* depend on the implementation
|
|
92
|
-
*/
|
|
93
|
-
constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: RBTreeOptions<K, V, R>);
|
|
94
|
-
protected _root: NODE | undefined;
|
|
77
|
+
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> {
|
|
95
78
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
79
|
+
* This TypeScript constructor initializes a Red-Black Tree with optional keys, nodes, entries, or
|
|
80
|
+
* raw data.
|
|
81
|
+
* @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
|
|
82
|
+
* iterable that can contain either `BTNRep<K, V, RedBlackTreeNode<K, V>>` objects or `R` objects. It
|
|
83
|
+
* is used to initialize the Red-Black Tree with keys, nodes, entries, or
|
|
84
|
+
* @param [options] - The `options` parameter in the constructor is of type `RedBlackTreeOptions<K,
|
|
85
|
+
* V, R>`. It is an optional parameter that allows you to specify additional options for the
|
|
86
|
+
* RedBlackTree class. These options could include configuration settings, behavior customization, or
|
|
87
|
+
* any other parameters that are specific to
|
|
98
88
|
*/
|
|
99
|
-
|
|
89
|
+
constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, RedBlackTreeNode<K, V>> | R>, options?: RedBlackTreeOptions<K, V, R>);
|
|
90
|
+
protected _root: RedBlackTreeNode<K, V> | undefined;
|
|
91
|
+
get root(): RedBlackTreeNode<K, V> | undefined;
|
|
100
92
|
/**
|
|
93
|
+
* Time Complexity: O(1)
|
|
94
|
+
* Space Complexity: O(1)
|
|
95
|
+
*
|
|
101
96
|
* The function creates a new Red-Black Tree node with the specified key, value, and color.
|
|
102
97
|
* @param {K} key - The key parameter represents the key value of the node being created. It is of
|
|
103
98
|
* type K, which is a generic type that can be replaced with any specific type when using the
|
|
@@ -111,25 +106,28 @@ export declare class RedBlackTree<K = any, V = any, R = object, NODE extends Red
|
|
|
111
106
|
* @returns A new instance of a RedBlackTreeNode with the specified key, value, and color is being
|
|
112
107
|
* returned.
|
|
113
108
|
*/
|
|
114
|
-
createNode(key: K, value?: V, color?: RBTNColor):
|
|
109
|
+
createNode(key: K, value?: V, color?: RBTNColor): RedBlackTreeNode<K, V>;
|
|
115
110
|
/**
|
|
111
|
+
* Time Complexity: O(1)
|
|
112
|
+
* Space Complexity: O(1)
|
|
113
|
+
*
|
|
116
114
|
* The function creates a new Red-Black Tree with the specified options.
|
|
117
115
|
* @param [options] - The `options` parameter is an optional object that contains additional
|
|
118
116
|
* configuration options for creating the Red-Black Tree. It has the following properties:
|
|
119
117
|
* @returns a new instance of a RedBlackTree object.
|
|
120
118
|
*/
|
|
121
|
-
createTree(options?:
|
|
119
|
+
createTree(options?: RedBlackTreeOptions<K, V, R>): RedBlackTree<K, V, R, MK, MV, MR>;
|
|
122
120
|
/**
|
|
123
121
|
* Time Complexity: O(1)
|
|
124
122
|
* Space Complexity: O(1)
|
|
125
123
|
*
|
|
126
124
|
* The function checks if the input is an instance of the RedBlackTreeNode class.
|
|
127
|
-
* @param {BTNRep<K, V,
|
|
128
|
-
* `
|
|
129
|
-
* @returns a boolean value indicating whether the input parameter `
|
|
125
|
+
* @param {BTNRep<K, V, RedBlackTreeNode<K, V>>} keyNodeOrEntry - The parameter
|
|
126
|
+
* `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, RedBlackTreeNode<K, V>>`.
|
|
127
|
+
* @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
|
|
130
128
|
* an instance of the `RedBlackTreeNode` class.
|
|
131
129
|
*/
|
|
132
|
-
isNode(
|
|
130
|
+
isNode(keyNodeOrEntry: BTNRep<K, V, RedBlackTreeNode<K, V>>): keyNodeOrEntry is RedBlackTreeNode<K, V>;
|
|
133
131
|
/**
|
|
134
132
|
* Time Complexity: O(1)
|
|
135
133
|
* Space Complexity: O(1)
|
|
@@ -140,12 +138,12 @@ export declare class RedBlackTree<K = any, V = any, R = object, NODE extends Red
|
|
|
140
138
|
clear(): void;
|
|
141
139
|
/**
|
|
142
140
|
* Time Complexity: O(log n)
|
|
143
|
-
* Space Complexity: O(
|
|
141
|
+
* Space Complexity: O(log n)
|
|
144
142
|
*
|
|
145
143
|
* The function adds a new node to a binary search tree and returns true if the node was successfully
|
|
146
144
|
* added.
|
|
147
|
-
* @param {BTNRep<K, V,
|
|
148
|
-
* `
|
|
145
|
+
* @param {BTNRep<K, V, RedBlackTreeNode<K, V>>} keyNodeOrEntry - The parameter
|
|
146
|
+
* `keyNodeOrEntry` can accept a value of type `R` or `BTNRep<K, V, RedBlackTreeNode<K, V>>`.
|
|
149
147
|
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with
|
|
150
148
|
* the key in the data structure. It represents the value that you want to add or update in the data
|
|
151
149
|
* structure.
|
|
@@ -153,106 +151,136 @@ export declare class RedBlackTree<K = any, V = any, R = object, NODE extends Red
|
|
|
153
151
|
* the method returns true. If the node already exists and its value is updated, the method also
|
|
154
152
|
* returns true. If the node cannot be added or updated, the method returns false.
|
|
155
153
|
*/
|
|
156
|
-
add(
|
|
154
|
+
add(keyNodeOrEntry: BTNRep<K, V, RedBlackTreeNode<K, V>>, value?: V): boolean;
|
|
157
155
|
/**
|
|
158
156
|
* Time Complexity: O(log n)
|
|
159
|
-
* Space Complexity: O(
|
|
157
|
+
* Space Complexity: O(log n)
|
|
160
158
|
*
|
|
161
159
|
* The function overrides the delete method in a binary tree data structure to remove a node based on
|
|
162
160
|
* a given predicate and maintain the binary search tree properties.
|
|
163
|
-
* @param {BTNRep<K, V,
|
|
161
|
+
* @param {BTNRep<K, V, RedBlackTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
|
|
164
162
|
* parameter in the `override delete` method is used to specify the condition or key based on which a
|
|
165
163
|
* node should be deleted from the binary tree. It can be a key, a node, an entry, or a predicate
|
|
166
164
|
* function that determines which node(s) should be deleted.
|
|
167
|
-
* @returns The `override delete` method is returning an array of `BinaryTreeDeleteResult<
|
|
165
|
+
* @returns The `override delete` method is returning an array of `BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>`
|
|
168
166
|
* objects. Each object in the array contains information about the deleted node and whether
|
|
169
167
|
* balancing is needed.
|
|
170
168
|
*/
|
|
171
|
-
delete(
|
|
169
|
+
delete(keyNodeOrEntry: BTNRep<K, V, RedBlackTreeNode<K, V>>): BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>[];
|
|
170
|
+
/**
|
|
171
|
+
* Time Complexity: O(n)
|
|
172
|
+
* Space Complexity: O(n)
|
|
173
|
+
*
|
|
174
|
+
* The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
|
|
175
|
+
* applying a callback to each entry in the original tree.
|
|
176
|
+
* @param callback - A function that will be called for each entry in the tree, with parameters
|
|
177
|
+
* representing the key, value, index, and the tree itself. It should return an entry for the new
|
|
178
|
+
* tree.
|
|
179
|
+
* @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
|
|
180
|
+
* MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
|
|
181
|
+
* Tree that will be created during the mapping process. These options could include things like
|
|
182
|
+
* custom comparators
|
|
183
|
+
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
|
|
184
|
+
* the value of `this` when executing the `callback` function. It allows you to set the context
|
|
185
|
+
* (value of `this`) for the callback function. This can be useful when you want to access properties
|
|
186
|
+
* or
|
|
187
|
+
* @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
|
|
188
|
+
* provided callback function.
|
|
189
|
+
*/
|
|
190
|
+
map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: RedBlackTreeOptions<MK, MV, MR>, thisArg?: any): RedBlackTree<MK, MV, MR>;
|
|
191
|
+
/**
|
|
192
|
+
* Time Complexity: O(n)
|
|
193
|
+
* Space Complexity: O(n)
|
|
194
|
+
*
|
|
195
|
+
* The function `clone` overrides the default cloning behavior to create a deep copy of a tree
|
|
196
|
+
* structure.
|
|
197
|
+
* @returns The `cloned` object is being returned.
|
|
198
|
+
*/
|
|
199
|
+
clone(): RedBlackTree<K, V, R, MK, MV, MR>;
|
|
172
200
|
/**
|
|
173
201
|
* Time Complexity: O(1)
|
|
174
202
|
* Space Complexity: O(1)
|
|
175
203
|
*
|
|
176
204
|
* The function sets the root of a tree-like structure and updates the parent property of the new
|
|
177
205
|
* root.
|
|
178
|
-
* @param {
|
|
206
|
+
* @param {RedBlackTreeNode<K, V> | undefined} v - v is a parameter of type RedBlackTreeNode<K, V> or undefined.
|
|
179
207
|
*/
|
|
180
|
-
protected _setRoot(v:
|
|
208
|
+
protected _setRoot(v: RedBlackTreeNode<K, V> | undefined): void;
|
|
181
209
|
/**
|
|
182
210
|
* Time Complexity: O(1)
|
|
183
211
|
* Space Complexity: O(1)
|
|
184
212
|
*
|
|
185
213
|
* The function replaces an old node with a new node while preserving the color of the old node.
|
|
186
|
-
* @param {
|
|
214
|
+
* @param {RedBlackTreeNode<K, V>} oldNode - The `oldNode` parameter represents the node that needs to be replaced in
|
|
187
215
|
* the data structure.
|
|
188
|
-
* @param {
|
|
216
|
+
* @param {RedBlackTreeNode<K, V>} newNode - The `newNode` parameter is of type `RedBlackTreeNode<K, V>`, which represents a node in a
|
|
189
217
|
* data structure.
|
|
190
218
|
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
191
219
|
* superclass, with the `oldNode` and `newNode` parameters.
|
|
192
220
|
*/
|
|
193
|
-
protected _replaceNode(oldNode:
|
|
221
|
+
protected _replaceNode(oldNode: RedBlackTreeNode<K, V>, newNode: RedBlackTreeNode<K, V>): RedBlackTreeNode<K, V>;
|
|
194
222
|
/**
|
|
195
223
|
* Time Complexity: O(log n)
|
|
196
|
-
* Space Complexity: O(
|
|
224
|
+
* Space Complexity: O(log n)
|
|
197
225
|
*
|
|
198
226
|
* The `_insert` function inserts a node into a binary search tree and performs necessary fix-ups to
|
|
199
227
|
* maintain the red-black tree properties.
|
|
200
|
-
* @param {
|
|
228
|
+
* @param {RedBlackTreeNode<K, V>} node - The `node` parameter represents the node that needs to be inserted into the
|
|
201
229
|
* binary search tree.
|
|
202
230
|
* @returns a string value indicating the result of the insertion operation. It can return either
|
|
203
231
|
* 'UPDATED' if the node with the same key already exists and was updated, or 'CREATED' if a new node
|
|
204
232
|
* was created and inserted into the tree.
|
|
205
233
|
*/
|
|
206
|
-
protected _insert(node:
|
|
234
|
+
protected _insert(node: RedBlackTreeNode<K, V>): CRUD;
|
|
207
235
|
/**
|
|
208
236
|
* Time Complexity: O(1)
|
|
209
237
|
* Space Complexity: O(1)
|
|
210
238
|
*
|
|
211
239
|
* The function `_transplant` is used to replace a node `u` with another node `v` in a binary tree.
|
|
212
|
-
* @param {
|
|
213
|
-
* @param {
|
|
214
|
-
* either be a `
|
|
240
|
+
* @param {RedBlackTreeNode<K, V>} u - The parameter "u" represents a node in a binary tree.
|
|
241
|
+
* @param {RedBlackTreeNode<K, V> | undefined} v - The parameter `v` is of type `RedBlackTreeNode<K, V> | undefined`, which means it can
|
|
242
|
+
* either be a `RedBlackTreeNode<K, V>` object or `undefined`.
|
|
215
243
|
*/
|
|
216
|
-
protected _transplant(u:
|
|
244
|
+
protected _transplant(u: RedBlackTreeNode<K, V>, v: RedBlackTreeNode<K, V> | undefined): void;
|
|
217
245
|
/**
|
|
218
246
|
* Time Complexity: O(log n)
|
|
219
247
|
* Space Complexity: O(1)
|
|
220
248
|
*
|
|
221
249
|
* The `_insertFixup` function is used to fix the Red-Black Tree after inserting a new node.
|
|
222
|
-
* @param {
|
|
250
|
+
* @param {RedBlackTreeNode<K, V> | undefined} z - The parameter `z` represents a node in the Red-Black Tree data
|
|
223
251
|
* structure. It can either be a valid node or `undefined`.
|
|
224
252
|
*/
|
|
225
|
-
protected _insertFixup(z:
|
|
253
|
+
protected _insertFixup(z: RedBlackTreeNode<K, V> | undefined): void;
|
|
226
254
|
/**
|
|
227
255
|
* Time Complexity: O(log n)
|
|
228
256
|
* Space Complexity: O(1)
|
|
229
257
|
*
|
|
230
258
|
* The `_deleteFixup` function is used to fix the red-black tree after a node deletion by adjusting
|
|
231
259
|
* the colors and performing rotations.
|
|
232
|
-
* @param {
|
|
260
|
+
* @param {RedBlackTreeNode<K, V> | undefined} node - The `node` parameter represents a node in a binary tree. It can
|
|
233
261
|
* be either a valid node object or `undefined`.
|
|
234
262
|
* @returns The function does not return any value. It has a return type of `void`, which means it
|
|
235
263
|
* does not return anything.
|
|
236
264
|
*/
|
|
237
|
-
protected _deleteFixup(node:
|
|
265
|
+
protected _deleteFixup(node: RedBlackTreeNode<K, V> | undefined): void;
|
|
238
266
|
/**
|
|
239
267
|
* Time Complexity: O(1)
|
|
240
268
|
* Space Complexity: O(1)
|
|
241
269
|
*
|
|
242
270
|
* The `_leftRotate` function performs a left rotation on a given node in a binary tree.
|
|
243
|
-
* @param {
|
|
271
|
+
* @param {RedBlackTreeNode<K, V> | undefined} x - The parameter `x` is of type `RedBlackTreeNode<K, V> | undefined`. It represents a
|
|
244
272
|
* node in a binary tree or `undefined` if there is no node.
|
|
245
273
|
* @returns void, which means it does not return any value.
|
|
246
274
|
*/
|
|
247
|
-
protected _leftRotate(x:
|
|
275
|
+
protected _leftRotate(x: RedBlackTreeNode<K, V> | undefined): void;
|
|
248
276
|
/**
|
|
249
277
|
* Time Complexity: O(1)
|
|
250
278
|
* Space Complexity: O(1)
|
|
251
279
|
*
|
|
252
280
|
* The `_rightRotate` function performs a right rotation on a given node in a binary tree.
|
|
253
|
-
* @param {
|
|
281
|
+
* @param {RedBlackTreeNode<K, V> | undefined} y - The parameter `y` is of type `RedBlackTreeNode<K, V> | undefined`. It represents a
|
|
254
282
|
* node in a binary tree or `undefined` if there is no node.
|
|
255
283
|
* @returns void, which means it does not return any value.
|
|
256
284
|
*/
|
|
257
|
-
protected _rightRotate(y:
|
|
285
|
+
protected _rightRotate(y: RedBlackTreeNode<K, V> | undefined): void;
|
|
258
286
|
}
|