data-structure-typed 1.12.11 → 1.15.0

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 (81) hide show
  1. package/README.md +278 -179
  2. package/dist/data-structures/binary-tree/avl-tree.d.ts +14 -5
  3. package/dist/data-structures/binary-tree/avl-tree.js +15 -6
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +11 -2
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.js +11 -2
  6. package/dist/data-structures/binary-tree/binary-tree.d.ts +72 -18
  7. package/dist/data-structures/binary-tree/binary-tree.js +139 -62
  8. package/dist/data-structures/binary-tree/bst.d.ts +92 -5
  9. package/dist/data-structures/binary-tree/bst.js +89 -5
  10. package/dist/data-structures/binary-tree/segment-tree.d.ts +70 -2
  11. package/dist/data-structures/binary-tree/segment-tree.js +86 -2
  12. package/dist/data-structures/binary-tree/tree-multiset.d.ts +34 -3
  13. package/dist/data-structures/binary-tree/tree-multiset.js +35 -4
  14. package/dist/data-structures/graph/abstract-graph.d.ts +45 -5
  15. package/dist/data-structures/graph/abstract-graph.js +59 -11
  16. package/dist/data-structures/graph/directed-graph.d.ts +26 -4
  17. package/dist/data-structures/graph/directed-graph.js +38 -39
  18. package/dist/data-structures/graph/undirected-graph.d.ts +23 -0
  19. package/dist/data-structures/graph/undirected-graph.js +41 -3
  20. package/dist/data-structures/hash/coordinate-map.d.ts +12 -3
  21. package/dist/data-structures/hash/coordinate-map.js +21 -2
  22. package/dist/data-structures/hash/coordinate-set.d.ts +12 -3
  23. package/dist/data-structures/hash/coordinate-set.js +21 -2
  24. package/dist/data-structures/heap/heap.d.ts +25 -6
  25. package/dist/data-structures/heap/heap.js +46 -8
  26. package/dist/data-structures/heap/max-heap.d.ts +5 -2
  27. package/dist/data-structures/heap/max-heap.js +5 -2
  28. package/dist/data-structures/heap/min-heap.d.ts +5 -2
  29. package/dist/data-structures/heap/min-heap.js +5 -2
  30. package/dist/data-structures/index.d.ts +1 -0
  31. package/dist/data-structures/index.js +1 -0
  32. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +32 -9
  33. package/dist/data-structures/linked-list/doubly-linked-list.js +75 -8
  34. package/dist/data-structures/linked-list/singly-linked-list.d.ts +267 -330
  35. package/dist/data-structures/linked-list/singly-linked-list.js +263 -275
  36. package/dist/data-structures/matrix/matrix.d.ts +5 -2
  37. package/dist/data-structures/matrix/matrix.js +5 -2
  38. package/dist/data-structures/matrix/matrix2d.d.ts +5 -2
  39. package/dist/data-structures/matrix/matrix2d.js +5 -2
  40. package/dist/data-structures/matrix/navigator.d.ts +5 -2
  41. package/dist/data-structures/matrix/vector2d.d.ts +5 -2
  42. package/dist/data-structures/matrix/vector2d.js +5 -2
  43. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +5 -2
  44. package/dist/data-structures/priority-queue/max-priority-queue.js +5 -2
  45. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +5 -2
  46. package/dist/data-structures/priority-queue/min-priority-queue.js +5 -2
  47. package/dist/data-structures/priority-queue/priority-queue.d.ts +14 -5
  48. package/dist/data-structures/priority-queue/priority-queue.js +20 -4
  49. package/dist/data-structures/queue/deque.d.ts +30 -16
  50. package/dist/data-structures/queue/deque.js +62 -12
  51. package/dist/data-structures/queue/queue.d.ts +4 -4
  52. package/dist/data-structures/queue/queue.js +4 -4
  53. package/dist/data-structures/stack/stack.d.ts +1 -1
  54. package/dist/data-structures/stack/stack.js +1 -1
  55. package/dist/data-structures/trie/trie.d.ts +6 -3
  56. package/dist/data-structures/trie/trie.js +7 -4
  57. package/dist/data-structures/types/abstract-graph.d.ts +2 -2
  58. package/dist/utils/index.d.ts +1 -0
  59. package/dist/utils/index.js +1 -0
  60. package/dist/utils/types/utils.d.ts +8 -10
  61. package/dist/utils/types/utils.js +0 -1
  62. package/dist/utils/utils.d.ts +18 -8
  63. package/dist/utils/utils.js +93 -47
  64. package/package.json +2 -2
  65. package/src/data-structures/binary-tree/aa-tree.ts +1 -1
  66. package/src/data-structures/binary-tree/binary-tree.ts +84 -14
  67. package/src/data-structures/binary-tree/segment-tree.ts +45 -13
  68. package/src/data-structures/graph/abstract-graph.ts +58 -15
  69. package/src/data-structures/graph/directed-graph.ts +14 -5
  70. package/src/data-structures/graph/undirected-graph.ts +23 -6
  71. package/src/data-structures/hash/coordinate-map.ts +13 -1
  72. package/src/data-structures/hash/coordinate-set.ts +13 -1
  73. package/src/data-structures/heap/heap.ts +31 -0
  74. package/src/data-structures/linked-list/doubly-linked-list.ts +68 -11
  75. package/src/data-structures/linked-list/singly-linked-list.ts +312 -334
  76. package/src/data-structures/priority-queue/priority-queue.ts +15 -2
  77. package/src/data-structures/queue/deque.ts +38 -8
  78. package/src/data-structures/types/abstract-graph.ts +3 -3
  79. package/tests/unit/data-structures/graph/directed-graph.test.ts +431 -8
  80. package/dist/utils/trampoline.d.ts +0 -14
  81. package/dist/utils/trampoline.js +0 -130
