data-structure-typed 1.34.6 → 1.34.8

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 (98) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +74 -35
  3. package/dist/data-structures/binary-tree/abstract-binary-tree.js +70 -70
  4. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  5. package/dist/data-structures/binary-tree/avl-tree.js +8 -8
  6. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  7. package/dist/data-structures/binary-tree/binary-tree.js +4 -4
  8. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  9. package/dist/data-structures/binary-tree/bst.js +59 -59
  10. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/data-structures/binary-tree/rb-tree.js +4 -4
  12. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  13. package/dist/data-structures/binary-tree/tree-multiset.js +39 -39
  14. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  15. package/dist/data-structures/graph/abstract-graph.js +49 -49
  16. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  17. package/dist/data-structures/graph/directed-graph.js +33 -33
  18. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  19. package/dist/data-structures/graph/map-graph.js +4 -4
  20. package/dist/data-structures/graph/map-graph.js.map +1 -1
  21. package/dist/data-structures/graph/undirected-graph.js +14 -14
  22. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  23. package/dist/data-structures/tree/tree.js +5 -5
  24. package/dist/data-structures/tree/tree.js.map +1 -1
  25. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +71 -71
  26. package/lib/data-structures/binary-tree/abstract-binary-tree.js +110 -110
  27. package/lib/data-structures/binary-tree/avl-tree.d.ts +10 -10
  28. package/lib/data-structures/binary-tree/avl-tree.js +13 -13
  29. package/lib/data-structures/binary-tree/binary-tree.d.ts +6 -6
  30. package/lib/data-structures/binary-tree/binary-tree.js +7 -7
  31. package/lib/data-structures/binary-tree/bst.d.ts +34 -34
  32. package/lib/data-structures/binary-tree/bst.js +80 -80
  33. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  34. package/lib/data-structures/binary-tree/rb-tree.js +4 -4
  35. package/lib/data-structures/binary-tree/tree-multiset.d.ts +27 -27
  36. package/lib/data-structures/binary-tree/tree-multiset.js +55 -55
  37. package/lib/data-structures/graph/abstract-graph.d.ts +60 -60
  38. package/lib/data-structures/graph/abstract-graph.js +81 -81
  39. package/lib/data-structures/graph/directed-graph.d.ts +51 -51
  40. package/lib/data-structures/graph/directed-graph.js +63 -63
  41. package/lib/data-structures/graph/map-graph.d.ts +13 -13
  42. package/lib/data-structures/graph/map-graph.js +12 -12
  43. package/lib/data-structures/graph/undirected-graph.d.ts +30 -30
  44. package/lib/data-structures/graph/undirected-graph.js +32 -32
  45. package/lib/data-structures/heap/heap.d.ts +1 -1
  46. package/lib/data-structures/tree/tree.d.ts +4 -4
  47. package/lib/data-structures/tree/tree.js +6 -6
  48. package/lib/interfaces/abstract-binary-tree.d.ts +24 -24
  49. package/lib/interfaces/abstract-graph.d.ts +13 -13
  50. package/lib/interfaces/avl-tree.d.ts +3 -3
  51. package/lib/interfaces/bst.d.ts +8 -8
  52. package/lib/interfaces/directed-graph.d.ts +5 -5
  53. package/lib/interfaces/rb-tree.d.ts +2 -2
  54. package/lib/interfaces/undirected-graph.d.ts +2 -2
  55. package/lib/types/data-structures/abstract-binary-tree.d.ts +3 -3
  56. package/lib/types/data-structures/abstract-graph.d.ts +2 -2
  57. package/lib/types/data-structures/bst.d.ts +2 -2
  58. package/lib/types/data-structures/tree-multiset.d.ts +1 -1
  59. package/lib/types/utils/validate-type.d.ts +8 -8
  60. package/package.json +1 -1
  61. package/scripts/rename_clear_files.sh +29 -0
  62. package/src/data-structures/binary-tree/abstract-binary-tree.ts +147 -147
  63. package/src/data-structures/binary-tree/avl-tree.ts +14 -14
  64. package/src/data-structures/binary-tree/binary-tree.ts +8 -8
  65. package/src/data-structures/binary-tree/bst.ts +98 -90
  66. package/src/data-structures/binary-tree/rb-tree.ts +9 -9
  67. package/src/data-structures/binary-tree/tree-multiset.ts +62 -62
  68. package/src/data-structures/graph/abstract-graph.ts +109 -104
  69. package/src/data-structures/graph/directed-graph.ts +77 -77
  70. package/src/data-structures/graph/map-graph.ts +20 -15
  71. package/src/data-structures/graph/undirected-graph.ts +39 -39
  72. package/src/data-structures/heap/heap.ts +1 -1
  73. package/src/data-structures/tree/tree.ts +7 -7
  74. package/src/interfaces/abstract-binary-tree.ts +24 -24
  75. package/src/interfaces/abstract-graph.ts +13 -13
  76. package/src/interfaces/avl-tree.ts +3 -3
  77. package/src/interfaces/bst.ts +8 -8
  78. package/src/interfaces/directed-graph.ts +5 -5
  79. package/src/interfaces/rb-tree.ts +2 -2
  80. package/src/interfaces/undirected-graph.ts +2 -2
  81. package/src/types/data-structures/abstract-binary-tree.ts +3 -3
  82. package/src/types/data-structures/abstract-graph.ts +2 -2
  83. package/src/types/data-structures/bst.ts +2 -2
  84. package/src/types/data-structures/tree-multiset.ts +1 -1
  85. package/src/types/utils/validate-type.ts +10 -10
  86. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +24 -24
  87. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
  88. package/test/unit/data-structures/binary-tree/bst.test.ts +71 -71
  89. package/test/unit/data-structures/binary-tree/overall.test.ts +19 -19
  90. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +72 -72
  91. package/test/unit/data-structures/graph/directed-graph.test.ts +8 -8
  92. package/test/unit/data-structures/graph/map-graph.test.ts +4 -4
  93. package/test/unit/data-structures/graph/overall.test.ts +2 -2
  94. package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
  95. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -1
  96. package/test/unit/data-structures/tree/tree.test.ts +2 -2
  97. package/umd/bundle.min.js +1 -1
  98. package/umd/bundle.min.js.map +1 -1
