min-heap-typed 1.50.2 → 1.50.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +6 -0
  2. package/dist/data-structures/binary-tree/avl-tree.d.ts +29 -1
  3. package/dist/data-structures/binary-tree/avl-tree.js +33 -1
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  6. package/dist/data-structures/binary-tree/binary-tree.d.ts +1 -1
  7. package/dist/data-structures/binary-tree/binary-tree.js +1 -1
  8. package/dist/data-structures/binary-tree/bst.d.ts +46 -13
  9. package/dist/data-structures/binary-tree/bst.js +46 -13
  10. package/dist/data-structures/binary-tree/rb-tree.d.ts +54 -2
  11. package/dist/data-structures/binary-tree/rb-tree.js +73 -15
  12. package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
  13. package/dist/data-structures/binary-tree/segment-tree.js +127 -10
  14. package/dist/data-structures/binary-tree/tree-multimap.d.ts +35 -2
  15. package/dist/data-structures/binary-tree/tree-multimap.js +38 -0
  16. package/dist/data-structures/graph/abstract-graph.d.ts +0 -78
  17. package/dist/data-structures/graph/abstract-graph.js +0 -189
  18. package/dist/data-structures/graph/directed-graph.d.ts +59 -0
  19. package/dist/data-structures/graph/directed-graph.js +105 -0
  20. package/dist/data-structures/graph/undirected-graph.d.ts +60 -7
  21. package/dist/data-structures/graph/undirected-graph.js +126 -18
  22. package/dist/data-structures/hash/hash-map.d.ts +143 -23
  23. package/dist/data-structures/hash/hash-map.js +196 -62
  24. package/dist/data-structures/heap/heap.d.ts +29 -19
  25. package/dist/data-structures/heap/heap.js +29 -20
  26. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  27. package/dist/data-structures/linked-list/doubly-linked-list.js +83 -25
  28. package/dist/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  29. package/dist/data-structures/linked-list/singly-linked-list.js +34 -3
  30. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  31. package/dist/data-structures/linked-list/skip-linked-list.js +2 -2
  32. package/dist/data-structures/matrix/matrix.d.ts +1 -1
  33. package/dist/data-structures/matrix/matrix.js +1 -1
  34. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  35. package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
  36. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  37. package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
  38. package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
  39. package/dist/data-structures/priority-queue/priority-queue.js +8 -0
  40. package/dist/data-structures/queue/deque.d.ts +95 -21
  41. package/dist/data-structures/queue/deque.js +100 -16
  42. package/dist/data-structures/queue/queue.d.ts +65 -45
  43. package/dist/data-structures/queue/queue.js +65 -45
  44. package/dist/data-structures/stack/stack.d.ts +36 -22
  45. package/dist/data-structures/stack/stack.js +36 -22
  46. package/dist/data-structures/tree/tree.d.ts +57 -3
  47. package/dist/data-structures/tree/tree.js +77 -11
  48. package/dist/data-structures/trie/trie.d.ts +100 -36
  49. package/dist/data-structures/trie/trie.js +115 -36
  50. package/package.json +2 -2
  51. package/src/data-structures/base/iterable-base.ts +12 -0
  52. package/src/data-structures/binary-tree/avl-tree.ts +37 -3
  53. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  54. package/src/data-structures/binary-tree/binary-tree.ts +1 -1
  55. package/src/data-structures/binary-tree/bst.ts +46 -13
  56. package/src/data-structures/binary-tree/rb-tree.ts +79 -18
  57. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  58. package/src/data-structures/binary-tree/tree-multimap.ts +42 -3
  59. package/src/data-structures/graph/abstract-graph.ts +0 -211
  60. package/src/data-structures/graph/directed-graph.ts +122 -0
  61. package/src/data-structures/graph/undirected-graph.ts +143 -19
  62. package/src/data-structures/hash/hash-map.ts +228 -76
  63. package/src/data-structures/heap/heap.ts +31 -20
  64. package/src/data-structures/linked-list/doubly-linked-list.ts +96 -29
  65. package/src/data-structures/linked-list/singly-linked-list.ts +42 -6
  66. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  67. package/src/data-structures/matrix/matrix.ts +1 -1
  68. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  69. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  70. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  71. package/src/data-structures/queue/deque.ts +118 -22
  72. package/src/data-structures/queue/queue.ts +68 -45
  73. package/src/data-structures/stack/stack.ts +39 -23
  74. package/src/data-structures/tree/tree.ts +89 -15
  75. package/src/data-structures/trie/trie.ts +131 -40