@@ -1,6 +1,9 @@
1
1
  /**
2
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
- * @license MIT
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
4
7
  */
5
8
  import type { BinaryTreeDeleted, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName, ResultsByProperty } from '../types';
6
9
  export declare enum FamilyPosition {
@@ -8,36 +11,74 @@ export declare enum FamilyPosition {
8
11
  left = 1,
9
12
  right = 2
10
13
  }
14
+ /**
15
+ * Enum representing different loop types.
16
+ *
17
+ * - `iterative`: Indicates the iterative loop type (with loops that use iterations).
18
+ * - `recursive`: Indicates the recursive loop type (with loops that call themselves).
19
+ */
11
20
  export declare enum LoopType {
12
21
  iterative = 1,
13
22
  recursive = 2
14
23
  }
15
24
  export declare class BinaryTreeNode<T> {
16
- constructor(id: BinaryTreeNodeId, val: T, count?: number);
17
25
  protected _id: BinaryTreeNodeId;
18
26
  get id(): BinaryTreeNodeId;
27
+ /**
28
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
29
+ */
30
+ getId(): BinaryTreeNodeId;
19
31
  set id(v: BinaryTreeNodeId);
20
32
  protected _val: T;
21
33
  get val(): T;
34
+ /**
35
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
36
+ */
37
+ getVal(): T;
22
38
  set val(v: T);
23
39
  protected _left?: BinaryTreeNode<T> | null;
24
40
  get left(): BinaryTreeNode<T> | null | undefined;
41
+ /**
42
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
43
+ */
44
+ getLeft(): BinaryTreeNode<T> | null | undefined;
25
45
  set left(v: BinaryTreeNode<T> | null | undefined);
26
46
  protected _right?: BinaryTreeNode<T> | null;
27
47
  get right(): BinaryTreeNode<T> | null | undefined;
48
+ /**
49
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
50
+ */
51
+ getRight(): BinaryTreeNode<T> | null | undefined;
28
52
  set right(v: BinaryTreeNode<T> | null | undefined);
29
53
  protected _parent: BinaryTreeNode<T> | null | undefined;
30
54
  get parent(): BinaryTreeNode<T> | null | undefined;
55
+ /**
56
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
57
+ */
58
+ getParent(): BinaryTreeNode<T> | null | undefined;
31
59
  set parent(v: BinaryTreeNode<T> | null | undefined);
32
60
  protected _familyPosition: FamilyPosition;
33
61
  get familyPosition(): FamilyPosition;
62
+ /**
63
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
64
+ */
65
+ getFamilyPosition(): FamilyPosition;
34
66
  set familyPosition(v: FamilyPosition);
35
67
  protected _count: number;
36
68
  get count(): number;
69
+ /**
70
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
71
+ */
72
+ getCount(): number;
37
73
  set count(v: number);
38
74
  protected _height: number;
39
75
  get height(): number;
76
+ /**
77
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
78
+ */
79
+ getHeight(): number;
40
80
  set height(v: number);
81
+ constructor(id: BinaryTreeNodeId, val: T, count?: number);
41
82
  swapLocation(swapNode: BinaryTreeNode<T>): BinaryTreeNode<T>;
42
83
  clone(): BinaryTreeNode<T>;
43
84
  }
@@ -63,12 +104,25 @@ export declare class BinaryTree<T> {
63
104
  });
