data-structure-typed 1.53.9 → 1.54.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 (68) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -17
  3. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +1 -20
  4. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +9 -24
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.js +18 -34
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +40 -37
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js +68 -53
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/bst.d.ts +36 -50
  12. package/dist/cjs/data-structures/binary-tree/bst.js +45 -60
  13. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +29 -43
  15. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +45 -59
  16. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +33 -45
  18. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +70 -83
  19. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  20. package/dist/cjs/interfaces/binary-tree.d.ts +4 -3
  21. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -2
  22. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -2
  23. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +3 -2
  24. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -2
  25. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +5 -4
  26. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -2
  27. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -17
  28. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +1 -20
  29. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  30. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +9 -24
  31. package/dist/mjs/data-structures/binary-tree/avl-tree.js +18 -35
  32. package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  33. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +40 -37
  34. package/dist/mjs/data-structures/binary-tree/binary-tree.js +68 -53
  35. package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  36. package/dist/mjs/data-structures/binary-tree/bst.d.ts +36 -50
  37. package/dist/mjs/data-structures/binary-tree/bst.js +65 -80
  38. package/dist/mjs/data-structures/binary-tree/bst.js.map +1 -1
  39. package/dist/mjs/data-structures/binary-tree/red-black-tree.d.ts +29 -43
  40. package/dist/mjs/data-structures/binary-tree/red-black-tree.js +44 -59
  41. package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  42. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +33 -45
  43. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +70 -83
  44. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  45. package/dist/mjs/interfaces/binary-tree.d.ts +4 -3
  46. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -2
  47. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -2
  48. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +3 -2
  49. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -2
  50. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +5 -4
  51. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -2
  52. package/dist/umd/data-structure-typed.js +223 -298
  53. package/dist/umd/data-structure-typed.min.js +2 -2
  54. package/dist/umd/data-structure-typed.min.js.map +1 -1
  55. package/package.json +5 -5
  56. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +23 -31
  57. package/src/data-structures/binary-tree/avl-tree.ts +35 -46
  58. package/src/data-structures/binary-tree/binary-tree.ts +105 -66
  59. package/src/data-structures/binary-tree/bst.ts +105 -104
  60. package/src/data-structures/binary-tree/red-black-tree.ts +68 -73
  61. package/src/data-structures/binary-tree/tree-multi-map.ts +98 -102
  62. package/src/interfaces/binary-tree.ts +16 -3
  63. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +4 -2
  64. package/src/types/data-structures/binary-tree/avl-tree.ts +4 -2
  65. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
  66. package/src/types/data-structures/binary-tree/bst.ts +4 -2
  67. package/src/types/data-structures/binary-tree/rb-tree.ts +6 -4
  68. package/src/types/data-structures/binary-tree/tree-multi-map.ts +4 -2
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback } from '../../types';
9
+ import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
12
12
  /**
@@ -18,18 +18,6 @@ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V
18
18
  * value associated with the key in the constructor.
19
19
  */
20
20
  constructor(key: K, value?: V);
21
- protected _height: number;
22
- /**
23
- * The function returns the value of the height property.
24
- * @returns The height of the object.
25
- */
26
- get height(): number;
27
- /**
28
- * The above function sets the value of the height property.
29
- * @param {number} value - The value parameter is a number that represents the new height value to be
30
- * set.
31
- */
32
- set height(value: number);
33
21
  }
34
22
  /**
35
23
  * 1. Height-Balanced: Each node's left and right subtrees differ in height by no more than one.
@@ -40,7 +28,7 @@ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V
40
28
  * 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
41
29
  * 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
42
30
  */
43
- export declare class AVLTree<K = any, V = any, R = object, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>> extends BST<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
31
+ export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, R, MK, MV, MR, NODE, TREE> = AVLTree<K, V, R, MK, MV, MR, NODE, AVLTreeNested<K, V, R, MK, MV, MR, NODE>>> extends BST<K, V, R, MK, MV, MR, NODE, TREE> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
44
32
  /**
45
33
  * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,
46
34
  * entries, or raw elements.
@@ -64,16 +52,13 @@ export declare class AVLTree<K = any, V = any, R = object, NODE extends AVLTreeN
64
52
  */
