data-structure-typed 1.18.6 → 1.18.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +48 -24
  2. package/dist/data-structures/binary-tree/abstract-binary-tree.js +51 -26
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +5 -4
  4. package/dist/data-structures/binary-tree/avl-tree.js +5 -3
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +13 -3
  6. package/dist/data-structures/binary-tree/binary-tree.js +14 -5
  7. package/dist/data-structures/binary-tree/bst.d.ts +26 -5
  8. package/dist/data-structures/binary-tree/bst.js +26 -4
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +30 -1
  10. package/dist/data-structures/binary-tree/rb-tree.js +27 -14
  11. package/dist/data-structures/binary-tree/tree-multiset.d.ts +15 -4
  12. package/dist/data-structures/binary-tree/tree-multiset.js +15 -3
  13. package/dist/data-structures/graph/abstract-graph.d.ts +20 -21
  14. package/dist/data-structures/graph/abstract-graph.js +24 -19
  15. package/dist/data-structures/graph/directed-graph.d.ts +10 -9
  16. package/dist/data-structures/graph/directed-graph.js +18 -18
  17. package/dist/data-structures/graph/undirected-graph.d.ts +5 -11
  18. package/dist/data-structures/graph/undirected-graph.js +4 -17
  19. package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +101 -0
  20. package/dist/data-structures/interfaces/abstract-binary-tree.js +2 -0
  21. package/dist/data-structures/interfaces/abstract-graph.d.ts +1 -4
  22. package/dist/data-structures/interfaces/avl-tree.d.ts +16 -1
  23. package/dist/data-structures/interfaces/binary-tree.d.ts +4 -24
  24. package/dist/data-structures/interfaces/bst.d.ts +18 -1
  25. package/dist/data-structures/interfaces/directed-graph.d.ts +4 -1
  26. package/dist/data-structures/interfaces/index.d.ts +1 -1
  27. package/dist/data-structures/interfaces/index.js +1 -1
  28. package/dist/data-structures/interfaces/rb-tree.d.ts +9 -0
  29. package/dist/data-structures/interfaces/rb-tree.js +2 -0
  30. package/dist/data-structures/interfaces/undirected-graph.d.ts +4 -1
  31. package/dist/data-structures/types/abstract-binary-tree.d.ts +2 -2
  32. package/dist/utils/utils.js +62 -0
  33. package/docs/assets/search.js +1 -1
  34. package/docs/classes/AVLTree.html +292 -180
  35. package/docs/classes/AVLTreeNode.html +126 -77
  36. package/docs/classes/AaTree.html +12 -6
  37. package/docs/classes/AbstractBinaryTree.html +258 -163
  38. package/docs/classes/AbstractBinaryTreeNode.html +117 -84
  39. package/docs/classes/AbstractEdge.html +22 -16
  40. package/docs/classes/AbstractGraph.html +137 -140
  41. package/docs/classes/AbstractVertex.html +19 -13
  42. package/docs/classes/ArrayDeque.html +25 -19
  43. package/docs/classes/BST.html +275 -174
  44. package/docs/classes/BSTNode.html +127 -77
  45. package/docs/classes/BTree.html +12 -6
  46. package/docs/classes/BinaryIndexedTree.html +20 -14
  47. package/docs/classes/BinaryTree.html +265 -169
  48. package/docs/classes/BinaryTreeNode.html +110 -61
  49. package/docs/classes/Character.html +15 -9
  50. package/docs/classes/CoordinateMap.html +20 -14
  51. package/docs/classes/CoordinateSet.html +19 -13
  52. package/docs/classes/Deque.html +45 -39
  53. package/docs/classes/DirectedEdge.html +26 -20
  54. package/docs/classes/DirectedGraph.html +189 -154
  55. package/docs/classes/DirectedVertex.html +17 -11
  56. package/docs/classes/DoublyLinkedList.html +48 -42
  57. package/docs/classes/DoublyLinkedListNode.html +22 -16
  58. package/docs/classes/HashTable.html +12 -6
  59. package/docs/classes/Heap.html +26 -20
  60. package/docs/classes/HeapItem.html +19 -13
  61. package/docs/classes/Matrix2D.html +27 -21
  62. package/docs/classes/MatrixNTI2D.html +15 -9
  63. package/docs/classes/MaxHeap.html +26 -20
  64. package/docs/classes/MaxPriorityQueue.html +45 -39
  65. package/docs/classes/MinHeap.html +26 -20
  66. package/docs/classes/MinPriorityQueue.html +45 -39
  67. package/docs/classes/Navigator.html +21 -15
  68. package/docs/classes/ObjectDeque.html +36 -30
  69. package/docs/classes/Pair.html +12 -6
  70. package/docs/classes/PriorityQueue.html +43 -37
  71. package/docs/classes/Queue.html +25 -19
  72. package/docs/classes/RBTree.html +2388 -0
  73. package/docs/classes/RBTreeNode.html +516 -0
  74. package/docs/classes/SegmentTree.html +28 -22
  75. package/docs/classes/SegmentTreeNode.html +31 -25
  76. package/docs/classes/SinglyLinkedList.html +45 -39
  77. package/docs/classes/SinglyLinkedListNode.html +19 -13
  78. package/docs/classes/SkipLinkedList.html +12 -6
  79. package/docs/classes/SplayTree.html +12 -6
  80. package/docs/classes/Stack.html +23 -17
  81. package/docs/classes/TreeMap.html +12 -6
  82. package/docs/classes/TreeMultiSet.html +273 -172
  83. package/docs/classes/TreeMultiSetNode.html +126 -77
  84. package/docs/classes/TreeNode.html +27 -21
  85. package/docs/classes/TreeSet.html +12 -6
  86. package/docs/classes/Trie.html +24 -18
  87. package/docs/classes/TrieNode.html +22 -16
  88. package/docs/classes/TwoThreeTree.html +12 -6
  89. package/docs/classes/UndirectedEdge.html +23 -17
  90. package/docs/classes/UndirectedGraph.html +160 -146
  91. package/docs/classes/UndirectedVertex.html +17 -11
  92. package/docs/classes/Vector2D.html +39 -33
  93. package/docs/enums/CP.html +15 -9
  94. package/docs/enums/FamilyPosition.html +15 -9
  95. package/docs/enums/LoopType.html +14 -8
  96. package/docs/enums/RBColor.html +14 -8
  97. package/docs/enums/TopologicalProperty.html +15 -9
  98. package/docs/index.html +11 -5
  99. package/docs/interfaces/IAVLTree.html +1378 -0
  100. package/docs/interfaces/IAVLTreeNode.html +405 -0
  101. package/docs/interfaces/IAbstractBinaryTree.html +1124 -0
  102. package/docs/interfaces/{IBinaryTreeNode.html → IAbstractBinaryTreeNode.html} +61 -73
  103. package/docs/interfaces/{IGraph.html → IAbstractGraph.html} +52 -90
  104. package/docs/interfaces/IBST.html +1271 -0
  105. package/docs/interfaces/IBSTNode.html +408 -0
  106. package/docs/interfaces/IDirectedGraph.html +329 -16
  107. package/docs/interfaces/IUNDirectedGraph.html +322 -8
  108. package/docs/modules.html +22 -10
  109. package/docs/types/AVLTreeOptions.html +12 -6
  110. package/docs/types/{AbstractResultsByProperty.html → AbstractBinaryTreeNodeProperties.html} +16 -10
  111. package/docs/types/{AbstractResultByProperty.html → AbstractBinaryTreeNodeProperty.html} +16 -10
  112. package/docs/types/AbstractBinaryTreeOptions.html +12 -6
  113. package/docs/types/AbstractRecursiveBinaryTreeNode.html +12 -6
  114. package/docs/types/BSTComparator.html +12 -6
  115. package/docs/types/BSTOptions.html +12 -6
  116. package/docs/types/BinaryTreeDeletedResult.html +12 -6
  117. package/docs/types/BinaryTreeNodeId.html +12 -6
  118. package/docs/types/BinaryTreeNodePropertyName.html +12 -6
  119. package/docs/types/BinaryTreeOptions.html +12 -6
  120. package/docs/types/DFSOrderPattern.html +12 -6
  121. package/docs/types/DijkstraResult.html +12 -6
  122. package/docs/types/Direction.html +12 -6
  123. package/docs/types/EdgeId.html +12 -6
  124. package/docs/types/HeapOptions.html +12 -6
  125. package/docs/types/IdObject.html +12 -6
  126. package/docs/types/KeyValObject.html +12 -6
  127. package/docs/types/NavigatorParams.html +12 -6
  128. package/docs/types/NodeOrPropertyName.html +12 -6
  129. package/docs/types/PriorityQueueComparator.html +12 -6
  130. package/docs/types/PriorityQueueDFSOrderPattern.html +12 -6
  131. package/docs/types/PriorityQueueOptions.html +12 -6
  132. package/docs/types/RBTreeOptions.html +12 -6
  133. package/docs/types/RecursiveAVLTreeNode.html +12 -6
  134. package/docs/types/RecursiveBSTNode.html +12 -6
  135. package/docs/types/RecursiveBinaryTreeNode.html +12 -6
  136. package/docs/types/RecursiveTreeMultiSetNode.html +12 -6
  137. package/docs/types/SegmentTreeNodeVal.html +12 -6
  138. package/docs/types/TopologicalStatus.html +12 -6
  139. package/docs/types/TreeMultiSetOptions.html +12 -6
  140. package/docs/types/Turning.html +12 -6
  141. package/docs/types/VertexId.html +12 -6
  142. package/package.json +2 -2
  143. package/docs/interfaces/IBinaryTree.html +0 -189
