priority-queue-typed 1.48.2 → 1.48.4

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 (40) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +16 -16
  2. package/dist/data-structures/binary-tree/avl-tree.js +7 -7
  3. package/dist/data-structures/binary-tree/binary-tree.d.ts +89 -87
  4. package/dist/data-structures/binary-tree/binary-tree.js +67 -58
  5. package/dist/data-structures/binary-tree/bst.d.ts +28 -47
  6. package/dist/data-structures/binary-tree/bst.js +54 -57
  7. package/dist/data-structures/binary-tree/rb-tree.d.ts +15 -15
  8. package/dist/data-structures/binary-tree/rb-tree.js +7 -7
  9. package/dist/data-structures/binary-tree/tree-multimap.d.ts +22 -22
  10. package/dist/data-structures/binary-tree/tree-multimap.js +11 -11
  11. package/dist/data-structures/graph/abstract-graph.d.ts +1 -0
  12. package/dist/data-structures/graph/abstract-graph.js +4 -0
  13. package/dist/data-structures/graph/directed-graph.d.ts +25 -7
  14. package/dist/data-structures/graph/directed-graph.js +58 -12
  15. package/dist/data-structures/graph/undirected-graph.d.ts +25 -6
  16. package/dist/data-structures/graph/undirected-graph.js +70 -7
  17. package/dist/interfaces/binary-tree.d.ts +6 -6
  18. package/dist/types/common.d.ts +11 -8
  19. package/dist/types/common.js +6 -1
  20. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
  21. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  22. package/dist/types/data-structures/binary-tree/bst.d.ts +6 -6
  23. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
  24. package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
  25. package/package.json +2 -2
  26. package/src/data-structures/binary-tree/avl-tree.ts +20 -21
  27. package/src/data-structures/binary-tree/binary-tree.ts +147 -136
  28. package/src/data-structures/binary-tree/bst.ts +86 -82
  29. package/src/data-structures/binary-tree/rb-tree.ts +25 -26
  30. package/src/data-structures/binary-tree/tree-multimap.ts +30 -35
  31. package/src/data-structures/graph/abstract-graph.ts +5 -0
  32. package/src/data-structures/graph/directed-graph.ts +61 -12
  33. package/src/data-structures/graph/undirected-graph.ts +75 -7
  34. package/src/interfaces/binary-tree.ts +5 -6
  35. package/src/types/common.ts +11 -8
  36. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -3
  37. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -5
  38. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  39. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -3
  40. package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -3
@@ -96,19 +96,37 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
96
96
  */
97
97
  deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | undefined;
98
98
  /**
99
- * Time Complexity: O(|E|) where |E| is the number of edges
99
+ * Time Complexity: O(E) where E is the number of edges
100
100
  * Space Complexity: O(1)
101
101
  */
102
102
  /**
103
- * Time Complexity: O(|E|) where |E| is the number of edges
103
+ * Time Complexity: O(E) where E is the number of edges
104
104
  * Space Complexity: O(1)
105
105
  *
106
- * The function removes an edge from a graph and returns the removed edge, or undefined if the edge was not found.
107
- * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
108
- * and `dest`, which represent the source and destination vertices of the edge, respectively.
109
- * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `undefined` if the edge does not exist.
106
+ * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
107
+ * @param {EO | VertexKey} edgeOrSrcVertexKey - The `edge` parameter can be either an `EO` object (edge object) or
108
+ * a `VertexKey` (key of a vertex).
109
+ * @param {VertexKey} [destVertexKey] - The `destVertexKey` parameter is an optional parameter that
110
+ * represents the key of the destination vertex of the edge. It is used to specify the destination
111
+ * vertex when the `edge` parameter is a vertex key. If `destVertexKey` is not provided, the function
112
+ * assumes that the `edge`
113
+ * @returns the removed edge (EO) or undefined if no edge was removed.
114
+ */
115
+ deleteEdge(edgeOrSrcVertexKey: EO | VertexKey, destVertexKey?: VertexKey): EO | undefined;
116
+ /**
117
+ * Time Complexity: O(1) - Constant time for Map operations.
118
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
119
+ */
120
+ /**
121
+ * Time Complexity: O(1) - Constant time for Map operations.
122
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
123
+ *
124
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
125
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
126
+ * (`VertexKey`).
127
+ * @returns The method is returning a boolean value.
110
128
  */