@@ -6,10 +6,10 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId } from '../../types';
9
+ import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeKey } from '../../types';
10
10
  import { IAVLTree, IAVLTreeNode } from '../../interfaces';
11
11
  export declare class AVLTreeNode<V = any, NEIGHBOR extends AVLTreeNode<V, NEIGHBOR> = AVLTreeNodeNested<V>> extends BSTNode<V, NEIGHBOR> implements IAVLTreeNode<V, NEIGHBOR> {
12
- constructor(id: BinaryTreeNodeId, val?: V);
12
+ constructor(key: BinaryTreeNodeKey, val?: V);
13
13
  }
14
14
  export declare class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> extends BST<N> implements IAVLTree<N> {
15
15
  /**
@@ -20,30 +20,30 @@ export declare class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> e
20
20
  */
21
21
  constructor(options?: AVLTreeOptions);
22
22
  /**
23
- * The function creates a new AVL tree node with the given id and value.
24
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is used to uniquely
23
+ * The function creates a new AVL tree node with the given key and value.
24
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier for the binary tree node. It is used to uniquely
25
25
  * identify each node in the tree.
26
26
  * @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
27
27
  * that will be stored in the node.
28
- * @returns a new AVLTreeNode object with the specified id and value.
28
+ * @returns a new AVLTreeNode object with the specified key and value.
29
29
  */
30
- createNode(id: BinaryTreeNodeId, val?: N['val']): N;
30
+ createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
31
31
  /**
32
32
  * The function overrides the add method of a binary tree node and balances the tree after inserting a new node.
33
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier of the binary tree node that we want to add.
33
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier of the binary tree node that we want to add.
34
34
  * @param [val] - The `val` parameter is an optional value that can be assigned to the node being added. It is of type
35
35
  * `N['val']`, which means it should be of the same type as the `val` property of the nodes in the binary tree.
36
36
  * @returns The method is returning the inserted node, or null or undefined if the insertion was not successful.
37
37
  */
38
- add(id: BinaryTreeNodeId, val?: N['val']): N | null | undefined;
38
+ add(key: BinaryTreeNodeKey, val?: N['val']): N | null | undefined;
39
39
  /**
40
40
  * The function overrides the remove method of a binary tree and performs additional operations to balance the tree after
41
41
  * deletion.
42
- * @param {BinaryTreeNodeId} id - The `id` parameter represents the identifier of the binary tree node that needs to be
42
+ * @param {BinaryTreeNodeKey} key - The `key` parameter represents the identifier of the binary tree node that needs to be
43
43
  * removed.
44
44
  * @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
45
45
  */
46
- remove(id: BinaryTreeNodeId): BinaryTreeDeletedResult<N>[];
46
+ remove(key: BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
47
47
  /**
48
48
  * The balance factor of a given AVL tree node is calculated by subtracting the height of its left subtree from the
49
49
  * height of its right subtree.
@@ -7,8 +7,8 @@
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
9
  export class AVLTreeNode extends BSTNode {
10
- constructor(id, val) {
11
- super(id, val);
10
+ constructor(key, val) {
11
+ super(key, val);
12
12
  }
13
13
  }
14
14
  export class AVLTree extends BST {
@@ -22,26 +22,26 @@ export class AVLTree extends BST {
22
22
  super(options);
23
23
  }
24
24
  /**
25
- * The function creates a new AVL tree node with the given id and value.
26
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is used to uniquely
25
+ * The function creates a new AVL tree node with the given key and value.
26
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier for the binary tree node. It is used to uniquely
27
27
  * identify each node in the tree.
28
28
  * @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
29
29
  * that will be stored in the node.
30
- * @returns a new AVLTreeNode object with the specified id and value.
30
+ * @returns a new AVLTreeNode object with the specified key and value.
31
31
  */
32
- createNode(id, val) {
33
- return new AVLTreeNode(id, val);
32
+ createNode(key, val) {
33
+ return new AVLTreeNode(key, val);
34
34
  }
35
35
  /**
36
36
  * The function overrides the add method of a binary tree node and balances the tree after inserting a new node.
37
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier of the binary tree node that we want to add.
37
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier of the binary tree node that we want to add.
38
38
  * @param [val] - The `val` parameter is an optional value that can be assigned to the node being added. It is of type
39
39
  * `N['val']`, which means it should be of the same type as the `val` property of the nodes in the binary tree.
40
40
  * @returns The method is returning the inserted node, or null or undefined if the insertion was not successful.
41
41
  */
42
- add(id, val) {
42
+ add(key, val) {
43
43
  // TODO support node as a param
44
- const inserted = super.add(id, val);
44
+ const inserted = super.add(key, val);
45
45
  if (inserted)
46
46
  this._balancePath(inserted);
47
47
  return inserted;
@@ -49,12 +49,12 @@ export class AVLTree extends BST {
49
49
  /**
50
50
  * The function overrides the remove method of a binary tree and performs additional operations to balance the tree after
51
51
  * deletion.
52
- * @param {BinaryTreeNodeId} id - The `id` parameter represents the identifier of the binary tree node that needs to be
52
+ * @param {BinaryTreeNodeKey} key - The `key` parameter represents the identifier of the binary tree node that needs to be
53
53
  * removed.
54
54
  * @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
55
55
  */
56
- remove(id) {
57
- const deletedResults = super.remove(id);
56
+ remove(key) {
57
+ const deletedResults = super.remove(key);
58
58
  for (const { needBalanced } of deletedResults) {
59
59
  if (needBalanced) {
60
60
  this._balancePath(needBalanced);
@@ -5,11 +5,11 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions } from '../../types';
8
+ import type { BinaryTreeNodeKey, BinaryTreeNodeNested, BinaryTreeOptions } from '../../types';
9
9
  import { AbstractBinaryTree, AbstractBinaryTreeNode } from './abstract-binary-tree';
10
10
  import { IBinaryTree, IBinaryTreeNode } from '../../interfaces';
11
11
  export declare class BinaryTreeNode<V = any, NEIGHBOR extends BinaryTreeNode<V, NEIGHBOR> = BinaryTreeNodeNested<V>> extends AbstractBinaryTreeNode<V, NEIGHBOR> implements IBinaryTreeNode<V, NEIGHBOR> {
12
- constructor(id: BinaryTreeNodeId, val?: V);
12
+ constructor(key: BinaryTreeNodeKey, val?: V);
13
13
  }
14
14
  export declare class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode> extends AbstractBinaryTree<N> implements IBinaryTree<N> {
15
15
  /**
@@ -21,11 +21,11 @@ export declare class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTr
21
21
  constructor(options?: BinaryTreeOptions);
22
22
  /**
23
23
  * The function creates a new binary tree node with an optional value.
24
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
25
- * `BinaryTreeNodeId`, which represents the unique identifier for each node in the binary tree.
24
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier for the binary tree node. It is of type
25
+ * `BinaryTreeNodeKey`, which represents the unique identifier for each node in the binary tree.
26
26
  * @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
27
27
  * stored in the node.
28
- * @returns a new instance of a BinaryTreeNode with the specified id and value.
28
+ * @returns a new instance of a BinaryTreeNode with the specified key and value.
29
29
  */
30
- createNode(id: BinaryTreeNodeId, val?: N['val']): N;
30
+ createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
31
31
  }
@@ -7,8 +7,8 @@
7
7
  */
8
8
  import { AbstractBinaryTree, AbstractBinaryTreeNode } from './abstract-binary-tree';
9
9
  export class BinaryTreeNode extends AbstractBinaryTreeNode {
10
- constructor(id, val) {
11
- super(id, val);
10
+ constructor(key, val) {
11
+ super(key, val);
12
12
  }
13
13
  }
14
14
  export class BinaryTree extends AbstractBinaryTree {
@@ -23,13 +23,13 @@ export class BinaryTree extends AbstractBinaryTree {
23
23
  }
24
24
  /**
25
25
  * The function creates a new binary tree node with an optional value.
26
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
27
- * `BinaryTreeNodeId`, which represents the unique identifier for each node in the binary tree.
26
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier for the binary tree node. It is of type
27
+ * `BinaryTreeNodeKey`, which represents the unique identifier for each node in the binary tree.
28
28
  * @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
29
29
  * stored in the node.
30
- * @returns a new instance of a BinaryTreeNode with the specified id and value.
30
+ * @returns a new instance of a BinaryTreeNode with the specified key and value.
31
31
  */
32
- createNode(id, val) {
33
- return new BinaryTreeNode(id, val);
32
+ createNode(key, val) {
33
+ return new BinaryTreeNode(key, val);
34
34
  }
35
35
  }
@@ -5,12 +5,12 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeNodeId, BinaryTreeNodePropertyName, BSTComparator, BSTNodeNested, BSTOptions } from '../../types';
8
+ import type { BinaryTreeNodeKey, BinaryTreeNodePropertyName, BSTComparator, BSTNodeNested, BSTOptions } from '../../types';
9
9
  import { CP } from '../../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
11
  import { IBST, IBSTNode } from '../../interfaces';
12
12
  export declare class BSTNode<V = any, NEIGHBOR extends BSTNode<V, NEIGHBOR> = BSTNodeNested<V>> extends BinaryTreeNode<V, NEIGHBOR> implements IBSTNode<V, NEIGHBOR> {
13
- constructor(id: BinaryTreeNodeId, val?: V);
13
+ constructor(key: BinaryTreeNodeKey, val?: V);
14
14
  }
15
15
  export declare class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N> implements IBST<N> {
16
16
  /**
@@ -19,87 +19,87 @@ export declare class BST<N extends BSTNode<N['val'], N> = BSTNode> extends Binar
19
19
  */
20
20
  constructor(options?: BSTOptions);
21
21
  /**
22
- * The function creates a new binary search tree node with the given id and value.
23
- * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is used to uniquely
22
+ * The function creates a new binary search tree node with the given key and value.
23
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is the identifier for the binary tree node. It is used to uniquely
24
24
  * identify each node in the binary tree.
25
25
  * @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
26
26
  * that will be stored in the node.
27
- * @returns a new instance of the BSTNode class with the specified id and value.
27
+ * @returns a new instance of the BSTNode class with the specified key and value.
28
28
  */
29
- createNode(id: BinaryTreeNodeId, val?: N['val']): N;
29
+ createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
30
30
  /**
31
31
  * The `add` function adds a new node to a binary search tree, either by creating a new node or by updating an existing
32
32
  * node with the same ID.
33
- * @param {BinaryTreeNodeId | N | null} idOrNode - The `idOrNode` parameter can be either a `BinaryTreeNodeId` or a `N`
33
+ * @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey` or a `N`
34
34
  * (which represents a binary tree node) or `null`.
35
35
  * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the new node
36
36
  * being added to the binary search tree.
37
37
  * @returns The function `add` returns the inserted node (`inserted`) which can be of type `N`, `null`, or `undefined`.
38
38
  */
39
- add(idOrNode: BinaryTreeNodeId | N | null, val?: N['val']): N | null | undefined;
39
+ add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
40
40
  /**
41
41
  * The `addMany` function overrides the base class method to add multiple nodes to a binary search tree in a balanced
42
42
  * manner.
43
- * @param {[BinaryTreeNodeId | N , N['val']][]} idsOrNodes - The `idsOrNodes` parameter in the `addMany` function is an array of
44
- * `BinaryTreeNodeId` or `N` (node) objects, or `null` values. It represents the nodes or node IDs that need to be added
43
+ * @param {[BinaryTreeNodeKey | N , N['val']][]} idsOrNodes - The `idsOrNodes` parameter in the `addMany` function is an array of
44
+ * `BinaryTreeNodeKey` or `N` (node) objects, or `null` values. It represents the nodes or node IDs that need to be added
45
45
  * to the binary search tree.
46
46
  * @param {N['val'][]} data - The values of tree nodes
47
47
  * @param {boolean} isBalanceAdd - If true the nodes will be balance inserted in binary search method.
48
48
  * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
49
49
  */
50
- addMany(idsOrNodes: (BinaryTreeNodeId | null)[] | (N | null)[], data?: N['val'][], isBalanceAdd?: boolean): (N | null | undefined)[];
50
+ addMany(idsOrNodes: (BinaryTreeNodeKey | null)[] | (N | null)[], data?: N['val'][], isBalanceAdd?: boolean): (N | null | undefined)[];
51
51
  /**
52
52
  * The function returns the first node in a binary tree that matches the given property name and value.
53
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
53
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or a
54
54
  * generic type `N`. It represents the property of the binary tree node that you want to search for.
55
55
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
56
- * specifies the property name to use for searching the binary tree nodes. If not provided, it defaults to `'id'`.
57
- * @returns The method is returning either a BinaryTreeNodeId or N (generic type) or null.
56
+ * specifies the property name to use for searching the binary tree nodes. If not provided, it defaults to `'key'`.
57
+ * @returns The method is returning either a BinaryTreeNodeKey or N (generic type) or null.
58
58
  */
59
- get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
59
+ get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
60
60
  /**
61
- * The function returns the id of the rightmost node if the comparison between two values is less than, the id of the
62
- * leftmost node if the comparison is greater than, and the id of the rightmost node otherwise.
63
- * @returns The method `lastKey()` returns the id of the rightmost node in the binary tree if the comparison between
64
- * the values at index 0 and 1 is less than, otherwise it returns the id of the leftmost node. If the comparison is
65
- * equal, it returns the id of the rightmost node. If there are no nodes in the tree, it returns 0.
61
+ * The function returns the key of the rightmost node if the comparison between two values is less than, the key of the
62
+ * leftmost node if the comparison is greater than, and the key of the rightmost node otherwise.
63
+ * @returns The method `lastKey()` returns the key of the rightmost node in the binary tree if the comparison between
64
+ * the values at index 0 and 1 is less than, otherwise it returns the key of the leftmost node. If the comparison is
65
+ * equal, it returns the key of the rightmost node. If there are no nodes in the tree, it returns 0.
66
66
  */
67
- lastKey(): BinaryTreeNodeId;
67
+ lastKey(): BinaryTreeNodeKey;
68
68
  /**
69
69
  * The function `getNodes` returns an array of nodes in a binary tree that match a given property value.
70
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or an
70
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or an
71
71
  * `N` type. It represents the property of the binary tree node that you want to compare with.
72
72
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
73
- * specifies the property name to use for comparison. If not provided, it defaults to `'id'`.
73
+ * specifies the property name to use for comparison. If not provided, it defaults to `'key'`.
74
74
  * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
75
75
  * return only one node that matches the given `nodeProperty` or all nodes that match the `nodeProperty`. If `onlyOne`
76
76
  * is set to `true`, the function will return an array with only one node (if
77
77
  * @returns an array of nodes (type N).
78
78
  */
79
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
79
+ getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
80
80
  /**
81
81
  * The `lesserSum` function calculates the sum of property values in a binary tree for nodes that have a property value
82
82
  * less than a given node.
83
- * @param {N | BinaryTreeNodeId | null} beginNode - The `beginNode` parameter can be one of the following:
83
+ * @param {N | BinaryTreeNodeKey | null} beginNode - The `beginNode` parameter can be one of the following:
84
84
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
85
- * specifies the property name to use for calculating the sum. If not provided, it defaults to `'id'`.
85
+ * specifies the property name to use for calculating the sum. If not provided, it defaults to `'key'`.
86
86
  * @returns The function `lesserSum` returns a number, which represents the sum of the values of the nodes in the
87
87
  * binary tree that have a lesser value than the specified `beginNode` based on the `propertyName`.
88
88
  */
89
- lesserSum(beginNode: N | BinaryTreeNodeId | null, propertyName?: BinaryTreeNodePropertyName): number;
89
+ lesserSum(beginNode: N | BinaryTreeNodeKey | null, propertyName?: BinaryTreeNodePropertyName): number;
90
90
  /**
91
91
  * The `allGreaterNodesAdd` function adds a delta value to the specified property of all nodes in a binary tree that
92
92
  * have a greater value than a given node.
93
- * @param {N | BinaryTreeNodeId | null} node - The `node` parameter can be either of type `N` (a generic type),
94
- * `BinaryTreeNodeId`, or `null`. It represents the node in the binary tree to which the delta value will be added.
93
+ * @param {N | BinaryTreeNodeKey | null} node - The `node` parameter can be either of type `N` (a generic type),
94
+ * `BinaryTreeNodeKey`, or `null`. It represents the node in the binary tree to which the delta value will be added.
95
95
  * @param {number} delta - The `delta` parameter is a number that represents the amount by which the property value of
96
96
  * each greater node should be increased.
97
97
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
98
98
  * specifies the property name of the nodes in the binary tree that you want to update. If not provided, it defaults to
99
- * 'id'.
99
+ * 'key'.
100
100
  * @returns a boolean value.
101
101
  */
102
- allGreaterNodesAdd(node: N | BinaryTreeNodeId | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
102
+ allGreaterNodesAdd(node: N | BinaryTreeNodeKey | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
103
103
  /**
104
104
  * Balancing Adjustment:
105
105
  * Perfectly Balanced Binary Tree: Since the balance of a perfectly balanced binary tree is already fixed, no additional balancing adjustment is needed. Any insertion or deletion operation will disrupt the perfect balance, often requiring a complete reconstruction of the tree.
@@ -124,10 +124,10 @@ export declare class BST<N extends BSTNode<N['val'], N> = BSTNode> extends Binar
124
124
  /**
125
125
  * The function compares two binary tree node IDs using a comparator function and returns whether the first ID is
126
126
  * greater than, less than, or equal to the second ID.
127
- * @param {BinaryTreeNodeId} a - a is a BinaryTreeNodeId, which represents the identifier of a binary tree node.
128
- * @param {BinaryTreeNodeId} b - The parameter "b" in the above code refers to a BinaryTreeNodeId.
127
+ * @param {BinaryTreeNodeKey} a - a is a BinaryTreeNodeKey, which represents the identifier of a binary tree node.
128
+ * @param {BinaryTreeNodeKey} b - The parameter "b" in the above code refers to a BinaryTreeNodeKey.
129
129
  * @returns a value of type CP (ComparisonResult). The possible return values are CP.gt (greater than), CP.lt (less
130
130
  * than), or CP.eq (equal).
131
131
  */
132
- protected _compare(a: BinaryTreeNodeId, b: BinaryTreeNodeId): CP;
132
+ protected _compare(a: BinaryTreeNodeKey, b: BinaryTreeNodeKey): CP;
133
133
  }