@@ -5,17 +5,26 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { AbstractRecursiveBinaryTreeNode, AbstractResultsByProperty, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../types';
8
+ import type { AbstractBinaryTreeNodeProperties, AbstractRecursiveBinaryTreeNode, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../types';
9
9
  import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../types';
10
- import { IBinaryTree, IBinaryTreeNode } from '../interfaces';
11
- export declare abstract class AbstractBinaryTreeNode<T, FAMILY extends AbstractBinaryTreeNode<T, FAMILY> = AbstractRecursiveBinaryTreeNode<T>> implements IBinaryTreeNode<T, FAMILY> {
12
- constructor(id: BinaryTreeNodeId, val: T, count?: number);
10
+ import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../interfaces';
11
+ export declare abstract class AbstractBinaryTreeNode<T = number, FAMILY extends AbstractBinaryTreeNode<T, FAMILY> = AbstractRecursiveBinaryTreeNode<T>> implements IAbstractBinaryTreeNode<T, FAMILY> {
12
+ /**
13
+ * The constructor function initializes a BinaryTreeNode object with an id, value, and count.
14
+ * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
15
+ * for the binary tree node.
16
+ * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value of the binary
17
+ * tree node. If no value is provided, it will be `undefined`.
18
+ * @param {number} [count] - The `count` parameter is an optional parameter that represents the number of times the
19
+ * value `val` appears in the binary tree node. If the `count` parameter is not provided, it defaults to 1.
20
+ */
21
+ constructor(id: BinaryTreeNodeId, val?: T, count?: number);
13
22
  private _id;
14
23
  get id(): BinaryTreeNodeId;
15
24
  set id(v: BinaryTreeNodeId);
16
25
  private _val;
17
- get val(): T;
18
- set val(v: T);
26
+ get val(): T | undefined;
27
+ set val(value: T | undefined);
19
28
  private _left?;
20
29
  get left(): FAMILY | null | undefined;
21
30
  set left(v: FAMILY | null | undefined);
@@ -34,11 +43,21 @@ export declare abstract class AbstractBinaryTreeNode<T, FAMILY extends AbstractB
34
43
  private _height;
35
44
  get height(): number;
36
45
  set height(v: number);
37
- abstract _createNode(id: BinaryTreeNodeId, val: T | null, count?: number): FAMILY | null;
46
+ abstract createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
47
+ /**
48
+ * The function swaps the location of two nodes in a binary tree.
49
+ * @param {FAMILY} swapNode - The `swapNode` parameter is of type `FAMILY`, which represents a node in a family tree.
50
+ * @returns the `swapNode` object after swapping its properties with the properties of `this` object.
51
+ */
38
52
  swapLocation(swapNode: FAMILY): FAMILY;
53
+ /**
54
+ * The `clone` function returns a new instance of the `FAMILY` class with the same `id`, `val`, and `count` properties.
55
+ * @returns The `clone()` method is returning a new instance of the `FAMILY` class with the same `id`, `val`, and
56
+ * `count` values as the current instance.
57
+ */
39
58
  clone(): FAMILY | null;
40
59
  }
41
- export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N> = AbstractBinaryTreeNode<number>> implements IBinaryTree<N> {
60
+ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N> = AbstractBinaryTreeNode<number>> implements IAbstractBinaryTree<N> {
42
61
  /**
43
62
  * The protected constructor initializes the options for an abstract binary tree.
44
63
  * @param {AbstractBinaryTreeOptions} [options] - An optional object that contains configuration options for the binary
@@ -69,7 +88,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
69
88
  get size(): number;
70
89
  private _count;
71
90
  get count(): number;
72
- abstract _createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
91
+ abstract createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
73
92
  /**
74
93
  * The clear function resets the state of an object by setting its properties to their initial values.
75
94
  */
@@ -92,12 +111,13 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
92
111
  */
93
112
  add(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null | undefined;
94
113
  /**
95
- * The function inserts a new node into a binary tree as the left or right child of a given parent node.
96
- * @param {N | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
97
- * `null`. It represents the node that needs to be inserted into the binary tree.
98
- * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
99
- * will be inserted as a child.
100
- * @returns The method returns the newly inserted node, either as the left child or the right child of the parent node.
114
+ * The function adds a new node to a binary tree as the left or right child of a given parent node.
115
+ * @param {N | null} newNode - The `newNode` parameter represents the node that you want to add to the tree. It can be
116
+ * either a node object (`N`) or `null`.
117
+ * @param {N} parent - The `parent` parameter represents the parent node to which the new node will be added as a
118
+ * child.
119
+ * @returns either the left or right child node that was added to the parent node. It can also return `null` or
120
+ * `undefined` in certain cases.
101
121
  */
102
122
  addTo(newNode: N | null, parent: N): N | null | undefined;
103
123
  /**
@@ -172,7 +192,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
172
192
  * function will stop traversing the tree and return the first matching node. If `
173
193
  * @returns The function `getNodes` returns an array of `N | null | undefined` objects.
174
194
  */
175
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): (N | null | undefined)[];
195
+ getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
176
196
  /**
177
197
  * The function checks if a binary tree node has a specific property or if any node in the tree has a specific
178
198
  * property.
@@ -206,12 +226,16 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
206
226
  getRightMost(): N | null;
207
227
  getRightMost(node: N): N;
208
228
  /**
209
- * The `isBST` function checks if a binary tree is a binary search tree.
210
- * @param {N | null} [node] - The `node` parameter is an optional parameter of type `N
211
- * | null`. It represents the root node of the binary search tree (BST) that we want to check for validity. If no node
212
- * is provided, the function will default to using the root node of the BST instance that
213
- * @returns The `isBST` function returns a boolean value. It returns `true` if the binary tree is a valid binary search
214
- * tree, and `false` otherwise.
229
+ * The function `isBSTByRooted` checks if a binary tree is a binary search tree (BST) by rooted traversal.
230
+ * @param {N | null} node - The `node` parameter represents the root node of a binary search tree (BST).
231
+ * @returns a boolean value.
232
+ */
233
+ isBSTByRooted(node: N | null): boolean;
234
+ /**
235
+ * The function checks if a binary tree is a binary search tree.
236
+ * @param {N | null} [node] - The `node` parameter is of type `N` or `null`. It represents the root node of a binary
237
+ * search tree (BST).
238
+ * @returns a boolean value.
215
239
  */
216
240
  isBST(node?: N | null): boolean;
217
241
  /**
@@ -327,7 +351,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
327
351
  * to 'id'.
328
352
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is an optional parameter that
329
353
  * can accept a value of type `NodeOrPropertyName`.
330
- * @returns The method returns an object of type `AbstractResultsByProperty<T>`.
354
+ * @returns The method returns an object of type `AbstractBinaryTreeNodeProperties<T>`.
331
355
  */
332
- protected _getResultByPropertyName(nodeOrPropertyName?: NodeOrPropertyName): AbstractResultsByProperty<N>;
356
+ protected _getResultByPropertyName(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
333
357
  }
@@ -38,6 +38,15 @@ exports.AbstractBinaryTree = exports.AbstractBinaryTreeNode = void 0;
38
38
  var utils_1 = require("../../utils");
39
39
  var types_1 = require("../types");
40
40
  var AbstractBinaryTreeNode = /** @class */ (function () {
41
+ /**
42
+ * The constructor function initializes a BinaryTreeNode object with an id, value, and count.
43
+ * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
44
+ * for the binary tree node.
45
+ * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value of the binary
46
+ * tree node. If no value is provided, it will be `undefined`.
47
+ * @param {number} [count] - The `count` parameter is an optional parameter that represents the number of times the
48
+ * value `val` appears in the binary tree node. If the `count` parameter is not provided, it defaults to 1.
49
+ */
41
50
  function AbstractBinaryTreeNode(id, val, count) {
42
51
  this._familyPosition = types_1.FamilyPosition.ROOT;
43
52
  this._count = 1;
@@ -60,8 +69,8 @@ var AbstractBinaryTreeNode = /** @class */ (function () {
60
69
  get: function () {
61
70
  return this._val;
62
71
  },
63
- set: function (v) {
64
- this._val = v;
72
+ set: function (value) {
73
+ this._val = value;
65
74
  },
66
75
  enumerable: false,
67
76
  configurable: true
@@ -134,9 +143,14 @@ var AbstractBinaryTreeNode = /** @class */ (function () {
134
143
  enumerable: false,
135
144
  configurable: true
136
145
  });
146
+ /**
147
+ * The function swaps the location of two nodes in a binary tree.
148
+ * @param {FAMILY} swapNode - The `swapNode` parameter is of type `FAMILY`, which represents a node in a family tree.
149
+ * @returns the `swapNode` object after swapping its properties with the properties of `this` object.
150
+ */
137
151
  AbstractBinaryTreeNode.prototype.swapLocation = function (swapNode) {
138
152
  var val = swapNode.val, count = swapNode.count, height = swapNode.height;
139
- var tempNode = this._createNode(swapNode.id, val);
153
+ var tempNode = this.createNode(swapNode.id, val);
140
154
  if (tempNode instanceof AbstractBinaryTreeNode) {
141
155
  tempNode.val = val;
142
156
  tempNode.count = count;
@@ -152,8 +166,13 @@ var AbstractBinaryTreeNode = /** @class */ (function () {
152
166
  }
153
167
  return swapNode;
154
168
  };
169
+ /**
170
+ * The `clone` function returns a new instance of the `FAMILY` class with the same `id`, `val`, and `count` properties.
171
+ * @returns The `clone()` method is returning a new instance of the `FAMILY` class with the same `id`, `val`, and
172
+ * `count` values as the current instance.
173
+ */
155
174
  AbstractBinaryTreeNode.prototype.clone = function () {
156
- return this._createNode(this.id, this.val, this.count);
175
+ return this.createNode(this.id, this.val, this.count);
157
176
  };
158
177
  return AbstractBinaryTreeNode;
159
178
  }());
@@ -317,7 +336,7 @@ var AbstractBinaryTree = /** @class */ (function () {
317
336
  return;
318
337
  };
319
338
  var inserted;
320
- var needInsert = val !== null ? this._createNode(id, val !== null && val !== void 0 ? val : id, count) : null;
339
+ var needInsert = val !== null ? this.createNode(id, val !== null && val !== void 0 ? val : id, count) : null;
321
340
  var existNode = val !== null ? this.get(id, 'id') : null;
322
341
  if (this.root) {
323
342
  if (existNode) {
@@ -333,7 +352,7 @@ var AbstractBinaryTree = /** @class */ (function () {
333
352
  }
334
353
  }
335
354
  else {
336
- this._setRoot(val !== null ? this._createNode(id, val !== null && val !== void 0 ? val : id, count) : null);
355
+ this._setRoot(val !== null ? this.createNode(id, val !== null && val !== void 0 ? val : id, count) : null);
337
356
  if (needInsert !== null) {
338
357
  this._setSize(1);
339
358
  this._setCount(count);
@@ -343,12 +362,13 @@ var AbstractBinaryTree = /** @class */ (function () {
343
362
  return inserted;
344
363
  };
345
364
  /**
346
- * The function inserts a new node into a binary tree as the left or right child of a given parent node.
347
- * @param {N | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
348
- * `null`. It represents the node that needs to be inserted into the binary tree.
349
- * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
350
- * will be inserted as a child.
351
- * @returns The method returns the newly inserted node, either as the left child or the right child of the parent node.
365
+ * The function adds a new node to a binary tree as the left or right child of a given parent node.
366
+ * @param {N | null} newNode - The `newNode` parameter represents the node that you want to add to the tree. It can be
367
+ * either a node object (`N`) or `null`.
368
+ * @param {N} parent - The `parent` parameter represents the parent node to which the new node will be added as a
369
+ * child.
370
+ * @returns either the left or right child node that was added to the parent node. It can also return `null` or
371
+ * `undefined` in certain cases.
352
372
  */
353
373
  AbstractBinaryTree.prototype.addTo = function (newNode, parent) {
354
374
  var _a, _b;
@@ -802,15 +822,11 @@ var AbstractBinaryTree = /** @class */ (function () {
802
822
  }
803
823
  };
804
824
  /**
805
- * The `isBST` function checks if a binary tree is a binary search tree.
806
- * @param {N | null} [node] - The `node` parameter is an optional parameter of type `N
807
- * | null`. It represents the root node of the binary search tree (BST) that we want to check for validity. If no node
808
- * is provided, the function will default to using the root node of the BST instance that
809
- * @returns The `isBST` function returns a boolean value. It returns `true` if the binary tree is a valid binary search
810
- * tree, and `false` otherwise.
825
+ * The function `isBSTByRooted` checks if a binary tree is a binary search tree (BST) by rooted traversal.
826
+ * @param {N | null} node - The `node` parameter represents the root node of a binary search tree (BST).
827
+ * @returns a boolean value.
811
828
  */
812
- AbstractBinaryTree.prototype.isBST = function (node) {
813
- node = node !== null && node !== void 0 ? node : this.root;
829
+ AbstractBinaryTree.prototype.isBSTByRooted = function (node) {
814
830
  if (!node)
815
831
  return true;
816
832
  if (this._loopType === types_1.LoopType.RECURSIVE) {
@@ -840,6 +856,15 @@ var AbstractBinaryTree = /** @class */ (function () {
840
856
  return true;
841
857
  }
842
858
  };
859
+ /**
860
+ * The function checks if a binary tree is a binary search tree.
861
+ * @param {N | null} [node] - The `node` parameter is of type `N` or `null`. It represents the root node of a binary
862
+ * search tree (BST).
863
+ * @returns a boolean value.
864
+ */
865
+ AbstractBinaryTree.prototype.isBST = function (node) {
866
+ return this.isBSTByRooted(this.root);
867
+ };
843
868
  /**
844
869
  * The function calculates the size and count of a subtree in a binary tree using either recursive or iterative
845
870
  * traversal.
@@ -981,7 +1006,7 @@ var AbstractBinaryTree = /** @class */ (function () {
981
1006
  * represents either a node or a property name. If a node is provided, the breadth-first search algorithm will be
982
1007
  * performed starting from that node. If a property name is provided, the breadth-first search algorithm will be
983
1008
  * performed starting from the root node
984
- * @returns an object of type `AbstractResultsByProperty<N>`.
1009
+ * @returns an object of type `AbstractBinaryTreeNodeProperties<N>`.
985
1010
  */
986
1011
  AbstractBinaryTree.prototype.BFS = function (nodeOrPropertyName) {
987
1012
  nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : 'id';
@@ -1009,7 +1034,7 @@ var AbstractBinaryTree = /** @class */ (function () {
1009
1034
  * either the name of a property in the `BinaryTreeNode` object or the value of the `id` property in the
1010
1035
  * `BinaryTreeNode` object. This parameter is used to accumulate the results based on the specified property name. If
1011
1036
  * no value
1012
- * @returns an object of type `AbstractResultsByProperty<N>`.
1037
+ * @returns an object of type `AbstractBinaryTreeNodeProperties<N>`.
1013
1038
  */
1014
1039
  AbstractBinaryTree.prototype.DFS = function (pattern, nodeOrPropertyName) {
1015
1040
  var _this = this;
@@ -1103,7 +1128,7 @@ var AbstractBinaryTree = /** @class */ (function () {
1103
1128
  * can be either a `BinaryTreeNode` property name or the string `'id'`. If a property name is provided, the function
1104
1129
  * will accumulate results based on that property. If no property name is provided, the function will default to
1105
1130
  * accumulating results
1106
- * @returns The function `levelIterative` returns an object of type `AbstractResultsByProperty<N>`.
1131
+ * @returns The function `levelIterative` returns an object of type `AbstractBinaryTreeNodeProperties<N>`.
1107
1132
  */
1108
1133
  AbstractBinaryTree.prototype.levelIterative = function (node, nodeOrPropertyName) {
1109
1134
  nodeOrPropertyName = nodeOrPropertyName || 'id';
@@ -1133,7 +1158,7 @@ var AbstractBinaryTree = /** @class */ (function () {
1133
1158
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that
1134
1159
  * specifies the property of the `BinaryTreeNode` object to collect at each level. It can be one of the following
1135
1160
  * values:
1136
- * @returns The function `listLevels` returns a 2D array of `AbstractResultByProperty<N>` objects.
1161
+ * @returns The function `listLevels` returns a 2D array of `AbstractBinaryTreeNodeProperty<N>` objects.
1137
1162
  */
1138
1163
  AbstractBinaryTree.prototype.listLevels = function (node, nodeOrPropertyName) {
1139
1164
  nodeOrPropertyName = nodeOrPropertyName || 'id';
@@ -1217,7 +1242,7 @@ var AbstractBinaryTree = /** @class */ (function () {
1217
1242
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is used to specify the
1218
1243
  * property of the nodes that you want to retrieve in the results. It can be either the node itself or the name of the
1219
1244
  * property. If not provided, it defaults to `'id'`.
1220
- * @returns The function `morris` returns an object of type `AbstractResultsByProperty<N>`.
1245
+ * @returns The function `morris` returns an object of type `AbstractBinaryTreeNodeProperties<N>`.
1221
1246
  */
1222
1247
  AbstractBinaryTree.prototype.morris = function (pattern, nodeOrPropertyName) {
1223
1248
  var _this = this;
@@ -1433,7 +1458,7 @@ var AbstractBinaryTree = /** @class */ (function () {
1433
1458
  * to 'id'.
1434
1459
  * @param {NodeOrPropertyName} [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is an optional parameter that
1435
1460
  * can accept a value of type `NodeOrPropertyName`.
1436
- * @returns The method returns an object of type `AbstractResultsByProperty<T>`.
1461
+ * @returns The method returns an object of type `AbstractBinaryTreeNodeProperties<T>`.
1437
1462
  */
1438
1463
  AbstractBinaryTree.prototype._getResultByPropertyName = function (nodeOrPropertyName) {
1439
1464
  nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : 'id';
@@ -7,12 +7,13 @@
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
9
  import type { AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId, RecursiveAVLTreeNode } from '../types';
10
- import { IBinaryTreeNode } from '../interfaces';
11
- export declare class AVLTreeNode<T, FAMILY extends AVLTreeNode<T, FAMILY> = RecursiveAVLTreeNode<T>> extends BSTNode<T, FAMILY> implements IBinaryTreeNode<T, FAMILY> {
10
+ import { IAVLTree, IAVLTreeNode } from '../interfaces';
11
+ export declare class AVLTreeNode<T, FAMILY extends AVLTreeNode<T, FAMILY> = RecursiveAVLTreeNode<T>> extends BSTNode<T, FAMILY> implements IAVLTreeNode<T, FAMILY> {
12
+ createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
12
13
  }
13
- export declare class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode<number>> extends BST<N> {
14
+ export declare class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode<number>> extends BST<N> implements IAVLTree<N> {
14
15
  constructor(options?: AVLTreeOptions);
15
- _createNode(id: BinaryTreeNodeId, val: N['val'], count?: number): N;
16
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
16
17
  /**
17
18
  * The function overrides the add method of a Binary Search Tree to insert a node with a given id and value, and then
18
19
  * balances the tree.
@@ -40,6 +40,9 @@ var AVLTreeNode = /** @class */ (function (_super) {
40
40
  function AVLTreeNode() {
41
41
  return _super !== null && _super.apply(this, arguments) || this;
42
42
  }
43
+ AVLTreeNode.prototype.createNode = function (id, val, count) {
44
+ return new AVLTreeNode(id, (val === undefined ? id : val), count);
45
+ };
43
46
  return AVLTreeNode;
44
47
  }(bst_1.BSTNode));
45
48
  exports.AVLTreeNode = AVLTreeNode;
@@ -48,9 +51,8 @@ var AVLTree = /** @class */ (function (_super) {
48
51
  function AVLTree(options) {
49
52
  return _super.call(this, options) || this;
50
53
  }
51
- AVLTree.prototype._createNode = function (id, val, count) {
52
- var node = new AVLTreeNode(id, val, count);
53
- return node;
54
+ AVLTree.prototype.createNode = function (id, val, count) {
55
+ return new AVLTreeNode(id, (val === undefined ? id : val), count);
54
56
  };
55
57
  /**
56
58
  * The function overrides the add method of a Binary Search Tree to insert a node with a given id and value, and then
@@ -7,10 +7,20 @@
7
7
  */
8
8
  import type { BinaryTreeNodeId, RecursiveBinaryTreeNode } from '../types';
9
9
  import { BinaryTreeOptions } from '../types';
10
- import { IBinaryTree, IBinaryTreeNode } from '../interfaces';
11
10
  import { AbstractBinaryTree, AbstractBinaryTreeNode } from './abstract-binary-tree';
11
+ import { IBinaryTree, IBinaryTreeNode } from '../interfaces/binary-tree';
12
12
  export declare class BinaryTreeNode<T = number, FAMILY extends BinaryTreeNode<T, FAMILY> = RecursiveBinaryTreeNode<T>> extends AbstractBinaryTreeNode<T, FAMILY> implements IBinaryTreeNode<T, FAMILY> {
13
- _createNode(id: BinaryTreeNodeId, val: T | null, count?: number): FAMILY | null;
13
+ /**
14
+ * The function creates a new binary tree node with an optional value and count, and returns it as a specified type.
15
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
16
+ * `BinaryTreeNodeId`, which could be a string or a number depending on how you want to identify your nodes.
17
+ * @param {T} [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the
18
+ * value stored in the node.
19
+ * @param {number} [count] - The count parameter is an optional parameter that represents the number of times the value
20
+ * appears in the binary tree node.
21
+ * @returns a new instance of the BinaryTreeNode class, casted as the FAMILY type.
22
+ */
23
+ createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
14
24
  }
15
25
  export declare class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode> extends AbstractBinaryTree<N> implements IBinaryTree<N> {
16
26
  /**
@@ -30,5 +40,5 @@ export declare class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTr
30
40
  * of occurrences of the value in the binary tree node. If not provided, the default value is `undefined`.
31
41
  * @returns a BinaryTreeNode object if the value is not null, otherwise it returns null.
32
42
  */
33
- _createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
43
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
34
44
  }
@@ -29,8 +29,18 @@ var BinaryTreeNode = /** @class */ (function (_super) {
29
29
  function BinaryTreeNode() {
30
30
  return _super !== null && _super.apply(this, arguments) || this;
31
31
  }
32
- BinaryTreeNode.prototype._createNode = function (id, val, count) {
33
- return val !== null ? new BinaryTreeNode(id, val, count) : null;
32
+ /**
33
+ * The function creates a new binary tree node with an optional value and count, and returns it as a specified type.
34
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
35
+ * `BinaryTreeNodeId`, which could be a string or a number depending on how you want to identify your nodes.
36
+ * @param {T} [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the
37
+ * value stored in the node.
38
+ * @param {number} [count] - The count parameter is an optional parameter that represents the number of times the value
39
+ * appears in the binary tree node.
40
+ * @returns a new instance of the BinaryTreeNode class, casted as the FAMILY type.
41
+ */
42
+ BinaryTreeNode.prototype.createNode = function (id, val, count) {
43
+ return new BinaryTreeNode(id, (val === undefined ? id : val), count);
34
44
  };
35
45
  return BinaryTreeNode;
36
46
  }(abstract_binary_tree_1.AbstractBinaryTreeNode));
@@ -56,9 +66,8 @@ var BinaryTree = /** @class */ (function (_super) {
56
66
  * of occurrences of the value in the binary tree node. If not provided, the default value is `undefined`.
57
67
  * @returns a BinaryTreeNode object if the value is not null, otherwise it returns null.
58
68
  */
59
- BinaryTree.prototype._createNode = function (id, val, count) {
60
- var node = new BinaryTreeNode(id, val, count);
61
- return node;
69
+ BinaryTree.prototype.createNode = function (id, val, count) {
70
+ return new BinaryTreeNode(id, val === undefined ? id : val, count);
62
71
  };
63
72
  return BinaryTree;
64
73
  }(abstract_binary_tree_1.AbstractBinaryTree));
@@ -8,16 +8,37 @@
8
8
  import type { BinaryTreeNodeId, BinaryTreeNodePropertyName, BSTComparator, RecursiveBSTNode } from '../types';
9
9
  import { BinaryTreeDeletedResult, BSTOptions, CP } from '../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
- import { IBinaryTree, IBinaryTreeNode } from '../interfaces';
12
- export declare class BSTNode<T, FAMILY extends BSTNode<T, FAMILY> = RecursiveBSTNode<T>> extends BinaryTreeNode<T, FAMILY> implements IBinaryTreeNode<T, FAMILY> {
11
+ import { IBST, IBSTNode } from '../interfaces';
12
+ export declare class BSTNode<T, FAMILY extends BSTNode<T, FAMILY> = RecursiveBSTNode<T>> extends BinaryTreeNode<T, FAMILY> implements IBSTNode<T, FAMILY> {
13
+ /**
14
+ * The function creates a new binary search tree node with the specified id, value, and count.
15
+ * @param {BinaryTreeNodeId} id - The id parameter is the identifier for the binary tree node. It is used to uniquely
16
+ * identify each node in the tree.
17
+ * @param {T} [val] - The "val" parameter represents the value that will be stored in the binary tree node. It is an
18
+ * optional parameter, meaning it can be omitted when calling the "createNode" function.
19
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of the value in the binary
20
+ * search tree node. It is an optional parameter, so it can be omitted when calling the `createNode` method.
21
+ * @returns The method is returning a new instance of the BSTNode class, casted as the FAMILY type.
22
+ */
23
+ createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
13
24
  }
14
- export declare class BST<N extends BSTNode<N['val'], N> = BSTNode<number>> extends BinaryTree<N> implements IBinaryTree<N> {
25
+ export declare class BST<N extends BSTNode<N['val'], N> = BSTNode<number>> extends BinaryTree<N> implements IBST<N> {
15
26
  /**
16
27
  * The constructor function accepts an optional options object and sets the comparator property if provided.
17
28
  * @param [options] - An optional object that can contain the following properties:
18
29
  */
19
30
  constructor(options?: BSTOptions);
20
- _createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
31
+ /**
32
+ * The function creates a new binary search tree node with the given id, value, and count.
33
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
34
+ * `BinaryTreeNodeId`.
35
+ * @param {N['val'] | null} [val] - The `val` parameter is the value that will be stored in the node. It can be of any
36
+ * type `N['val']` or `null`.
37
+ * @param {number} [count] - The `count` parameter is an optional parameter that represents the number of occurrences
38
+ * of a particular value in the binary search tree node.
39
+ * @returns a new instance of the BSTNode class, casted as type N.
40
+ */
41
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
21
42
  /**
22
43
  * The `add` function inserts a new node into a binary search tree, updating the count and value of an existing node if
23
44
  * the ID matches, and returns the inserted node.
@@ -49,7 +70,7 @@ export declare class BST<N extends BSTNode<N['val'], N> = BSTNode<number>> exten
49
70
  * greater than, it returns the ID of the leftmost node. Otherwise, it also returns the ID of the rightmost node. If
50
71
  * there are no nodes in
51
72
  */
52
- lastKey(): number;
73
+ lastKey(): BinaryTreeNodeId;
53
74
  /**
54
75
  * The `remove` function in this TypeScript code removes a node from a binary search tree and returns information about
55
76
  * the deleted node and any nodes that need to be balanced.
@@ -39,6 +39,19 @@ var BSTNode = /** @class */ (function (_super) {
39
39
  function BSTNode() {
40
40
  return _super !== null && _super.apply(this, arguments) || this;
41
41
  }
42
+ /**
43
+ * The function creates a new binary search tree node with the specified id, value, and count.
44
+ * @param {BinaryTreeNodeId} id - The id parameter is the identifier for the binary tree node. It is used to uniquely
45
+ * identify each node in the tree.
46
+ * @param {T} [val] - The "val" parameter represents the value that will be stored in the binary tree node. It is an
47
+ * optional parameter, meaning it can be omitted when calling the "createNode" function.
48
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of the value in the binary
49
+ * search tree node. It is an optional parameter, so it can be omitted when calling the `createNode` method.
50
+ * @returns The method is returning a new instance of the BSTNode class, casted as the FAMILY type.
51
+ */
52
+ BSTNode.prototype.createNode = function (id, val, count) {
53
+ return new BSTNode(id, (val === undefined ? id : val), count);
54
+ };
42
55
  return BSTNode;
43
56
  }(binary_tree_1.BinaryTreeNode));
44
57
  exports.BSTNode = BSTNode;
@@ -59,9 +72,18 @@ var BST = /** @class */ (function (_super) {
59
72
  }
60
73
  return _this;
61
74
  }
62
- BST.prototype._createNode = function (id, val, count) {
63
- var node = val !== null ? new BSTNode(id, val, count) : null;
64
- return node;
75
+ /**
76
+ * The function creates a new binary search tree node with the given id, value, and count.
77
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
78
+ * `BinaryTreeNodeId`.
79
+ * @param {N['val'] | null} [val] - The `val` parameter is the value that will be stored in the node. It can be of any
80
+ * type `N['val']` or `null`.
81
+ * @param {number} [count] - The `count` parameter is an optional parameter that represents the number of occurrences
82
+ * of a particular value in the binary search tree node.
83
+ * @returns a new instance of the BSTNode class, casted as type N.
84
+ */
85
+ BST.prototype.createNode = function (id, val, count) {
86
+ return new BSTNode(id, val === undefined ? id : val, count);
65
87
  };
66
88
  /**
67
89
  * The `add` function inserts a new node into a binary search tree, updating the count and value of an existing node if
@@ -78,7 +100,7 @@ var BST = /** @class */ (function (_super) {
78
100
  BST.prototype.add = function (id, val, count) {
79
101
  if (count === void 0) { count = 1; }
80
102
  var inserted = null;
81
- var newNode = this._createNode(id, val, count);
103
+ var newNode = this.createNode(id, val, count);
82
104
  if (this.root === null) {
83
105
  this._setRoot(newNode);
84
106
  this._setSize(this.size + 1);
@@ -1 +1,30 @@
1
- export {};
1
+ import { BinaryTreeNodeId, RBColor, RBTreeOptions } from '../types';
2
+ import { IRBTree, IRBTreeNode } from '../interfaces/rb-tree';
3
+ import { BST, BSTNode } from './bst';
4
+ export declare class RBTreeNode<T, FAMILY extends RBTreeNode<T, FAMILY>> extends BSTNode<T, FAMILY> implements IRBTreeNode<T, FAMILY> {
5
+ constructor(id: number, val: T, count?: number);
6
+ private _color;
7
+ get color(): RBColor;
8
+ set color(value: RBColor);
9
+ /**
10
+ * The function creates a new RBTreeNode with the given id, value, and count and returns it as a FAMILY object.
11
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is used to uniquely
12
+ * identify each node in the tree.
13
+ * @param {T | null} [val] - The "val" parameter represents the value to be stored in the node. It can be of type T
14
+ * (generic type) or null.
15
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of the value in the binary tree
16
+ * node.
17
+ * @returns The method is returning a new instance of the RBTreeNode class, casted as a FAMILY type.
18
+ */
19
+ createNode(id: BinaryTreeNodeId, val?: T | null, count?: number): FAMILY;
20
+ }
21
+ export declare class RBTree<N extends RBTreeNode<N['val'], N>> extends BST<N> implements IRBTree<N> {
22
+ constructor(options?: RBTreeOptions);
23
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
24
+ insert(id: number, val: N | null): void;
25
+ private leftRotate;
26
+ private rightRotate;
27
+ private insertFixup;
28
+ private deleteFixup;
29
+ private transplant;
30
+ }
@@ -15,19 +15,17 @@ var __extends = (this && this.__extends) || (function () {
15
15
  };
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var binary_tree_1 = require("./binary-tree");
18
+ exports.RBTree = exports.RBTreeNode = void 0;
19
19
  var types_1 = require("../types");
20
- var RBNode = /** @class */ (function (_super) {
21
- __extends(RBNode, _super);
22
- // override createNode(id: BinaryTreeNodeId, val: T | null, count?: number): RBNode<T> | null {
23
- // return val !== null ? new RBNode<T>(id, val, count) : null;
24
- // }
25
- function RBNode(id, val, count) {
20
+ var bst_1 = require("./bst");
21
+ var RBTreeNode = /** @class */ (function (_super) {
22
+ __extends(RBTreeNode, _super);
23
+ function RBTreeNode(id, val, count) {
26
24
  var _this = _super.call(this, id, val, count) || this;
27
25
  _this._color = types_1.RBColor.RED;
28
26
  return _this;
29
27
  }
30
- Object.defineProperty(RBNode.prototype, "color", {
28
+ Object.defineProperty(RBTreeNode.prototype, "color", {
31
29
  get: function () {
32
30
  return this._color;
33
31
  },
@@ -37,16 +35,30 @@ var RBNode = /** @class */ (function (_super) {
37
35
  enumerable: false,
38
36
  configurable: true
39
37
  });
40
- return RBNode;
41
- }(binary_tree_1.BinaryTreeNode));
38
+ /**
39
+ * The function creates a new RBTreeNode with the given id, value, and count and returns it as a FAMILY object.
40
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is used to uniquely
41
+ * identify each node in the tree.
42
+ * @param {T | null} [val] - The "val" parameter represents the value to be stored in the node. It can be of type T
43
+ * (generic type) or null.
44
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of the value in the binary tree
45
+ * node.
46
+ * @returns The method is returning a new instance of the RBTreeNode class, casted as a FAMILY type.
47
+ */
48
+ RBTreeNode.prototype.createNode = function (id, val, count) {
49
+ return new RBTreeNode(id, val, count);
50
+ };
51
+ return RBTreeNode;
52
+ }(bst_1.BSTNode));
53
+ exports.RBTreeNode = RBTreeNode;
42
54
  var RBTree = /** @class */ (function (_super) {
43
55
  __extends(RBTree, _super);
44
56
  function RBTree(options) {
45
57
  return _super.call(this, options) || this;
46
58
  }
47
- // override _createNode(id: BinaryTreeNodeId, val: N | null, count?: number): RBNode<N> | null {
48
- // return val !== null ? new RBNode<N>(id, val, count) : null;
49
- // }
59
+ RBTree.prototype.createNode = function (id, val, count) {
60
+ return new RBTreeNode(id, val, count);
61
+ };
50
62
  // private override _root: BinaryTreeNode<N> | null = null;
51
63
  //
52
64
  // override get root(): BinaryTreeNode<N> | null {
@@ -65,4 +77,5 @@ var RBTree = /** @class */ (function (_super) {
65
77
  RBTree.prototype.transplant = function (u, v) {
66
78
  };
67
79
  return RBTree;
68
- }(binary_tree_1.BinaryTree));
80
+ }(bst_1.BST));
81
+ exports.RBTree = RBTree;