@@ -8,9 +8,57 @@ const base_1 = require("../base");
8
8
  */
9
9
  class TrieNode {
10
10
  constructor(key) {
11
- this.key = key;
12
- this.isEnd = false;
13
- this.children = new Map();
11
+ this._key = key;
12
+ this._isEnd = false;
13
+ this._children = new Map();
14
+ }
15
+ /**
16
+ * The function returns the value of the protected variable _key.
17
+ * @returns The value of the `_key` property, which is a string.
18
+ */
19
+ get key() {
20
+ return this._key;
21
+ }
22
+ /**
23
+ * The above function sets the value of a protected variable called "key".
24
+ * @param {string} value - The value parameter is a string that represents the value to be assigned
25
+ * to the key.
26
+ */
27
+ set key(value) {
28
+ this._key = value;
29
+ }
30
+ /**
31
+ * The function returns the children of a TrieNode as a Map.
32
+ * @returns The `children` property of the TrieNode object, which is a Map containing string keys and
33
+ * TrieNode values.
34
+ */
35
+ get children() {
36
+ return this._children;
37
+ }
38
+ /**
39
+ * The function sets the value of the `_children` property of a TrieNode object.
40
+ * @param value - The value parameter is a Map object that represents the children of a TrieNode. The
41
+ * keys of the map are strings, which represent the characters that are associated with each child
42
+ * TrieNode. The values of the map are TrieNode objects, which represent the child nodes of the
43
+ * current TrieNode.
44
+ */
45
+ set children(value) {
46
+ this._children = value;
47
+ }
48
+ /**
49
+ * The function returns a boolean value indicating whether a certain condition is met.
50
+ * @returns The method is returning a boolean value, specifically the value of the variable `_isEnd`.
51
+ */
52
+ get isEnd() {
53
+ return this._isEnd;
54
+ }
55
+ /**
56
+ * The function sets the value of the "_isEnd" property.
57
+ * @param {boolean} value - The value parameter is a boolean value that indicates whether the current
58
+ * state is the end state or not.
59
+ */
60
+ set isEnd(value) {
61
+ this._isEnd = value;
14
62
  }
15
63
  }
16
64
  exports.TrieNode = TrieNode;
@@ -57,9 +105,8 @@ class Trie extends base_1.IterableElementBase {
57
105
  return this._size;
58
106
  }
59
107
  /**
60
- * The caseSensitive function is a getter that returns the value of the private _caseSensitive property.
61
- *
62
- * @return The value of the _casesensitive private variable
108
+ * The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
109
+ * @return The value of the _caseSensitive protected variable
63
110
  */