65
53
  createNode(key: K, value?: V): NODE;
66
54
  /**
67
- * The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
68
- * options.
69
- * @param [options] - The `options` parameter in the `createTree` function is an object that contains
70
- * configuration options for creating an AVL tree. These options can include properties such as
71
- * `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
72
- * creates a
73
- * @returns An AVLTree object is being returned with the specified options and properties inherited
74
- * from the current object.
55
+ * The function creates a new AVL tree with the specified options and returns it.
56
+ * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
57
+ * passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
58
+ * being created.
59
+ * @returns a new AVLTree object.
75
60
  */
76
- createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R, NODE>;
61
+ createTree(options?: AVLTreeOptions<K, V, R>): TREE;
77
62
  /**
78
63
  * The function checks if the input is an instance of AVLTreeNode.
79
64
  * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
@@ -110,7 +95,7 @@ export declare class AVLTree<K = any, V = any, R = object, NODE extends AVLTreeN
110
95
  * `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
111
96
  */
112
97
  delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): BinaryTreeDeleteResult<NODE>[];
113
- map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR, AVLTreeNode<MK, MV, AVLTreeNodeNested<MK, MV>>>;
98
+ map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR>;
114
99
  /**
115
100
  * Time Complexity: O(1)
116
101
  * Space Complexity: O(1)
@@ -17,23 +17,6 @@ export class AVLTreeNode extends BSTNode {
17
17
  */
18
18
  constructor(key, value) {
19
19
  super(key, value);
20
- this._height = 0;
21
- }
22
- _height;
23
- /**
24
- * The function returns the value of the height property.
25
- * @returns The height of the object.
26
- */
27
- get height() {
28
- return this._height;
29
- }
30
- /**
31
- * The above function sets the value of the height property.
32
- * @param {number} value - The value parameter is a number that represents the new height value to be
33
- * set.
34
- */
35
- set height(value) {
36
- this._height = value;
37
20
  }
38
21
  }
39
22
  /**
@@ -75,16 +58,12 @@ export class AVLTree extends BST {
75
58
  return new AVLTreeNode(key, this._isMapMode ? undefined : value);
76
59
  }
77
60
  /**
78
- * The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
79
- * options.
80
- * @param [options] - The `options` parameter in the `createTree` function is an object that contains
81
- * configuration options for creating an AVL tree. These options can include properties such as
82
- * `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
83
- * creates a
84
- * @returns An AVLTree object is being returned with the specified options and properties inherited
85
- * from the current object.
61
+ * The function creates a new AVL tree with the specified options and returns it.
62
+ * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
63
+ * passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
64
+ * being created.
65
+ * @returns a new AVLTree object.
86
66
  */