64
105
  protected _root: BinaryTreeNode<T> | null;
65
106
  get root(): BinaryTreeNode<T> | null;
107
+ /**
108
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Getters (using the same name as the property) while utilizing separate method names for Setters.
109
+ * @returns The method is returning either a BinaryTreeNode object of type T or null.
110
+ */
111
+ getRoot(): BinaryTreeNode<T> | null;
66
112
  protected set root(v: BinaryTreeNode<T> | null);
67
113
  protected _size: number;
68
114
  get size(): number;
115
+ /**
116
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
117
+ */
118
+ getSize(): number;
69
119
  protected set size(v: number);
70
120
  protected _count: number;
71
121
  get count(): number;
122
+ /**
123
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
124
+ */
125
+ getCount(): number;
72
126
  protected set count(v: number);
73
127
  /**
74
128
  * The function creates a new binary tree node with the given id, value, and count, or returns null if the value is
@@ -93,34 +147,34 @@ export declare class BinaryTree<T> {
93
147
  */
94
148
  isEmpty(): boolean;
95
149
  /**
96
- * The function inserts a new node into a binary tree as the left or right child of a given parent node.
97
- * @param {BinaryTreeNode<T> | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
98
- * `null`. It represents the node that needs to be inserted into the binary tree.
99
- * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
100
- * will be inserted as a child.
101
- * @returns The method returns the newly inserted node, either as the left child or the right child of the parent node.
102
- */
103
- putTo(newNode: BinaryTreeNode<T> | null, parent: BinaryTreeNode<T>): BinaryTreeNode<T> | null | undefined;
104
- /**
105
- * The `put` function inserts a new node with a given ID and value into a binary tree, updating the count if the node
150
+ * The `add` function inserts a new node with a given ID and value into a binary tree, updating the count if the node
106
151
  * already exists.
107
152
  * @param {BinaryTreeNodeId} id - The id parameter is the identifier of the binary tree node. It is used to uniquely
108
153
  * identify each node in the binary tree.
109
154
  * @param {T} val - The value to be inserted into the binary tree.
110
155
  * @param {number} [count] - The `count` parameter is an optional parameter that specifies the number of times the
111
156
  * value should be inserted into the binary tree. If not provided, it defaults to 1.
112
- * @returns The function `put` returns a `BinaryTreeNode<T>` object if a new node is inserted, or `null` if no new node
157
+ * @returns The function `add` returns a `BinaryTreeNode<T>` object if a new node is inserted, or `null` if no new node
113
158
  * is inserted, or `undefined` if the insertion fails.
114
159
  */
115
- put(id: BinaryTreeNodeId, val: T, count?: number): BinaryTreeNode<T> | null | undefined;
160
+ add(id: BinaryTreeNodeId, val: T, count?: number): BinaryTreeNode<T> | null | undefined;
161
+ /**
162
+ * The function inserts a new node into a binary tree as the left or right child of a given parent node.
163
+ * @param {BinaryTreeNode<T> | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
164
+ * `null`. It represents the node that needs to be inserted into the binary tree.
165
+ * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
166
+ * will be inserted as a child.
167
+ * @returns The method returns the newly inserted node, either as the left child or the right child of the parent node.
168
+ */
169
+ addTo(newNode: BinaryTreeNode<T> | null, parent: BinaryTreeNode<T>): BinaryTreeNode<T> | null | undefined;
116
170
  /**
117
- * The `insertMany` function inserts multiple items into a binary tree and returns an array of the inserted nodes or
171
+ * The `addMany` function inserts multiple items into a binary tree and returns an array of the inserted nodes or
118
172
  * null/undefined values.
119
173
  * @param {T[] | BinaryTreeNode<T>[]} data - The `data` parameter can be either an array of elements of type `T` or an
120
174
  * array of `BinaryTreeNode<T>` objects.
121
- * @returns The function `insertMany` returns an array of `BinaryTreeNode<T>`, `null`, or `undefined` values.
175
+ * @returns The function `addMany` returns an array of `BinaryTreeNode<T>`, `null`, or `undefined` values.
122
176
  */