111
- deleteEdge(edge: EO): EO | undefined;
129
+ deleteVertex(vertexOrKey: VO | VertexKey): boolean;
112
130
  /**
113
131
  * Time Complexity: O(|E|) where |E| is the number of edges
114
132
  * Space Complexity: O(1)
@@ -150,34 +150,80 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
150
150
  return removed;
151
151
  }
152
152
  /**
153
- * Time Complexity: O(|E|) where |E| is the number of edges
153
+ * Time Complexity: O(E) where E is the number of edges
154
154
  * Space Complexity: O(1)
155
155
  */
156
156
  /**
157
- * Time Complexity: O(|E|) where |E| is the number of edges
157
+ * Time Complexity: O(E) where E is the number of edges
158
158
  * Space Complexity: O(1)
159
159
  *
160
- * The function removes an edge from a graph and returns the removed edge, or undefined if the edge was not found.
161
- * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
162
- * and `dest`, which represent the source and destination vertices of the edge, respectively.
163
- * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `undefined` if the edge does not exist.
164
- */
165
- deleteEdge(edge) {
160
+ * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
161
+ * @param {EO | VertexKey} edgeOrSrcVertexKey - The `edge` parameter can be either an `EO` object (edge object) or
162
+ * a `VertexKey` (key of a vertex).
163
+ * @param {VertexKey} [destVertexKey] - The `destVertexKey` parameter is an optional parameter that
164
+ * represents the key of the destination vertex of the edge. It is used to specify the destination
165
+ * vertex when the `edge` parameter is a vertex key. If `destVertexKey` is not provided, the function
166
+ * assumes that the `edge`
167
+ * @returns the removed edge (EO) or undefined if no edge was removed.
168
+ */
169
+ deleteEdge(edgeOrSrcVertexKey, destVertexKey) {
166
170
  let removed = undefined;
167
- const src = this._getVertex(edge.src);
168
- const dest = this._getVertex(edge.dest);
171
+ let src, dest;
172
+ if (this.isVertexKey(edgeOrSrcVertexKey)) {
173
+ if (this.isVertexKey(destVertexKey)) {
174
+ src = this._getVertex(edgeOrSrcVertexKey);
175
+ dest = this._getVertex(destVertexKey);
176
+ }
177
+ else {
178
+ return;
179
+ }
180
+ }
181
+ else {
182
+ src = this._getVertex(edgeOrSrcVertexKey.src);
183
+ dest = this._getVertex(edgeOrSrcVertexKey.dest);
184
+ }
169
185
  if (src && dest) {
170
186
  const srcOutEdges = this._outEdgeMap.get(src);
171
187
  if (srcOutEdges && srcOutEdges.length > 0) {
172
- (0, utils_1.arrayRemove)(srcOutEdges, (edge) => edge.src === src.key);
188
+ (0, utils_1.arrayRemove)(srcOutEdges, (edge) => edge.src === src.key && edge.dest === (dest === null || dest === void 0 ? void 0 : dest.key));
173
189
  }
174
190
  const destInEdges = this._inEdgeMap.get(dest);
175
191
  if (destInEdges && destInEdges.length > 0) {
176
- removed = (0, utils_1.arrayRemove)(destInEdges, (edge) => edge.dest === dest.key)[0];
192
+ removed = (0, utils_1.arrayRemove)(destInEdges, (edge) => edge.src === src.key && edge.dest === dest.key)[0];
177
193
  }
178
194
  }
179
195
  return removed;
180
196
  }
197
+ /**
198
+ * Time Complexity: O(1) - Constant time for Map operations.
199
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
200
+ */
201
+ /**
202
+ * Time Complexity: O(1) - Constant time for Map operations.
203
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
204
+ *
205
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
206
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
207
+ * (`VertexKey`).
208
+ * @returns The method is returning a boolean value.
209
+ */
210
+ deleteVertex(vertexOrKey) {
211
+ let vertexKey;
212
+ let vertex;
213
+ if (this.isVertexKey(vertexOrKey)) {
214
+ vertex = this.getVertex(vertexOrKey);
215
+ vertexKey = vertexOrKey;
216
+ }
217
+ else {
218
+ vertex = vertexOrKey;
219
+ vertexKey = this._getVertexKey(vertexOrKey);
220
+ }
221
+ if (vertex) {
222
+ this._outEdgeMap.delete(vertex);
223
+ this._inEdgeMap.delete(vertex);
224
+ }
225
+ return this._vertices.delete(vertexKey);
226
+ }
181
227
  /**
182
228
  * Time Complexity: O(|E|) where |E| is the number of edges
183
229
  * Space Complexity: O(1)
@@ -85,18 +85,37 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
85
85
  */
86
86
  deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | undefined;
87
87
  /**
88
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
88
+ * Time Complexity: O(E), where E is the number of edges incident to the given vertex.
89
89
  * Space Complexity: O(1)
90
90
  */
91
91
  /**
92
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
92
+ * Time Complexity: O(E), where E is the number of edges incident to the given vertex.
93
93
  * Space Complexity: O(1)
94
94
  *
95
- * The deleteEdge function removes an edge between two vertices in a graph.
96
- * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
97
- * @returns The method is returning either the removed edge (of type EO) or undefined if the edge was not found.
95
+ * The function `deleteEdge` deletes an edge between two vertices in a graph.
96
+ * @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be
97
+ * either an edge object or a vertex key.
98
+ * @param {VertexKey} [otherSideVertexKey] - The parameter `otherSideVertexKey` is an optional
99
+ * parameter that represents the key of the vertex on the other side of the edge. It is used when the
100
+ * `edgeOrOneSideVertexKey` parameter is a vertex key, and it specifies the key of the vertex on the
101
+ * other side of the
102
+ * @returns The `deleteEdge` function returns either the deleted edge object (EO) or `undefined`.
103
+ */
104
+ deleteEdge(edgeOrOneSideVertexKey: EO | VertexKey, otherSideVertexKey?: VertexKey): EO | undefined;
105
+ /**
106
+ * Time Complexity: O(1) - Constant time for Map operations.
107
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
108
+ */
109
+ /**
110
+ * Time Complexity: O(1) - Constant time for Map operations.
111
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
112
+ *
113
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
114
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
115
+ * (`VertexKey`).
116
+ * @returns The method is returning a boolean value.
98
117
  */
99
- deleteEdge(edge: EO): EO | undefined;
118
+ deleteVertex(vertexOrKey: VO | VertexKey): boolean;
100
119
  /**
101
120
  * Time Complexity: O(1)
102
121
  * Space Complexity: O(1)
@@ -135,19 +135,82 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
135
135
  return removed;
136
136
  }
137
137
  /**
138
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
138
+ * Time Complexity: O(E), where E is the number of edges incident to the given vertex.
139
139
  * Space Complexity: O(1)
140
140
  */
141
141
  /**
142
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
142
+ * Time Complexity: O(E), where E is the number of edges incident to the given vertex.
143
143
  * Space Complexity: O(1)
144
144
  *
145
- * The deleteEdge function removes an edge between two vertices in a graph.
146
- * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
147
- * @returns The method is returning either the removed edge (of type EO) or undefined if the edge was not found.
145
+ * The function `deleteEdge` deletes an edge between two vertices in a graph.
146
+ * @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be
147
+ * either an edge object or a vertex key.
148
+ * @param {VertexKey} [otherSideVertexKey] - The parameter `otherSideVertexKey` is an optional
149
+ * parameter that represents the key of the vertex on the other side of the edge. It is used when the
150
+ * `edgeOrOneSideVertexKey` parameter is a vertex key, and it specifies the key of the vertex on the
151
+ * other side of the
152
+ * @returns The `deleteEdge` function returns either the deleted edge object (EO) or `undefined`.
153
+ */
154
+ deleteEdge(edgeOrOneSideVertexKey, otherSideVertexKey) {
155
+ let oneSide, otherSide;
156
+ if (this.isVertexKey(edgeOrOneSideVertexKey)) {
157
+ if (this.isVertexKey(otherSideVertexKey)) {
158
+ oneSide = this._getVertex(edgeOrOneSideVertexKey);
159
+ otherSide = this._getVertex(otherSideVertexKey);
160
+ }
161
+ else {
162
+ return;
163
+ }
164
+ }
165
+ else {
166
+ oneSide = this._getVertex(edgeOrOneSideVertexKey.vertices[0]);
167
+ otherSide = this._getVertex(edgeOrOneSideVertexKey.vertices[1]);
168
+ }
169
+ if (oneSide && otherSide) {
170
+ return this.deleteEdgeBetween(oneSide, otherSide);
171
+ }
172
+ else {
173
+ return;
174
+ }
175
+ }
176
+ /**
177
+ * Time Complexity: O(1) - Constant time for Map operations.
178
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
148
179
  */
149
- deleteEdge(edge) {
150
- return this.deleteEdgeBetween(edge.vertices[0], edge.vertices[1]);
180
+ /**
181
+ * Time Complexity: O(1) - Constant time for Map operations.
182
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
183
+ *
184
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
185
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
186
+ * (`VertexKey`).
187
+ * @returns The method is returning a boolean value.
188
+ */
189
+ deleteVertex(vertexOrKey) {
190
+ let vertexKey;
191
+ let vertex;
192
+ if (this.isVertexKey(vertexOrKey)) {
193
+ vertex = this.getVertex(vertexOrKey);
194
+ vertexKey = vertexOrKey;
195
+ }
196
+ else {
197
+ vertex = vertexOrKey;
198
+ vertexKey = this._getVertexKey(vertexOrKey);
199
+ }
200
+ const neighbors = this.getNeighbors(vertexOrKey);
201
+ if (vertex) {
202
+ neighbors.forEach(neighbor => {
203
+ const neighborEdges = this._edges.get(neighbor);
204
+ if (neighborEdges) {
205
+ const restEdges = neighborEdges.filter(edge => {
206
+ return !edge.vertices.includes(vertexKey);
207
+ });
208
+ this._edges.set(neighbor, restEdges);
209
+ }
210
+ });
211
+ this._edges.delete(vertex);
212
+ }
213
+ return this._vertices.delete(vertexKey);
151
214
  }
152
215
  /**
153
216
  * Time Complexity: O(1)
@@ -1,9 +1,9 @@
1
1
  import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
- import { BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BiTreeDeleteResult, BTNCallback, BTNKey, BTNodeExemplar } from '../types';
3
- export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>, TREE extends BinaryTree<V, N, TREE> = BinaryTreeNested<V, N>> {
4
- createNode(key: BTNKey, value?: N['value']): N;
5
- createTree(options?: Partial<BinaryTreeOptions>): TREE;
6
- add(keyOrNodeOrEntry: BTNodeExemplar<V, N>, count?: number): N | null | undefined;
7
- addMany(nodes: Iterable<BTNodeExemplar<V, N>>): (N | null | undefined)[];
2
+ import { BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BiTreeDeleteResult, BTNCallback, BTNodeExemplar } from '../types';
3
+ export interface IBinaryTree<K = number, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTreeNested<K, V, N>> {
4
+ createNode(key: K, value?: N['value']): N;
5
+ createTree(options?: Partial<BinaryTreeOptions<K>>): TREE;
6
+ add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count?: number): N | null | undefined;
7
+ addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];
8
8
  delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
9
9
  }
@@ -1,5 +1,8 @@
1
- import { BTNKey } from "./data-structures";
2
- export type Comparator<T> = (a: T, b: T) => number;
1
+ export type Comparator<K> = (a: K, b: K) => number;
2
+ export declare enum BSTVariant {
3
+ MIN = "MIN",
4
+ MAX = "MAX"
5
+ }
3
6
  export type DFSOrderPattern = 'pre' | 'in' | 'post';
4
7
  export type BTNCallback<N, D = any> = (node: N) => D;
5
8
  export declare enum CP {
@@ -19,9 +22,9 @@ export type BinaryTreePrintOptions = {
19
22
  isShowNull?: boolean;
20
23
  isShowRedBlackNIL?: boolean;
21
24
  };
22
- export type BTNodeEntry<T> = [BTNKey | null | undefined, T | undefined];
23
- export type BTNodeKeyOrNode<N> = BTNKey | null | undefined | N;
24
- export type BTNodeExemplar<T, N> = BTNodeEntry<T> | BTNodeKeyOrNode<N>;
25
- export type BTNodePureExemplar<T, N> = [BTNKey, T | undefined] | BTNodePureKeyOrNode<N>;
26
- export type BTNodePureKeyOrNode<N> = BTNKey | N;
27
- export type BSTNodeKeyOrNode<N> = BTNKey | undefined | N;
25
+ export type BTNodeEntry<K, V> = [K | null | undefined, V | undefined];
26
+ export type BTNodeKeyOrNode<K, N> = K | null | undefined | N;
27
+ export type BTNodeExemplar<K, V, N> = BTNodeEntry<K, V> | BTNodeKeyOrNode<K, N>;
28
+ export type BTNodePureExemplar<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>;
29
+ export type BTNodePureKeyOrNode<K, N> = K | N;
30
+ export type BSTNodeKeyOrNode<K, N> = K | undefined | N;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CP = void 0;
3
+ exports.CP = exports.BSTVariant = void 0;
4
+ var BSTVariant;
5
+ (function (BSTVariant) {
6
+ BSTVariant["MIN"] = "MIN";
7
+ BSTVariant["MAX"] = "MAX";
8
+ })(BSTVariant || (exports.BSTVariant = BSTVariant = {}));
4
9
  var CP;
5
10
  (function (CP) {
6
11
  CP["lt"] = "lt";
@@ -1,5 +1,5 @@
1
1
  import { AVLTree, AVLTreeNode } from '../../../data-structures';
2
2
  import { BSTOptions } from './bst';
3
- export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type AVLTreeNested<T, N extends AVLTreeNode<T, N>> = AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type AVLTreeOptions = BSTOptions & {};
3
+ export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type AVLTreeNested<K, V, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type AVLTreeOptions<K> = BSTOptions<K> & {};
@@ -18,14 +18,14 @@ export declare enum FamilyPosition {
18
18
  ISOLATED = "ISOLATED",
19
19
  MAL_NODE = "MAL_NODE"
20
20
  }
21
- export type BTNKey = number;
22
21
  export type BiTreeDeleteResult<N> = {
23
22
  deleted: N | null | undefined;
24
23
  needBalanced: N | null | undefined;
25
24
  };
26
- export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
27
- export type BinaryTreeNested<T, N extends BinaryTreeNode<T, N>> = BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
28
- export type BinaryTreeOptions = {
25
+ export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
26
+ export type BinaryTreeNested<K, V, N extends BinaryTreeNode<K, V, N>> = BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
27
+ export type BinaryTreeOptions<K> = {
29
28
  iterationType: IterationType;
29
+ extractor: (key: K) => number;
30
30
  };
31
31
  export type NodeDisplayLayout = [string[], number, number, number];
@@ -1,8 +1,8 @@
1
1
  import { BST, BSTNode } from '../../../data-structures';
2
- import type { BinaryTreeOptions, BTNKey } from './binary-tree';
3
- import { Comparator } from "../../common";
4
- export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type BSTNested<T, N extends BSTNode<T, N>> = BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
- export type BSTOptions = BinaryTreeOptions & {
7
- comparator: Comparator<BTNKey>;
2
+ import type { BinaryTreeOptions } from './binary-tree';
3
+ import { BSTVariant } from "../../common";
4
+ export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type BSTNested<K, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
+ export type BSTOptions<K> = BinaryTreeOptions<K> & {
7
+ variant: BSTVariant;
8
8
  };
@@ -4,6 +4,6 @@ export declare enum RBTNColor {
4
4
  RED = 1,
5
5
  BLACK = 0
6
6
  }
7
- export type RedBlackTreeNodeNested<T> = RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
8
- export type RedBlackTreeNested<T, N extends RedBlackTreeNode<T, N>> = RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
9
- export type RBTreeOptions = BSTOptions & {};
7
+ export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
8
+ export type RedBlackTreeNested<K, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
9
+ export type RBTreeOptions<K> = BSTOptions<K> & {};
@@ -1,5 +1,5 @@
1
1
  import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
2
2
  import { AVLTreeOptions } from './avl-tree';
3
- export type TreeMultimapNodeNested<T> = TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type TreeMultimapNested<T, N extends TreeMultimapNode<T, N>> = TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type TreeMultimapOptions = Omit<AVLTreeOptions, 'isMergeDuplicatedNodeByKey'> & {};
3
+ export type TreeMultimapNodeNested<K, V> = TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type TreeMultimapNested<K, V, N extends TreeMultimapNode<K, V, N>> = TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type TreeMultimapOptions<K> = Omit<AVLTreeOptions<K>, 'isMergeDuplicatedNodeByKey'> & {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "priority-queue-typed",
3
- "version": "1.48.2",
3
+ "version": "1.48.4",
4
4
  "description": "Priority Queue, Min Priority Queue, Max Priority Queue. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -120,6 +120,6 @@
120
120
  "typedoc": "^0.25.1"
121
121
  },
122
122
  "dependencies": {
123
- "data-structure-typed": "^1.48.2"
123
+ "data-structure-typed": "^1.48.4"
124
124
  }
125
125
  }
@@ -12,16 +12,15 @@ import type {
12
12
  AVLTreeOptions,
13
13
  BiTreeDeleteResult,
14
14
  BSTNodeKeyOrNode,
15
- BTNKey,
16
15
  BTNodeExemplar
17
16
  } from '../../types';
18
17
  import { BTNCallback } from '../../types';
19
18
  import { IBinaryTree } from '../../interfaces';
20
19
 
21
- export class AVLTreeNode<V = any, N extends AVLTreeNode<V, N> = AVLTreeNodeNested<V>> extends BSTNode<V, N> {
20
+ export class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, N> {
22
21
  height: number;
23
22
 
24
- constructor(key: BTNKey, value?: V) {
23
+ constructor(key: K, value?: V) {
25
24
  super(key, value);
26
25
  this.height = 0;
27
26
  }
@@ -37,35 +36,35 @@ export class AVLTreeNode<V = any, N extends AVLTreeNode<V, N> = AVLTreeNodeNeste
37
36
  * 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
38
37
  * 8. Memory Overhead: Stores balance factors (or heights) at each node, leading to slightly higher memory usage compared to a regular BST.
39
38
  */
40
- export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTreeNodeNested<V>>, TREE extends AVLTree<V, N, TREE> = AVLTree<V, N, AVLTreeNested<V, N>>>
41
- extends BST<V, N, TREE>
42
- implements IBinaryTree<V, N, TREE> {
39
+ export class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, N, TREE> = AVLTree<K, V, N, AVLTreeNested<K, V, N>>>
40
+ extends BST<K, V, N, TREE>
41
+ implements IBinaryTree<K, V, N, TREE> {
43
42
 
44
43
  /**
45
44
  * The constructor function initializes an AVLTree object with optional elements and options.
46
- * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<V, N>`
45
+ * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
47
46
  * objects. It represents a collection of elements that will be added to the AVL tree during
48
47
  * initialization.
49
48
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
50
49
  * behavior of the AVL tree. It is of type `Partial<AVLTreeOptions>`, which means that you can
51
50
  * provide only a subset of the properties defined in the `AVLTreeOptions` interface.
52
51
  */
53
- constructor(elements?: Iterable<BTNodeExemplar<V, N>>, options?: Partial<AVLTreeOptions>) {
52
+ constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<AVLTreeOptions<K>>) {
54
53
  super([], options);
55
54
  if (elements) super.addMany(elements);
56
55
  }
57
56
 
58
57
  /**
59
58
  * The function creates a new AVL tree node with the specified key and value.
60
- * @param {BTNKey} key - The key parameter is the key value that will be associated with
59
+ * @param {K} key - The key parameter is the key value that will be associated with
61
60
  * the new node. It is used to determine the position of the node in the binary search tree.
62
61
  * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
63
62
  * type `V`, which means it can be any value that is assignable to the `value` property of the
64
63
  * node type `N`.
65
64
  * @returns a new AVLTreeNode object with the specified key and value.
66
65
  */
67
- override createNode(key: BTNKey, value?: V): N {
68
- return new AVLTreeNode<V, N>(key, value) as N;
66
+ override createNode(key: K, value?: V): N {
67
+ return new AVLTreeNode<K, V, N>(key, value) as N;
69
68
  }
70
69
 
71
70
  /**
@@ -75,19 +74,19 @@ export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
75
74
  * being created.
76
75
  * @returns a new AVLTree object.
77
76
  */
78
- override createTree(options?: AVLTreeOptions): TREE {
79
- return new AVLTree<V, N, TREE>([], {
77
+ override createTree(options?: AVLTreeOptions<K>): TREE {
78
+ return new AVLTree<K, V, N, TREE>([], {
80
79
  iterationType: this.iterationType,
81
- comparator: this.comparator, ...options
80
+ variant: this.variant, ...options
82
81
  }) as TREE;
83
82
  }
84
83
 
85
84
  /**
86
85
  * The function checks if an exemplar is an instance of AVLTreeNode.
87
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<V, N>`.
86
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
88
87
  * @returns a boolean value indicating whether the exemplar is an instance of the AVLTreeNode class.
89
88
  */
90
- override isNode(exemplar: BTNodeExemplar<V, N>): exemplar is N {
89
+ override isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N {
91
90
  return exemplar instanceof AVLTreeNode;
92
91
  }
93
92
 
@@ -106,7 +105,7 @@ export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
106
105
  * entry.
107
106
  * @returns The method is returning either the inserted node or `undefined`.
108
107
  */
109
- override add(keyOrNodeOrEntry: BTNodeExemplar<V, N>): N | undefined {
108
+ override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined {
110
109
  if (keyOrNodeOrEntry === null) return undefined;
111
110
  const inserted = super.add(keyOrNodeOrEntry);
112
111
  if (inserted) this._balancePath(inserted);
@@ -151,14 +150,14 @@ export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
151
150
  /**
152
151
  * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a binary
153
152
  * tree.
154
- * @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node that
155
- * needs to be swapped with the destination node. It can be of type `BTNKey`, `N`, or `undefined`.
156
- * @param {BTNKey | N | undefined} destNode - The `destNode` parameter represents the destination
153
+ * @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node that
154
+ * needs to be swapped with the destination node. It can be of type `K`, `N`, or `undefined`.
155
+ * @param {K | N | undefined} destNode - The `destNode` parameter represents the destination
157
156
  * node where the values from the source node will be swapped to.
158
157
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
159
158
  * if either `srcNode` or `destNode` is undefined.
160
159
  */
161
- protected override _swapProperties(srcNode: BSTNodeKeyOrNode<N>, destNode: BSTNodeKeyOrNode<N>): N | undefined {
160
+ protected override _swapProperties(srcNode: BSTNodeKeyOrNode<K, N>, destNode: BSTNodeKeyOrNode<K, N>): N | undefined {
162
161
  srcNode = this.ensureNode(srcNode);
163
162
  destNode = this.ensureNode(destNode);
164
163