87
- // @ts-ignore
88
67
  createTree(options) {
89
68
  return new AVLTree([], {
90
69
  iterationType: this.iterationType,
@@ -148,7 +127,6 @@ export class AVLTree extends BST {
148
127
  }
149
128
  return deletedResults;
150
129
  }
151
- // @ts-ignore
152
130
  map(callback, options, thisArg) {
153
131
  const newTree = new AVLTree([], options);
154
132
  let index = 0;
@@ -241,7 +219,8 @@ export class AVLTree extends BST {
241
219
  _balanceLL(A) {
242
220
  const parentOfA = A.parent;
243
221
  const B = A.left;
244
- A.parent = B;
222
+ if (B !== null)
223
+ A.parent = B;
245
224
  if (B && B.right) {
246
225
  B.right.parent = A;
247
226
  }
@@ -282,13 +261,14 @@ export class AVLTree extends BST {
282
261
  if (B) {
283
262
  C = B.right;
284
263
  }
285
- if (A)
264
+ if (A && C !== null)
286
265
  A.parent = C;
287
- if (B)
266
+ if (B && C !== null)
288
267
  B.parent = C;
289
268
  if (C) {
290
269
  if (C.left) {
291
- C.left.parent = B;
270
+ if (B !== null)
271
+ C.left.parent = B;
292
272
  }
293
273
  if (C.right) {
294
274
  C.right.parent = A;
@@ -332,7 +312,8 @@ export class AVLTree extends BST {
332
312
  _balanceRR(A) {
333
313
  const parentOfA = A.parent;
334
314
  const B = A.right;
335
- A.parent = B;
315
+ if (B !== null)
316
+ A.parent = B;
336
317
  if (B) {
337
318
  if (B.left) {
338
319
  B.left.parent = A;
@@ -375,15 +356,17 @@ export class AVLTree extends BST {
375
356
  if (B) {
376
357
  C = B.left;
377
358
  }
378
- A.parent = C;
379
- if (B)
359
+ if (C !== null)
360
+ A.parent = C;
361
+ if (B && C !== null)
380
362
  B.parent = C;
381
363
  if (C) {
382
364
  if (C.left) {
383
365
  C.left.parent = A;
384
366
  }
385
367
  if (C.right) {
386
- C.right.parent = B;
368
+ if (B !== null)
369
+ C.right.parent = B;
387
370
  }
388
371
  C.parent = parentOfA;
389
372
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avl-tree.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/avl-tree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAWrC,MAAM,OAAO,WAIX,SAAQ,OAAmB;IAC3B;;;;;;;OAOG;IACH,YAAY,GAAM,EAAE,KAAS;QAC3B,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAES,OAAO,CAAS;IAE1B;;;OAGG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM,CAAC,KAAa;QACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,OAAO,OAMX,SAAQ,GAAkB;IAG1B;;;;;;;;;;OAUG;IACH,YAAY,yBAA2D,EAAE,EAAE,OAAiC;QAC1G,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,sBAAsB;YAAE,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;OAQG;IACM,UAAU,CAAC,GAAM,EAAE,KAAS;QACn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AAa;QAC1D,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAEhC,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF"}
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { BinaryTreeDeleteResult, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, BTNRep, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, ToEntryFn } from '../../types';
8
+ import { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, BTNRep, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, type RBTNColor, ToEntryFn } from '../../types';
9
9
  import { IBinaryTree } from '../../interfaces';
10
10
  import { IterableEntryBase } from '../base';
11
11
  import { Range } from '../../common';
@@ -19,12 +19,21 @@ export declare class BinaryTreeNode<K = any, V = any, NODE extends BinaryTreeNod
19
19
  value?: V;
20
20
  parent?: NODE;
21
21
  constructor(key: K, value?: V);
22
- protected _left?: OptNodeOrNull<NODE>;
22
+ _left?: OptNodeOrNull<NODE>;
23
23
  get left(): OptNodeOrNull<NODE>;
24
24
  set left(v: OptNodeOrNull<NODE>);
25
- protected _right?: OptNodeOrNull<NODE>;
25
+ _right?: OptNodeOrNull<NODE>;
26
26
  get right(): OptNodeOrNull<NODE>;
27
27
  set right(v: OptNodeOrNull<NODE>);
28
+ _height: number;
29
+ get height(): number;
30
+ set height(value: number);
31
+ _color: RBTNColor;
32
+ get color(): RBTNColor;
33
+ set color(value: RBTNColor);
34
+ _count: number;
35
+ get count(): number;
36
+ set count(value: number);
28
37
  get familyPosition(): FamilyPosition;
29
38
  }
30
39
  /**
@@ -34,7 +43,7 @@ export declare class BinaryTreeNode<K = any, V = any, NODE extends BinaryTreeNod
34
43
  * 4. Subtrees: Each child of a node forms the root of a subtree.
35
44
  * 5. Leaf Nodes: Nodes without children are leaves.
36
45
  */
37
- export declare class BinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, NODE> {
46
+ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, R, MK, MV, MR, NODE, TREE> = BinaryTree<K, V, R, MK, MV, MR, NODE, BinaryTreeNested<K, V, R, MK, MV, MR, NODE>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
38
47
  iterationType: IterationType;
39
48
  /**
40
49
  * The constructor initializes a binary tree with optional options and adds keys, nodes, entries, or
@@ -72,20 +81,30 @@ export declare class BinaryTree<K = any, V = any, R = object, NODE extends Binar
72
81
  */
73
82
  createNode(key: K, value?: V): NODE;
74
83
  /**
75
- * Time Complexity: O(1)
76
- * Space Complexity: O(1)
77
- *
78
- * The `createTree` function creates a new binary tree based on the provided options.
79
- * @param [options] - The `options` parameter in the `createTree` method is of type
80
- * `BinaryTreeOptions<K, V, R>`. This type likely contains configuration options for creating a
81
- * binary tree, such as the iteration type, whether the tree is in map mode, and functions for
82
- * converting entries.
83
- * @returns The `createTree` method is returning an instance of the `BinaryTree` class with the
84
- * provided options. The method is creating a new `BinaryTree` object with an empty array as the
85
- * initial data, and then setting various options such as `iterationType`, `isMapMode`, and
86
- * `toEntryFn` based on the current object's properties and the provided `options`. Finally, it
84
+ * The function creates a binary tree with the specified options.
85
+ * @param [options] - The `options` parameter in the `createTree` function is an optional parameter
86
+ * that allows you to provide partial configuration options for creating a binary tree. It is of type
87
+ * `Partial<BinaryTreeOptions<K, V, R>>`, which means you can pass in an object containing a subset
88
+ * of properties
89
+ * @returns A new instance of a binary tree with the specified options is being returned.
87
90
  */
88
- createTree(options?: BinaryTreeOptions<K, V, R>): typeof this;
91
+ createTree(options?: BinaryTreeOptions<K, V, R>): TREE;
92
+ /**
93
+ * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
94
+ * or returns null.
95
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
96
+ * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
97
+ * can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
98
+ * node, an entry
99
+ * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
100
+ * an optional parameter of type `V`. It represents the value associated with the key in the node
101
+ * being created. If a `value` is provided, it will be used when creating the node. If
102
+ * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
103
+ * (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
104
+ * input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
105
+ * value.
106
+ */
107
+ protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): [OptNodeOrNull<NODE>, V | undefined];
89
108
  /**
90
109
  * Time Complexity: O(n)
91
110
  * Space Complexity: O(log n)
@@ -231,7 +250,7 @@ export declare class BinaryTree<K = any, V = any, R = object, NODE extends Binar
231
250
  * elements from the other tree.
232
251
  * @param anotherTree - `BinaryTree<K, V, R, NODE, TREE>`
233
252
  */
234
- merge(anotherTree: this): void;
253
+ merge(anotherTree: BinaryTree<K, V, R, NODE, TREE>): void;
235
254
  /**
236
255
  * Time Complexity: O(k * n)
237
256
  * Space Complexity: O(1)
@@ -631,7 +650,7 @@ export declare class BinaryTree<K = any, V = any, R = object, NODE extends Binar
631
650
  * original tree using breadth-first search (bfs), and adds the nodes to the new tree. If a node in
632
651
  * the original tree is null, a null node is added to the cloned tree. If a node
633
652
  */
634
- clone(): this;
653
+ clone(): TREE;
635
654
  /**
636
655
  * Time Complexity: O(n)
637
656
  * Space Complexity: O(n)
@@ -648,7 +667,7 @@ export declare class BinaryTree<K = any, V = any, R = object, NODE extends Binar
648
667
  * @returns The `filter` method is returning a new tree that contains entries that pass the provided
649
668
  * predicate function.
650
669
  */
651
- filter(predicate: EntryCallback<K, V | undefined, boolean>, thisArg?: any): this;
670
+ filter(predicate: EntryCallback<K, V | undefined, boolean>, thisArg?: any): TREE;
652
671
  /**
653
672
  * Time Complexity: O(n)
654
673
  * Space Complexity: O(n)
@@ -668,7 +687,7 @@ export declare class BinaryTree<K = any, V = any, R = object, NODE extends Binar
668
687
  * @returns The `map` function is returning a new `BinaryTree` instance filled with entries that are
669
688
  * the result of applying the provided `callback` function to each entry in the original tree.
670
689
  */
671
- map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: BinaryTreeOptions<MK, MV, MR>, thisArg?: any): BinaryTree<MK, MV, MR, BinaryTreeNode<MK, MV, BinaryTreeNodeNested<MK, MV>>>;
690
+ map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: BinaryTreeOptions<MK, MV, MR>, thisArg?: any): BinaryTree<MK, MV, MR>;
672
691
  /**
673
692
  * Time Complexity: O(n)
674
693
  * Space Complexity: O(n)
@@ -704,22 +723,6 @@ export declare class BinaryTree<K = any, V = any, R = object, NODE extends Binar
704
723
  * provided, the default value is set to
705
724
  */
706
725
  print(options?: BinaryTreePrintOptions, startNode?: BTNRep<K, V, NODE> | R): void;
707
- /**
708
- * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
709
- * or returns null.
710
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
711
- * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
712
- * can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
713
- * node, an entry
714
- * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
715
- * an optional parameter of type `V`. It represents the value associated with the key in the node
716
- * being created. If a `value` is provided, it will be used when creating the node. If
717
- * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
718
- * (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
719
- * input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
720
- * value.
721
- */
722
- protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): [OptNodeOrNull<NODE>, V | undefined];
723
726
  /**
724
727
  * Time complexity: O(n)
725
728
  * Space complexity: O(n)
@@ -42,6 +42,27 @@ export class BinaryTreeNode {
42
42
  }
43
43
  this._right = v;
44
44
  }
45
+ _height = 0;
46
+ get height() {
47
+ return this._height;
48
+ }
49
+ set height(value) {
50
+ this._height = value;
51
+ }
52
+ _color = 'BLACK';
53
+ get color() {
54
+ return this._color;
55
+ }
56
+ set color(value) {
57
+ this._color = value;
58
+ }
59
+ _count = 1;
60
+ get count() {
61
+ return this._count;
62
+ }
63
+ set count(value) {
64
+ this._count = value;
65
+ }
45
66
  get familyPosition() {
46
67
  const that = this;
47
68
  if (!this.parent) {
@@ -130,18 +151,12 @@ export class BinaryTree extends IterableEntryBase {
130
151
  return new BinaryTreeNode(key, this._isMapMode ? undefined : value);
131
152
  }
132
153
  /**
133
- * Time Complexity: O(1)
134
- * Space Complexity: O(1)
135
- *
136
- * The `createTree` function creates a new binary tree based on the provided options.
137
- * @param [options] - The `options` parameter in the `createTree` method is of type
138
- * `BinaryTreeOptions<K, V, R>`. This type likely contains configuration options for creating a
139
- * binary tree, such as the iteration type, whether the tree is in map mode, and functions for
140
- * converting entries.
141
- * @returns The `createTree` method is returning an instance of the `BinaryTree` class with the
142
- * provided options. The method is creating a new `BinaryTree` object with an empty array as the
143
- * initial data, and then setting various options such as `iterationType`, `isMapMode`, and
144
- * `toEntryFn` based on the current object's properties and the provided `options`. Finally, it
154
+ * The function creates a binary tree with the specified options.
155
+ * @param [options] - The `options` parameter in the `createTree` function is an optional parameter
156
+ * that allows you to provide partial configuration options for creating a binary tree. It is of type
157
+ * `Partial<BinaryTreeOptions<K, V, R>>`, which means you can pass in an object containing a subset
158
+ * of properties
159
+ * @returns A new instance of a binary tree with the specified options is being returned.
145
160
  */
146
161
  createTree(options) {
147
162
  return new BinaryTree([], {
@@ -151,6 +166,47 @@ export class BinaryTree extends IterableEntryBase {
151
166
  ...options
152
167
  });
153
168
  }
169
+ /**
170
+ * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
171
+ * or returns null.
172
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
173
+ * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
174
+ * can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
175
+ * node, an entry
176
+ * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
177
+ * an optional parameter of type `V`. It represents the value associated with the key in the node
178
+ * being created. If a `value` is provided, it will be used when creating the node. If
179
+ * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
180
+ * (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
181
+ * input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
182
+ * value.
183
+ */
184
+ _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
185
+ if (keyNodeEntryOrRaw === undefined)
186
+ return [undefined, undefined];
187
+ if (keyNodeEntryOrRaw === null)
188
+ return [null, undefined];
189
+ if (this.isNode(keyNodeEntryOrRaw))
190
+ return [keyNodeEntryOrRaw, value];
191
+ if (this.isEntry(keyNodeEntryOrRaw)) {
192
+ const [key, entryValue] = keyNodeEntryOrRaw;
193
+ if (key === undefined)
194
+ return [undefined, undefined];
195
+ else if (key === null)
196
+ return [null, undefined];
197
+ const finalValue = value ?? entryValue;
198
+ return [this.createNode(key, finalValue), finalValue];
199
+ }
200
+ if (this.isRaw(keyNodeEntryOrRaw)) {
201
+ const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
202
+ const finalValue = value ?? entryValue;
203
+ if (this.isKey(key))
204
+ return [this.createNode(key, finalValue), finalValue];
205
+ }
206
+ if (this.isKey(keyNodeEntryOrRaw))
207
+ return [this.createNode(keyNodeEntryOrRaw, value), value];
208
+ return [undefined, undefined];
209
+ }
154
210
  /**
155
211
  * Time Complexity: O(n)
156
212
  * Space Complexity: O(log n)
@@ -1564,47 +1620,6 @@ export class BinaryTree extends IterableEntryBase {
1564
1620
  print(options, startNode = this._root) {
1565
1621
  console.log(this.toVisual(startNode, options));
1566
1622
  }
1567
- /**
1568
- * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
1569
- * or returns null.
1570
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
1571
- * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
1572
- * can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
1573
- * node, an entry
1574
- * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
1575
- * an optional parameter of type `V`. It represents the value associated with the key in the node
1576
- * being created. If a `value` is provided, it will be used when creating the node. If
1577
- * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
1578
- * (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
1579
- * input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
1580
- * value.
1581
- */
1582
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
1583
- if (keyNodeEntryOrRaw === undefined)
1584
- return [undefined, undefined];
1585
- if (keyNodeEntryOrRaw === null)
1586
- return [null, undefined];
1587
- if (this.isNode(keyNodeEntryOrRaw))
1588
- return [keyNodeEntryOrRaw, value];
1589
- if (this.isEntry(keyNodeEntryOrRaw)) {
1590
- const [key, entryValue] = keyNodeEntryOrRaw;
1591
- if (key === undefined)
1592
- return [undefined, undefined];
1593
- else if (key === null)
1594
- return [null, undefined];
1595
- const finalValue = value ?? entryValue;
1596
- return [this.createNode(key, finalValue), finalValue];
1597
- }
1598
- if (this.isRaw(keyNodeEntryOrRaw)) {
1599
- const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
1600
- const finalValue = value ?? entryValue;
1601
- if (this.isKey(key))
1602
- return [this.createNode(key, finalValue), finalValue];
1603
- }
1604
- if (this.isKey(keyNodeEntryOrRaw))
1605
- return [this.createNode(keyNodeEntryOrRaw, value), value];
1606
- return [undefined, undefined];
1607
- }
1608
1623
  /**
1609
1624
  * Time complexity: O(n)
1610
1625
  * Space complexity: O(n)