64
111
  get caseSensitive() {
65
112
  return this._caseSensitive;
@@ -72,12 +119,12 @@ class Trie extends base_1.IterableElementBase {
72
119
  return this._root;
73
120
  }
74
121
  /**
75
- * Time Complexity: O(M), where M is the length of the word being added.
76
- * Space Complexity: O(M) - Each character in the word adds a TrieNode.
122
+ * Time Complexity: O(l), where l is the length of the word being added.
123
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
77
124
  */
78
125
  /**
79
- * Time Complexity: O(M), where M is the length of the word being added.
80
- * Space Complexity: O(M) - Each character in the word adds a TrieNode.
126
+ * Time Complexity: O(l), where l is the length of the word being added.
127
+ * Space Complexity: O(l) - Each character in the word adds a TrieNode.
81
128
  *
82
129
  * Add a word to the Trie structure.
83
130
  * @param {string} word - The word to add.
@@ -103,11 +150,11 @@ class Trie extends base_1.IterableElementBase {
103
150
  return isNewWord;
104
151
  }
105
152
  /**
106
- * Time Complexity: O(M), where M is the length of the input word.
153
+ * Time Complexity: O(l), where l is the length of the input word.
107
154
  * Space Complexity: O(1) - Constant space.
108
155
  */
109
156
  /**
110
- * Time Complexity: O(M), where M is the length of the input word.
157
+ * Time Complexity: O(l), where l is the length of the input word.
111
158
  * Space Complexity: O(1) - Constant space.
112
159
  *
113
160
  * Check if the Trie contains a given word.
@@ -126,6 +173,13 @@ class Trie extends base_1.IterableElementBase {
126
173
  return cur.isEnd;
127
174
  }
128
175
  /**
176
+ * Time Complexity: O(1)
177
+ * Space Complexity: O(1)
178
+ */
179
+ /**
180
+ * Time Complexity: O(1)
181
+ * Space Complexity: O(1)
182
+ *
129
183
  * The isEmpty function checks if the size of the queue is 0.
130
184
  * @return True if the size of the queue is 0
131
185
  */
@@ -133,12 +187,26 @@ class Trie extends base_1.IterableElementBase {
133
187
  return this.size === 0;
134
188
  }
135
189
  /**
136
- * Time Complexity: O(M), where M is the length of the word being deleted.
137
- * Space Complexity: O(M) - Due to the recursive DFS approach.
190
+ * Time Complexity: O(1)
191
+ * Space Complexity: O(1)
192
+ */
193
+ /**
194
+ * Time Complexity: O(1)
195
+ * Space Complexity: O(1)
196
+ *
197
+ * The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
198
+ */
199
+ clear() {
200
+ this._size = 0;
201
+ this._root = new TrieNode('');
202
+ }
203
+ /**
204
+ * Time Complexity: O(l), where l is the length of the word being deleted.
205
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
138
206
  */
139
207
  /**
140
- * Time Complexity: O(M), where M is the length of the word being deleted.
141
- * Space Complexity: O(M) - Due to the recursive DFS approach.
208
+ * Time Complexity: O(l), where l is the length of the word being deleted.
209
+ * Space Complexity: O(n) - Due to the recursive DFS approach.
142
210
  *
143
211
  * Remove a word from the Trie structure.
144
212
  * @param{string} word - The word to delete.
@@ -180,11 +248,11 @@ class Trie extends base_1.IterableElementBase {
180
248
  return isDeleted;
181
249
  }
182
250
  /**
183
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
251
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
184
252
  * Space Complexity: O(1) - Constant space.
185
253
  */
186
254
  /**
187
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
255
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
188
256
  * Space Complexity: O(1) - Constant space.
189
257
  *
190
258
  */
@@ -208,11 +276,11 @@ class Trie extends base_1.IterableElementBase {
208
276
  return maxDepth;
209
277
  }
210
278
  /**
211
- * Time Complexity: O(M), where M is the length of the input prefix.
279
+ * Time Complexity: O(l), where l is the length of the input prefix.
212
280
  * Space Complexity: O(1) - Constant space.
213
281
  */
214
282
  /**
215
- * Time Complexity: O(M), where M is the length of the input prefix.
283
+ * Time Complexity: O(l), where l is the length of the input prefix.
216
284
  * Space Complexity: O(1) - Constant space.
217
285
  *
218
286
  * Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
@@ -231,11 +299,11 @@ class Trie extends base_1.IterableElementBase {
231
299
  return !cur.isEnd;
232
300
  }
233
301
  /**
234
- * Time Complexity: O(M), where M is the length of the input prefix.
302
+ * Time Complexity: O(l), where l is the length of the input prefix.
235
303
  * Space Complexity: O(1) - Constant space.
236
304
  */
237
305
  /**
238
- * Time Complexity: O(M), where M is the length of the input prefix.
306
+ * Time Complexity: O(l), where l is the length of the input prefix.
239
307
  * Space Complexity: O(1) - Constant space.
240
308
  *
241
309
  * Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
@@ -254,12 +322,12 @@ class Trie extends base_1.IterableElementBase {
254
322
  return true;
255
323
  }
256
324
  /**
257
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
258
- * Space Complexity: O(M), where M is the length of the input prefix.
325
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
326
+ * Space Complexity: O(l), where l is the length of the input prefix.
259
327
  */
260
328
  /**
261
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
262
- * Space Complexity: O(M), where M is the length of the input prefix.
329
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
330
+ * Space Complexity: O(l), where l is the length of the input prefix.
263
331
  *
264
332
  * Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
265
333
  * @param {string} input - The input string representing the common prefix to check for.
@@ -283,12 +351,12 @@ class Trie extends base_1.IterableElementBase {
283
351
  return commonPre === input;
284
352
  }
285
353
  /**
286
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
287
- * Space Complexity: O(M), where M is the length of the longest common prefix.
354
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
355
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
288
356
  */
289
357
  /**
290
- * Time Complexity: O(N), where N is the total number of nodes in the trie.
291
- * Space Complexity: O(M), where M is the length of the longest common prefix.
358
+ * Time Complexity: O(n), where n is the total number of nodes in the trie.
359
+ * Space Complexity: O(l), where l is the length of the longest common prefix.
292
360
  *
293
361
  * Get the longest common prefix among all the words stored in the Trie.
294
362
  * @returns {string} The longest common prefix found in the Trie.
@@ -308,12 +376,12 @@ class Trie extends base_1.IterableElementBase {
308
376
  return commonPre;
309
377
  }
310
378
  /**
311
- * Time Complexity: O(K * L), where K is the number of words retrieved, and L is the average length of the words.
312
- * Space Complexity: O(K * L) - The space required for the output array.
379
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
380
+ * Space Complexity: O(w * l) - The space required for the output array.
313
381
  */
314
382
  /**
315
- * Time Complexity: O(K * L), where K is the number of words retrieved, and L is the average length of the words.
316
- * Space Complexity: O(K * L) - The space required for the output array.
383
+ * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
384
+ * Space Complexity: O(w * l) - The space required for the output array.
317
385
  *
318
386
  * The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
319
387
  * @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
@@ -422,6 +490,17 @@ class Trie extends base_1.IterableElementBase {
422
490
  }
423
491
  return newTrie;
424
492
  }
493
+ /**
494
+ * Time Complexity: O(n)
495
+ * Space Complexity: O(n)
496
+ */
497
+ /**
498
+ * Time Complexity: O(n)
499
+ * Space Complexity: O(n)
500
+ *
501
+ * The function `_getIterator` returns an iterable iterator that performs a depth-first search on a
502
+ * trie data structure and yields all the paths to the end nodes.
503
+ */
425
504
  *_getIterator() {
426
505
  function* _dfs(node, path) {
427
506
  if (node.isEnd) {
@@ -434,11 +513,11 @@ class Trie extends base_1.IterableElementBase {
434
513
  yield* _dfs(this.root, '');
435
514
  }
436
515
  /**
437
- * Time Complexity: O(M), where M is the length of the input string.
516
+ * Time Complexity: O(l), where l is the length of the input string.
438
517
  * Space Complexity: O(1) - Constant space.
439
518
  */
440
519
  /**
441
- * Time Complexity: O(M), where M is the length of the input string.
520
+ * Time Complexity: O(l), where l is the length of the input string.
442
521
  * Space Complexity: O(1) - Constant space.
443
522
  *
444
523
  * @param str
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "min-heap-typed",
3
- "version": "1.50.2",
3
+ "version": "1.50.3",
4
4
  "description": "Min Heap. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -132,6 +132,6 @@
132
132
  "typescript": "^4.9.5"
133
133
  },
134
134
  "dependencies": {
135
- "data-structure-typed": "^1.50.2"
135
+ "data-structure-typed": "^1.50.3"
136
136
  }
137
137
  }
@@ -289,8 +289,14 @@ export abstract class IterableEntryBase<K = any, V = any> {
289
289
 
290
290
  abstract isEmpty(): boolean;
291
291
 
292
+ abstract clear(): void;
293
+
292
294
  abstract clone(): any;
293
295
 
296
+ abstract map(...args: any[]): any;
297
+
298
+ abstract filter(...args: any[]): any;
299
+
294
300
  protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;
295
301
  }
296
302
 
@@ -497,7 +503,13 @@ export abstract class IterableElementBase<E = any, C = any> {
497
503
 
498
504
  abstract isEmpty(): boolean;
499
505
 
506
+ abstract clear(): void;
507
+
500
508
  abstract clone(): C;
501
509
 
510
+ abstract map(...args: any[]): any;
511
+
512
+ abstract filter(...args: any[]): any;
513
+
502
514
  protected abstract _getIterator(...args: any[]): IterableIterator<E>;
503
515
  }
@@ -22,11 +22,36 @@ export class AVLTreeNode<
22
22
  V = any,
23
23
  NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>
24
24
  > extends BSTNode<K, V, NODE> {
25
- height: number;
26
-
25
+ /**
26
+ * The constructor function initializes a new instance of a class with a key and an optional value,
27
+ * and sets the height property to 0.
28
+ * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
29
+ * constructor. It is used to initialize the key property of the object being created.
30
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
31
+ * value associated with the key in the constructor.
32
+ */
27
33
  constructor(key: K, value?: V) {
28
34
  super(key, value);
29
- this.height = 0;
35
+ this._height = 0;
36
+ }
37
+
38
+ protected _height: number;
39
+
40
+ /**
41
+ * The function returns the value of the height property.
42
+ * @returns The height of the object.
43
+ */
44
+ get height(): number {
45
+ return this._height;
46
+ }
47
+
48
+ /**
49
+ * The above function sets the value of the height property.
50
+ * @param {number} value - The value parameter is a number that represents the new height value to be
51
+ * set.
52
+ */
53
+ set height(value: number) {
54
+ this._height = value;
30
55
  }
31
56
  }
32
57
 
@@ -488,6 +513,15 @@ export class AVLTree<
488
513
  }
489
514
  }
490
515
 
516
+ /**
517
+ * The function replaces an old node with a new node while preserving the height of the old node.
518
+ * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace with the
519
+ * `newNode`.
520
+ * @param {NODE} newNode - The `newNode` parameter is the new node that will replace the `oldNode` in
521
+ * the data structure.
522
+ * @returns the result of calling the `_replaceNode` method on the superclass, passing in the
523
+ * `oldNode` and `newNode` as arguments.
524
+ */
491
525
  protected _replaceNode(oldNode: NODE, newNode: NODE): NODE {
492
526
  newNode.height = oldNode.height;
493
527
 
@@ -27,26 +27,48 @@ export class BinaryIndexedTree {
27
27
 
28
28
  protected _freqMap: Record<number, number>;
29
29
 
30
+ /**
31
+ * The function returns the frequency map of numbers.
32
+ * @returns The `_freqMap` property, which is a record with number keys and number values, is being
33
+ * returned.
34
+ */
30
35
  get freqMap(): Record<number, number> {
31
36
  return this._freqMap;
32
37
  }
33
38
 
34
39
  protected _msb: number;
35
40
 
41
+ /**
42
+ * The function returns the value of the _msb property.
43
+ * @returns The `_msb` property of the object.
44
+ */
36
45
  get msb(): number {
37
46
  return this._msb;
38
47
  }
39
48
 
40
49
  protected _negativeCount: number;
41
50
 
51
+ /**
52
+ * The function returns the value of the _negativeCount property.
53
+ * @returns The method is returning the value of the variable `_negativeCount`, which is of type
54
+ * `number`.
55
+ */
42
56
  get negativeCount(): number {
43
57
  return this._negativeCount;
44
58
  }
45
59
 
60
+ /**
61
+ * The above function returns the value of the protected variable `_freq`.
62
+ * @returns The frequency value stored in the protected variable `_freq`.
63
+ */
46
64
  get freq(): number {
47
65
  return this._freq;
48
66
  }
49
67
 
68
+ /**
69
+ * The above function returns the maximum value.
70
+ * @returns The maximum value stored in the variable `_max`.
71
+ */
50
72
  get max(): number {
51
73
  return this._max;
52
74
  }
@@ -44,7 +44,7 @@ export class BinaryTreeNode<
44
44
  /**
45
45
  * The constructor function initializes an object with a key and an optional value.
46
46
  * @param {K} key - The "key" parameter is of type K, which represents the type of the key for the
47
- * constructor. It is used to set the value of the "key" property of the object being created.
47
+ * constructor. It is used to set the key property of the object being created.
48
48
  * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
49
49
  * value associated with the key in the constructor.
50
50
  */
@@ -34,10 +34,19 @@ export class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNod
34
34
 
35
35
  protected override _left?: NODE;
36
36
 
37
+ /**
38
+ * The function returns the value of the `_left` property.
39
+ * @returns The `_left` property of the current object is being returned.
40
+ */
37
41
  override get left(): NODE | undefined {
38
42
  return this._left;
39
43
  }
40
44
 
45
+ /**
46
+ * The function sets the left child of a node and updates the parent reference of the child.
47
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an
48
+ * instance of the `NODE` class or `undefined`.
49
+ */
41
50
  override set left(v: NODE | undefined) {
42
51
  if (v) {
43
52
  v.parent = this as unknown as NODE;
@@ -47,10 +56,20 @@ export class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNod
47
56
 
48
57
  protected override _right?: NODE;
49
58
 
59
+ /**
60
+ * The function returns the right node of a binary tree or undefined if there is no right node.
61
+ * @returns The method is returning the value of the `_right` property, which is of type `NODE` or
62
+ * `undefined`.
63
+ */
50
64
  override get right(): NODE | undefined {
51
65
  return this._right;
52
66
  }
53
67
 
68
+ /**
69
+ * The function sets the right child of a node and updates the parent reference of the child.
70
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a
71
+ * `NODE` object or `undefined`.
72
+ */
54
73
  override set right(v: NODE | undefined) {
55
74
  if (v) {
56
75
  v.parent = this as unknown as NODE;
@@ -77,10 +96,10 @@ export class BST<
77
96
  extends BinaryTree<K, V, NODE, TREE>
78
97
  implements IBinaryTree<K, V, NODE, TREE> {
79
98
  /**
80
- * This is the constructor function for a binary search tree class in TypeScript, which initializes
81
- * the tree with optional keysOrNodesOrEntries and options.
82
- * @param [keysOrNodesOrEntries] - An optional iterable of KeyOrNodeOrEntry objects that will be added to the
83
- * binary search tree.
99
+ * This is the constructor function for a TypeScript class that initializes a binary search tree with
100
+ * optional keys or nodes or entries and options.
101
+ * @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used
102
+ * to initialize the binary search tree with the provided keys, nodes, or entries.
84
103
  * @param [options] - The `options` parameter is an optional object that can contain additional
85
104
  * configuration options for the binary search tree. It can have the following properties:
86
105
  */
@@ -99,23 +118,31 @@ export class BST<
99
118
 
100
119
  protected override _root?: NODE;
101
120
 
121
+ /**
122
+ * The function returns the root node of a tree structure.
123
+ * @returns The `_root` property of the object, which is of type `NODE` or `undefined`.
124
+ */
102
125
  override get root(): NODE | undefined {
103
126
  return this._root;
104
127
  }
105
128
 
106
129
  protected _variant = BSTVariant.STANDARD;
107
130
 
131
+ /**
132
+ * The function returns the value of the _variant property.
133
+ * @returns The value of the `_variant` property.
134
+ */
108
135
  get variant() {
109
136
  return this._variant;
110
137
  }
111
138
 
112
139
  /**
113
- * The function creates a new binary search tree node with the given key and value.
114
- * @param {K} key - The key parameter is the key value that will be associated with
115
- * the new node. It is used to determine the position of the node in the binary search tree.
116
- * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
117
- * represents the value associated with the node in a binary search tree.
118
- * @returns a new instance of the BSTNode class with the specified key and value.
140
+ * The function creates a new BSTNode with the given key and value and returns it.
141
+ * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
142
+ * being created.
143
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It represents the
144
+ * value associated with the key in the node being created.
145
+ * @returns The method is returning a new instance of the BSTNode class, casted as the NODE type.
119
146
  */
120
147
  override createNode(key: K, value?: V): NODE {
121
148
  return new BSTNode<K, V, NODE>(key, value) as NODE;
@@ -124,9 +151,10 @@ export class BST<
124
151
  /**
125
152
  * The function creates a new binary search tree with the specified options.
126
153
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
127
- * behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which is a type
128
- * that defines various options for creating a binary search tree.
129
- * @returns a new instance of the BST class with the specified options.
154
+ * behavior of the `createTree` method. It is of type `Partial<BSTOptions<K>>`, which means it is a
155
+ * partial object of type `BSTOptions<K>`.
156
+ * @returns a new instance of the BST class, with the provided options merged with the default
157
+ * options. The returned value is casted as TREE.
130
158
  */
131
159
  override createTree(options?: Partial<BSTOptions<K>>): TREE {
132
160
  return new BST<K, V, NODE, TREE>([], {
@@ -824,6 +852,11 @@ export class BST<
824
852
  return balanced;
825
853
  }
826
854
 
855
+ /**
856
+ * The function sets the root property of an object and updates the parent property of the new root.
857
+ * @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. This means that it
858
+ * can either be an object of type `NODE` or it can be `undefined`.
859
+ */
827
860
  protected _setRoot(v: NODE | undefined) {
828
861
  if (v) {
829
862
  v.parent = undefined;