123
- insertMany(data: T[] | BinaryTreeNode<T>[]): (BinaryTreeNode<T> | null | undefined)[];
177
+ addMany(data: T[] | BinaryTreeNode<T>[]): (BinaryTreeNode<T> | null | undefined)[];
124
178
  /**
125
179
  * The `fill` function clears the current data and inserts new data, returning a boolean indicating if the insertion
126
180
  * was successful.
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  /**
3
- * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
4
- * @license MIT
3
+ * data-structure-typed
4
+ *
5
+ * @author Tyler Zeng
6
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
7
+ * @license MIT License
5
8
  */
6
9
  var __values = (this && this.__values) || function(o) {
7
10
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
@@ -32,13 +35,20 @@ var __read = (this && this.__read) || function (o, n) {
32
35
  };
33
36
  Object.defineProperty(exports, "__esModule", { value: true });
34
37
  exports.BinaryTree = exports.BinaryTreeNode = exports.LoopType = exports.FamilyPosition = void 0;
35
- var trampoline_1 = require("../../utils/trampoline");
38
+ var utils_1 = require("../../utils");
39
+ /* This enumeration defines the position of a node within a family tree composed of three associated nodes, where 'root' represents the root node of the family tree, 'left' represents the left child node, and 'right' represents the right child node. */
36
40
  var FamilyPosition;
37
41
  (function (FamilyPosition) {
38
42
  FamilyPosition[FamilyPosition["root"] = 0] = "root";
39
43
  FamilyPosition[FamilyPosition["left"] = 1] = "left";
40
44
  FamilyPosition[FamilyPosition["right"] = 2] = "right";
41
45
  })(FamilyPosition = exports.FamilyPosition || (exports.FamilyPosition = {}));
46
+ /**
47
+ * Enum representing different loop types.
48
+ *
49
+ * - `iterative`: Indicates the iterative loop type (with loops that use iterations).
50
+ * - `recursive`: Indicates the recursive loop type (with loops that call themselves).
51
+ */
42
52
  var LoopType;
43
53
  (function (LoopType) {
44
54
  LoopType[LoopType["iterative"] = 1] = "iterative";
@@ -63,6 +73,12 @@ var BinaryTreeNode = /** @class */ (function () {
63
73
  enumerable: false,
64
74
  configurable: true
65
75
  });
76
+ /**
77
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
78
+ */
79
+ BinaryTreeNode.prototype.getId = function () {
80
+ return this._id;
81
+ };
66
82
  Object.defineProperty(BinaryTreeNode.prototype, "val", {
67
83
  get: function () {
68
84
  return this._val;
@@ -73,6 +89,12 @@ var BinaryTreeNode = /** @class */ (function () {
73
89
  enumerable: false,
74
90
  configurable: true
75
91
  });
92
+ /**
93
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
94
+ */
95
+ BinaryTreeNode.prototype.getVal = function () {
96
+ return this._val;
97
+ };
76
98
  Object.defineProperty(BinaryTreeNode.prototype, "left", {
77
99
  get: function () {
78
100
  return this._left;
@@ -87,6 +109,12 @@ var BinaryTreeNode = /** @class */ (function () {
87
109
  enumerable: false,
88
110
  configurable: true
89
111
  });
112
+ /**
113
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
114
+ */
115
+ BinaryTreeNode.prototype.getLeft = function () {
116
+ return this._left;
117
+ };
90
118
  Object.defineProperty(BinaryTreeNode.prototype, "right", {
91
119
  get: function () {
92
120
  return this._right;
@@ -101,6 +129,12 @@ var BinaryTreeNode = /** @class */ (function () {
101
129
  enumerable: false,
102
130
  configurable: true
103
131
  });
132
+ /**
133
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
134
+ */
135
+ BinaryTreeNode.prototype.getRight = function () {
136
+ return this._right;
137
+ };
104
138
  Object.defineProperty(BinaryTreeNode.prototype, "parent", {
105
139
  get: function () {
106
140
  return this._parent;
@@ -111,6 +145,12 @@ var BinaryTreeNode = /** @class */ (function () {
111
145
  enumerable: false,
112
146
  configurable: true
113
147
  });
148
+ /**
149
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
150
+ */
151
+ BinaryTreeNode.prototype.getParent = function () {
152
+ return this._parent;
153
+ };
114
154
  Object.defineProperty(BinaryTreeNode.prototype, "familyPosition", {
115
155
  get: function () {
116
156
  return this._familyPosition;
@@ -121,6 +161,12 @@ var BinaryTreeNode = /** @class */ (function () {
121
161
  enumerable: false,
122
162
  configurable: true
123
163
  });
164
+ /**
165
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
166
+ */
167
+ BinaryTreeNode.prototype.getFamilyPosition = function () {
168
+ return this._familyPosition;
169
+ };
124
170
  Object.defineProperty(BinaryTreeNode.prototype, "count", {
125
171
  get: function () {
126
172
  return this._count;
@@ -131,6 +177,12 @@ var BinaryTreeNode = /** @class */ (function () {
131
177
  enumerable: false,
132
178
  configurable: true
133
179
  });
180
+ /**
181
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
182
+ */
183
+ BinaryTreeNode.prototype.getCount = function () {
184
+ return this._count;
185
+ };
134
186
  Object.defineProperty(BinaryTreeNode.prototype, "height", {
135
187
  get: function () {
136
188
  return this._height;
@@ -141,6 +193,12 @@ var BinaryTreeNode = /** @class */ (function () {
141
193
  enumerable: false,
142
194
  configurable: true
143
195
  });
196
+ /**
197
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
198
+ */
199
+ BinaryTreeNode.prototype.getHeight = function () {
200
+ return this._height;
201
+ };
144
202
  BinaryTreeNode.prototype.swapLocation = function (swapNode) {
145
203
  var val = swapNode.val, count = swapNode.count, height = swapNode.height;
146
204
  var tempNode = new BinaryTreeNode(swapNode.id, val);
@@ -203,6 +261,13 @@ var BinaryTree = /** @class */ (function () {
203
261
  enumerable: false,
204
262
  configurable: true
205
263
  });
264
+ /**
265
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Getters (using the same name as the property) while utilizing separate method names for Setters.
266
+ * @returns The method is returning either a BinaryTreeNode object of type T or null.
267
+ */
268
+ BinaryTree.prototype.getRoot = function () {
269
+ return this._root;
270
+ };
206
271
  Object.defineProperty(BinaryTree.prototype, "size", {
207
272
  get: function () {
208
273
  return this._size;
@@ -213,6 +278,12 @@ var BinaryTree = /** @class */ (function () {
213
278
  enumerable: false,
214
279
  configurable: true
215
280
  });
281
+ /**
282
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
283
+ */
284
+ BinaryTree.prototype.getSize = function () {
285
+ return this._size;
286
+ };
216
287
  Object.defineProperty(BinaryTree.prototype, "count", {
217
288
  get: function () {
218
289
  return this._count;
@@ -223,6 +294,12 @@ var BinaryTree = /** @class */ (function () {
223
294
  enumerable: false,
224
295
  configurable: true
225
296
  });
297
+ /**
298
+ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
299
+ */
300
+ BinaryTree.prototype.getCount = function () {
301
+ return this._count;
302
+ };
226
303
  /**
227
304
  * The function creates a new binary tree node with the given id, value, and count, or returns null if the value is
228
305
  * null.
@@ -255,60 +332,17 @@ var BinaryTree = /** @class */ (function () {
255
332
  return this.size === 0;
256
333
  };
257
334
  /**
258
- * The function inserts a new node into a binary tree as the left or right child of a given parent node.
259
- * @param {BinaryTreeNode<T> | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
260
- * `null`. It represents the node that needs to be inserted into the binary tree.
261
- * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
262
- * will be inserted as a child.
263
- * @returns The method returns the newly inserted node, either as the left child or the right child of the parent node.
264
- */
265
- BinaryTree.prototype.putTo = function (newNode, parent) {
266
- var _a, _b;
267
- if (parent) {
268
- if (parent.left === undefined) {
269
- if (newNode) {
270
- newNode.parent = parent;
271
- newNode.familyPosition = FamilyPosition.left;
272
- }
273
- parent.left = newNode;
274
- if (newNode !== null) {
275
- this.size++;
276
- this.count += (_a = newNode === null || newNode === void 0 ? void 0 : newNode.count) !== null && _a !== void 0 ? _a : 0;
277
- }
278
- return parent.left;
279
- }
280
- else if (parent.right === undefined) {
281
- if (newNode) {
282
- newNode.parent = parent;
283
- newNode.familyPosition = FamilyPosition.right;
284
- }
285
- parent.right = newNode;
286
- if (newNode !== null) {
287
- this.size++;
288
- this.count += (_b = newNode === null || newNode === void 0 ? void 0 : newNode.count) !== null && _b !== void 0 ? _b : 0;
289
- }
290
- return parent.right;
291
- }
292
- else {
293
- return;
294
- }
295
- }
296
- else {
297
- return;
298
- }
299
- };
300
- /**
301
- * The `put` function inserts a new node with a given ID and value into a binary tree, updating the count if the node
335
+ * The `add` function inserts a new node with a given ID and value into a binary tree, updating the count if the node
302
336
  * already exists.
303
337
  * @param {BinaryTreeNodeId} id - The id parameter is the identifier of the binary tree node. It is used to uniquely
304
338
  * identify each node in the binary tree.
305
339
  * @param {T} val - The value to be inserted into the binary tree.
306
340
  * @param {number} [count] - The `count` parameter is an optional parameter that specifies the number of times the
307
341
  * value should be inserted into the binary tree. If not provided, it defaults to 1.
308
- * @returns The function `put` returns a `BinaryTreeNode<T>` object if a new node is inserted, or `null` if no new node
342
+ * @returns The function `add` returns a `BinaryTreeNode<T>` object if a new node is inserted, or `null` if no new node
309
343
  * is inserted, or `undefined` if the insertion fails.
310
344
  */
311
- BinaryTree.prototype.put = function (id, val, count) {
345
+ BinaryTree.prototype.add = function (id, val, count) {
312
346
  var _this = this;
313
347
  count = count !== null && count !== void 0 ? count : 1;
314
348
  var _bfs = function (root, newNode) {
@@ -316,7 +350,7 @@ var BinaryTree = /** @class */ (function () {
316
350
  while (queue.length > 0) {
317
351
  var cur = queue.shift();
318
352
  if (cur) {
319
- var inserted_1 = _this.putTo(newNode, cur);
353
+ var inserted_1 = _this.addTo(newNode, cur);
320
354
  if (inserted_1 !== undefined)
321
355
  return inserted_1;
322
356
  if (cur.left)
@@ -356,13 +390,56 @@ var BinaryTree = /** @class */ (function () {
356
390
  return inserted;
357
391
  };
358
392
  /**
359
- * The `insertMany` function inserts multiple items into a binary tree and returns an array of the inserted nodes or
393
+ * The function inserts a new node into a binary tree as the left or right child of a given parent node.
394
+ * @param {BinaryTreeNode<T> | null} newNode - The `newNode` parameter is an instance of the `BinaryTreeNode` class or
395
+ * `null`. It represents the node that needs to be inserted into the binary tree.
396
+ * @param parent - The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node
397
+ * will be inserted as a child.
398
+ * @returns The method returns the newly inserted node, either as the left child or the right child of the parent node.
399
+ */
400
+ BinaryTree.prototype.addTo = function (newNode, parent) {
401
+ var _a, _b;
402
+ if (parent) {
403
+ if (parent.left === undefined) {
404
+ if (newNode) {
405
+ newNode.parent = parent;
406
+ newNode.familyPosition = FamilyPosition.left;
407
+ }
408
+ parent.left = newNode;
409
+ if (newNode !== null) {
410
+ this.size++;
411
+ this.count += (_a = newNode === null || newNode === void 0 ? void 0 : newNode.count) !== null && _a !== void 0 ? _a : 0;
412
+ }
413
+ return parent.left;
414
+ }
415
+ else if (parent.right === undefined) {
416
+ if (newNode) {
417
+ newNode.parent = parent;
418
+ newNode.familyPosition = FamilyPosition.right;
419
+ }
420
+ parent.right = newNode;
421
+ if (newNode !== null) {
422
+ this.size++;
423
+ this.count += (_b = newNode === null || newNode === void 0 ? void 0 : newNode.count) !== null && _b !== void 0 ? _b : 0;
424
+ }
425
+ return parent.right;
426
+ }
427
+ else {
428
+ return;
429
+ }
430
+ }
431
+ else {
432
+ return;
433
+ }
434
+ };
435
+ /**
436
+ * The `addMany` function inserts multiple items into a binary tree and returns an array of the inserted nodes or
360
437
  * null/undefined values.
361
438
  * @param {T[] | BinaryTreeNode<T>[]} data - The `data` parameter can be either an array of elements of type `T` or an
362
439
  * array of `BinaryTreeNode<T>` objects.
363
- * @returns The function `insertMany` returns an array of `BinaryTreeNode<T>`, `null`, or `undefined` values.
440
+ * @returns The function `addMany` returns an array of `BinaryTreeNode<T>`, `null`, or `undefined` values.
364
441
  */
365
- BinaryTree.prototype.insertMany = function (data) {
442
+ BinaryTree.prototype.addMany = function (data) {
366
443
  var e_1, _a, e_2, _b;
367
444
  var _c;
368
445
  var inserted = [];
@@ -387,33 +464,33 @@ var BinaryTree = /** @class */ (function () {
387
464
  var item = data_2_1.value;
388
465
  var count = this._isDuplicatedVal ? 1 : map.get(item);
389
466
  if (item instanceof BinaryTreeNode) {
390
- inserted.push(this.put(item.id, item.val, item.count));
467
+ inserted.push(this.add(item.id, item.val, item.count));
391
468
  }
392
469
  else if (typeof item === 'number' && !this._autoIncrementId) {
393
470
  if (!this._isDuplicatedVal) {
394
471
  if (map.get(item) !== undefined) {
395
- inserted.push(this.put(item, item, count));
472
+ inserted.push(this.add(item, item, count));
396
473
  map.delete(item);
397
474
  }
398
475
  }
399
476
  else {
400
- inserted.push(this.put(item, item, 1));
477
+ inserted.push(this.add(item, item, 1));
401
478
  }
402
479
  }
403
480
  else {
404
481
  if (item !== null) {
405
482
  if (!this._isDuplicatedVal) {
406
483
  if (map.get(item) !== undefined) {
407
- inserted.push(this.put(++this._maxId, item, count));
484
+ inserted.push(this.add(++this._maxId, item, count));
408
485
  map.delete(item);
409
486
  }
410
487
  }
411
488
  else {
412
- inserted.push(this.put(++this._maxId, item, 1));
489
+ inserted.push(this.add(++this._maxId, item, 1));
413
490
  }
414
491
  }
415
492
  else {
416
- inserted.push(this.put(Number.MAX_SAFE_INTEGER, item, 0));
493
+ inserted.push(this.add(Number.MAX_SAFE_INTEGER, item, 0));
417
494
  }
418
495
  }
419
496
  }
@@ -436,7 +513,7 @@ var BinaryTree = /** @class */ (function () {
436
513
  */
437
514
  BinaryTree.prototype.fill = function (data) {
438
515
  this.clear();
439
- return data.length === this.insertMany(data).length;
516
+ return data.length === this.addMany(data).length;
440
517
  };
441
518
  /**
442
519
  * The function removes a node from a binary tree and returns information about the deleted node.
@@ -718,7 +795,7 @@ var BinaryTree = /** @class */ (function () {
718
795
  }
719
796
  else {
720
797
  // Indirect implementation of iteration using tail recursion optimization
721
- var _traverse_3 = (0, trampoline_1.trampoline)(function (cur) {
798
+ var _traverse_3 = (0, utils_1.trampoline)(function (cur) {
722
799
  if (!cur.left)
723
800
  return cur;
724
801
  return _traverse_3.cont(cur.left);
@@ -748,7 +825,7 @@ var BinaryTree = /** @class */ (function () {
748
825
  }
749
826
  else {
750
827
  // Indirect implementation of iteration using tail recursion optimization
751
- var _traverse_5 = (0, trampoline_1.trampoline)(function (cur) {
828
+ var _traverse_5 = (0, utils_1.trampoline)(function (cur) {
752
829
  if (!cur.right)
753
830
  return cur;
754
831
  return _traverse_5.cont(cur.right);