data-structure-typed 1.52.9 → 1.53.1

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 (65) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/benchmark/report.html +1 -37
  4. package/benchmark/report.json +24 -384
  5. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +21 -21
  6. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +64 -47
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +20 -20
  9. package/dist/cjs/data-structures/binary-tree/avl-tree.js +29 -27
  10. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +186 -144
  12. package/dist/cjs/data-structures/binary-tree/binary-tree.js +376 -265
  13. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/bst.d.ts +56 -56
  15. package/dist/cjs/data-structures/binary-tree/bst.js +108 -78
  16. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +13 -13
  18. package/dist/cjs/data-structures/binary-tree/rb-tree.js +42 -36
  19. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +21 -21
  21. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +59 -49
  22. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  23. package/dist/cjs/data-structures/trie/trie.js +3 -3
  24. package/dist/cjs/interfaces/binary-tree.d.ts +5 -5
  25. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +13 -13
  26. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -3
  27. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +21 -21
  28. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +64 -46
  29. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +20 -20
  30. package/dist/mjs/data-structures/binary-tree/avl-tree.js +29 -26
  31. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +186 -144
  32. package/dist/mjs/data-structures/binary-tree/binary-tree.js +376 -264
  33. package/dist/mjs/data-structures/binary-tree/bst.d.ts +56 -56
  34. package/dist/mjs/data-structures/binary-tree/bst.js +108 -76
  35. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +13 -13
  36. package/dist/mjs/data-structures/binary-tree/rb-tree.js +42 -35
  37. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +21 -21
  38. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +59 -48
  39. package/dist/mjs/data-structures/trie/trie.js +3 -3
  40. package/dist/mjs/interfaces/binary-tree.d.ts +5 -5
  41. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +13 -13
  42. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -3
  43. package/dist/umd/data-structure-typed.js +596 -468
  44. package/dist/umd/data-structure-typed.min.js +5 -5
  45. package/dist/umd/data-structure-typed.min.js.map +1 -1
  46. package/package.json +6 -6
  47. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +60 -54
  48. package/src/data-structures/binary-tree/avl-tree.ts +32 -35
  49. package/src/data-structures/binary-tree/binary-tree.ts +440 -360
  50. package/src/data-structures/binary-tree/bst.ts +144 -113
  51. package/src/data-structures/binary-tree/rb-tree.ts +44 -43
  52. package/src/data-structures/binary-tree/tree-multi-map.ts +57 -61
  53. package/src/data-structures/trie/trie.ts +3 -3
  54. package/src/interfaces/binary-tree.ts +6 -6
  55. package/src/types/data-structures/binary-tree/binary-tree.ts +13 -14
  56. package/src/types/data-structures/binary-tree/bst.ts +3 -3
  57. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +2 -2
  58. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +9 -1
  59. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +115 -3
  60. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +109 -4
  61. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +183 -46
  62. package/test/unit/data-structures/binary-tree/bst.test.ts +340 -21
  63. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +19 -0
  64. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +141 -3
  65. package/test/utils/array.ts +15 -12
@@ -1 +1 @@
1
- {"version":3,"file":"tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-multi-map.ts"],"names":[],"mappings":";;;AAoBA,uCAA2D;AAE3D,MAAa,gBAIX,SAAQ,0BAA4B;IACpC;;;;;;;;;;;OAWG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC,EAAE,QAAmB,OAAO;QAClE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAIjB,WAAM,GAAW,CAAC,CAAC;QAH3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AAxCD,4CAwCC;AAED,MAAa,YAOX,SAAQ,sBAAiC;IAGzC;;;;;;;;OAQG;IACH,YACE,6BAAwE,EAAE,EAC1E,OAAsC;QAEtC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAIX,WAAM,GAAG,CAAC,CAAC;QAHnB,IAAI,0BAA0B;YAAE,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC3E,CAAC;IAID,6DAA6D;IAC7D;;;OA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;QAC1D,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9C,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF;AArZD,oCAqZC"}
@@ -239,9 +239,9 @@ class Trie extends base_1.IterableElementBase {
239
239
  *
240
240
  */
241
241
  getHeight() {
242
- const beginRoot = this.root;
242
+ const startNode = this.root;
243
243
  let maxDepth = 0;
244
- if (beginRoot) {
244
+ if (startNode) {
245
245
  const bfs = (node, level) => {
246
246
  if (level > maxDepth) {
247
247
  maxDepth = level;
@@ -253,7 +253,7 @@ class Trie extends base_1.IterableElementBase {
253
253
  }
254
254
  }
255
255
  };
256
- bfs(beginRoot, 0);
256
+ bfs(startNode, 0);
257
257
  }
258
258
  return maxDepth;
259
259
  }
@@ -1,9 +1,9 @@
1
1
  import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
- import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNKeyOrNodeOrEntry, BTNPredicate } from '../types';
3
- export interface IBinaryTree<K = any, V = any, R = [K, V], NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
2
+ import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNRep, NodePredicate } from '../types';
3
+ export interface IBinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
4
4
  createNode(key: K, value?: NODE['value']): NODE;
5
5
  createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
6
- add(keyOrNodeOrEntryOrRawElement: BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
7
- addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
8
- delete(predicate: R | BTNKeyOrNodeOrEntry<K, V, NODE> | BTNPredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
6
+ add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;
7
+ addMany(nodes: Iterable<BTNRep<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
8
+ delete(predicate: R | BTNRep<K, V, NODE> | NodePredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
9
9
  }
@@ -3,29 +3,29 @@ import { IterationType, OptValue } from '../../common';
3
3
  import { DFSOperation } from '../../../constants';
4
4
  export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
5
  export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
+ export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;
6
7
  export type BinaryTreeOptions<K, V, R> = {
7
8
  iterationType?: IterationType;
8
- toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
9
+ toEntryFn?: ToEntryFn<K, V, R>;
10
+ isMapMode?: boolean;
9
11
  };
10
12
  export type BinaryTreePrintOptions = {
11
13
  isShowUndefined?: boolean;
12
14
  isShowNull?: boolean;
13
15
  isShowRedBlackNIL?: boolean;
14
16
  };
15
- export type OptBTNOrNull<NODE> = NODE | null | undefined;
16
- export type OptBTNKeyOrNull<K> = K | null | undefined;
17
- export type BTNEntry<K, V> = [OptBTNKeyOrNull<K>, OptValue<V>];
18
- export type BTNKeyOrNode<K, NODE> = OptBTNKeyOrNull<K> | NODE;
19
- export type BTNKeyOrNodeOrEntry<K, V, NODE> = BTNEntry<K, V> | BTNKeyOrNode<K, NODE>;
20
- export type BTNPureKeyOrNode<K, NODE> = K | NODE;
21
- export type BTNPureKeyOrNodeOrEntry<K, V, NODE> = [K, OptValue<V>] | BTNPureKeyOrNode<K, NODE>;
17
+ export type OptNodeOrNull<NODE> = NODE | null | undefined;
18
+ export type BTNOptKeyOrNull<K> = K | null | undefined;
19
+ export type BTNEntry<K, V> = [BTNOptKeyOrNull<K>, OptValue<V>];
20
+ export type BTNOptKeyNodeOrNull<K, NODE> = BTNOptKeyOrNull<K> | NODE;
21
+ export type BTNRep<K, V, NODE> = BTNEntry<K, V> | BTNOptKeyNodeOrNull<K, NODE>;
22
22
  export type BinaryTreeDeleteResult<NODE> = {
23
- deleted: OptBTNOrNull<NODE>;
24
- needBalanced: OptBTNOrNull<NODE>;
23
+ deleted: OptNodeOrNull<NODE>;
24
+ needBalanced: OptNodeOrNull<NODE>;
25
25
  };
26
- export type BTNCallback<NODE, D = any> = (node: NODE) => D;
27
- export type BTNPredicate<NODE> = (node: NODE) => boolean;
26
+ export type NodeCallback<NODE, D = any> = (node: NODE) => D;
27
+ export type NodePredicate<NODE> = (node: NODE) => boolean;
28
28
  export type DFSStackItem<NODE> = {
29
29
  opt: DFSOperation;
30
- node: OptBTNOrNull<NODE>;
30
+ node: OptNodeOrNull<NODE>;
31
31
  };
@@ -6,6 +6,6 @@ export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R,
6
6
  export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
7
7
  comparator?: Comparator<K>;
8
8
  };
9
- export type OptBSTNKey<K> = K | undefined;
10
- export type OptBSTN<NODE> = NODE | undefined;
11
- export type BSTNKeyOrNode<K, NODE> = OptBSTNKey<K> | NODE;
9
+ export type BSTNOptKey<K> = K | undefined;
10
+ export type OptNode<NODE> = NODE | undefined;
11
+ export type BSTNOptKeyOrNode<K, NODE> = BSTNOptKey<K> | NODE;
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNKeyOrNodeOrEntry, IterationType, BTNEntry } from '../../types';
8
+ import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, IterationType } from '../../types';
9
9
  import { IBinaryTree } from '../../interfaces';
10
10
  import { AVLTree, AVLTreeNode } from './avl-tree';
11
11
  export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
@@ -36,16 +36,16 @@ export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeM
36
36
  /**
37
37
  * The only distinction between a AVLTreeMultiMap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
38
38
  */
39
- export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, R, NODE, TREE> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMapNested<K, V, R, NODE>>> extends AVLTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
39
+ export declare class AVLTreeMultiMap<K = any, V = any, R = object, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, R, NODE, TREE> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMapNested<K, V, R, NODE>>> extends AVLTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
40
40
  /**
41
41
  * The constructor initializes a new AVLTreeMultiMap object with optional initial elements.
42
- * @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` parameter is an
42
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
43
43
  * iterable object that can contain either keys, nodes, entries, or raw elements.
44
44
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
45
45
  * behavior of the AVLTreeMultiMap. It can include properties such as `compareKeys` and
46
46
  * `compareValues` functions to define custom comparison logic for keys and values, respectively.
47
47
  */
48
- constructor(keysOrNodesOrEntriesOrRaws?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
48
+ constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
49
49
  protected _count: number;
50
50
  /**
51
51
  * The function calculates the sum of the count property of all nodes in a tree using depth-first
@@ -84,17 +84,17 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
84
84
  createTree(options?: AVLTreeMultiMapOptions<K, V, R>): TREE;
85
85
  /**
86
86
  * The function checks if the input is an instance of AVLTreeMultiMapNode.
87
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
88
- * `keyOrNodeOrEntryOrRaw` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
89
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRaw` is
87
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
88
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
89
+ * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
90
90
  * an instance of the `AVLTreeMultiMapNode` class.
91
91
  */
92
- isNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R): keyOrNodeOrEntryOrRaw is NODE;
92
+ isNode(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): keyNodeEntryOrRaw is NODE;
93
93
  /**
94
- * The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
94
+ * The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into
95
95
  * a node object.
96
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The
97
- * `keyOrNodeOrEntryOrRaw` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
96
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
97
+ * `keyNodeEntryOrRaw` parameter can be of type `R` or `BTNRep<K, V, NODE>`.
98
98
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
99
99
  * `override` function. It represents the value associated with the key in the data structure. If no
100
100
  * value is provided, it will default to `undefined`.
@@ -102,16 +102,16 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
102
102
  * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
103
103
  * @returns either a NODE object or undefined.
104
104
  */
105
- keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V, count?: number): NODE | undefined;
105
+ keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
106
106
  /**
107
107
  * Time Complexity: O(log n)
108
108
  * Space Complexity: O(1)
109
109
  *
110
110
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
111
111
  * and update the count.
112
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The
113
- * `keyOrNodeOrEntryOrRaw` parameter can accept a value of type `R`, which can be any type. It
114
- * can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
112
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
113
+ * `keyNodeEntryOrRaw` parameter can accept a value of type `R`, which can be any type. It
114
+ * can also accept a value of type `BTNRep<K, V, NODE>`, which represents a key, node,
115
115
  * entry, or raw element
116
116
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
117
117
  * data structure. It is an optional parameter, so it can be omitted if not needed.
@@ -120,14 +120,14 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
120
120
  * be added once. However, you can specify a different value for `count` if you want to add
121
121
  * @returns a boolean value.
122
122
  */
123
- add(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V, count?: number): boolean;
123
+ add(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): boolean;
124
124
  /**
125
125
  * Time Complexity: O(log n)
126
126
  * Space Complexity: O(1)
127
127
  *
128
128
  * The function overrides the delete method in a binary tree data structure, handling deletion of
129
129
  * nodes and maintaining balance in the tree.
130
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The `predicate`
130
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `predicate`
131
131
  * parameter in the `delete` method is used to specify the condition for deleting a node from the
132
132
  * binary tree. It can be a key, node, or entry that determines which
133
133
  * node(s) should be deleted.
@@ -140,7 +140,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
140
140
  * method returns an array of `BinaryTreeDeleteResult` objects, each containing information about the
141
141
  * deleted node and whether balancing is needed in the tree.
142
142
  */
143
- delete(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
143
+ delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
144
144
  /**
145
145
  * Time Complexity: O(1)
146
146
  * Space Complexity: O(1)
@@ -176,14 +176,14 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
176
176
  *
177
177
  * The `_swapProperties` function swaps the properties (key, value, count, height) between two nodes
178
178
  * in a binary search tree.
179
- * @param {R | BSTNKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
179
+ * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
180
180
  * that will be swapped with the `destNode`.
181
- * @param {R | BSTNKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
181
+ * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
182
182
  * node where the properties will be swapped with the source node.
183
183
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
184
184
  * If either `srcNode` or `destNode` is undefined, it returns `undefined`.
185
185
  */
186
- protected _swapProperties(srcNode: R | BSTNKeyOrNode<K, NODE>, destNode: R | BSTNKeyOrNode<K, NODE>): NODE | undefined;
186
+ protected _swapProperties(srcNode: R | BSTNOptKeyOrNode<K, NODE>, destNode: R | BSTNOptKeyOrNode<K, NODE>): NODE | undefined;
187
187
  /**
188
188
  * Time Complexity: O(1)
189
189
  * Space Complexity: O(1)
@@ -37,16 +37,16 @@ export class AVLTreeMultiMapNode extends AVLTreeNode {
37
37
  export class AVLTreeMultiMap extends AVLTree {
38
38
  /**
39
39
  * The constructor initializes a new AVLTreeMultiMap object with optional initial elements.
40
- * @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` parameter is an
40
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
41
41
  * iterable object that can contain either keys, nodes, entries, or raw elements.
42
42
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
43
43
  * behavior of the AVLTreeMultiMap. It can include properties such as `compareKeys` and
44
44
  * `compareValues` functions to define custom comparison logic for keys and values, respectively.
45
45
  */
46
- constructor(keysOrNodesOrEntriesOrRaws = [], options) {
46
+ constructor(keysNodesEntriesOrRaws = [], options) {
47
47
  super([], options);
48
- if (keysOrNodesOrEntriesOrRaws)
49
- this.addMany(keysOrNodesOrEntriesOrRaws);
48
+ if (keysNodesEntriesOrRaws)
49
+ this.addMany(keysNodesEntriesOrRaws);
50
50
  }
51
51
  _count = 0;
52
52
  /**
@@ -82,7 +82,7 @@ export class AVLTreeMultiMap extends AVLTree {
82
82
  * @returns a new instance of the AVLTreeMultiMapNode class, casted as NODE.
83
83
  */
84
84
  createNode(key, value, count) {
85
- return new AVLTreeMultiMapNode(key, value, count);
85
+ return new AVLTreeMultiMapNode(key, this._isMapMode ? undefined : value, count);
86
86
  }
87
87
  /**
88
88
  * The function creates a new AVLTreeMultiMap object with the specified options and returns it.
@@ -94,6 +94,7 @@ export class AVLTreeMultiMap extends AVLTree {
94
94
  createTree(options) {
95
95
  return new AVLTreeMultiMap([], {
96
96
  iterationType: this.iterationType,
97
+ isMapMode: this._isMapMode,
97
98
  comparator: this._comparator,
98
99
  toEntryFn: this._toEntryFn,
99
100
  ...options
@@ -101,19 +102,19 @@ export class AVLTreeMultiMap extends AVLTree {
101
102
  }
102
103
  /**
103
104
  * The function checks if the input is an instance of AVLTreeMultiMapNode.
104
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
105
- * `keyOrNodeOrEntryOrRaw` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
106
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRaw` is
105
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
106
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
107
+ * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
107
108
  * an instance of the `AVLTreeMultiMapNode` class.
108
109
  */
109
- isNode(keyOrNodeOrEntryOrRaw) {
110
- return keyOrNodeOrEntryOrRaw instanceof AVLTreeMultiMapNode;
110
+ isNode(keyNodeEntryOrRaw) {
111
+ return keyNodeEntryOrRaw instanceof AVLTreeMultiMapNode;
111
112
  }
112
113
  /**
113
- * The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
114
+ * The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into
114
115
  * a node object.
115
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The
116
- * `keyOrNodeOrEntryOrRaw` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
116
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
117
+ * `keyNodeEntryOrRaw` parameter can be of type `R` or `BTNRep<K, V, NODE>`.
117
118
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
118
119
  * `override` function. It represents the value associated with the key in the data structure. If no
119
120
  * value is provided, it will default to `undefined`.
@@ -121,26 +122,30 @@ export class AVLTreeMultiMap extends AVLTree {
121
122
  * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
122
123
  * @returns either a NODE object or undefined.
123
124
  */
124
- keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw, value, count = 1) {
125
- if (keyOrNodeOrEntryOrRaw === undefined || keyOrNodeOrEntryOrRaw === null)
126
- return;
127
- if (this.isNode(keyOrNodeOrEntryOrRaw))
128
- return keyOrNodeOrEntryOrRaw;
129
- if (this.isEntry(keyOrNodeOrEntryOrRaw)) {
130
- const [key, entryValue] = keyOrNodeOrEntryOrRaw;
125
+ keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
126
+ if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
127
+ return [undefined, undefined];
128
+ if (this.isNode(keyNodeEntryOrRaw))
129
+ return [keyNodeEntryOrRaw, value];
130
+ if (this.isEntry(keyNodeEntryOrRaw)) {
131
+ const [key, entryValue] = keyNodeEntryOrRaw;
131
132
  if (key === undefined || key === null)
132
- return;
133
- if (this.isKey(key))
134
- return this.createNode(key, value ?? entryValue, count);
133
+ return [undefined, undefined];
134
+ const finalValue = value ?? entryValue;
135
+ return [this.createNode(key, finalValue, count), finalValue];
135
136
  }
136
- if (this._toEntryFn) {
137
- const [key, entryValue] = this._toEntryFn(keyOrNodeOrEntryOrRaw);
138
- if (this.isKey(key))
139
- return this.createNode(key, value ?? entryValue, count);
137
+ if (this.isKey(keyNodeEntryOrRaw))
138
+ return [this.createNode(keyNodeEntryOrRaw, value, count), value];
139
+ if (this.isRaw(keyNodeEntryOrRaw)) {
140
+ if (this._toEntryFn) {
141
+ const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
142
+ const finalValue = value ?? entryValue;
143
+ if (this.isKey(key))
144
+ return [this.createNode(key, finalValue, count), finalValue];
145
+ }
146
+ return [undefined, undefined];
140
147
  }
141
- if (this.isKey(keyOrNodeOrEntryOrRaw))
142
- return this.createNode(keyOrNodeOrEntryOrRaw, value, count);
143
- return;
148
+ return [undefined, undefined];
144
149
  }
145
150
  /**
146
151
  * Time Complexity: O(log n)
@@ -148,9 +153,9 @@ export class AVLTreeMultiMap extends AVLTree {
148
153
  *
149
154
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
150
155
  * and update the count.
151
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The
152
- * `keyOrNodeOrEntryOrRaw` parameter can accept a value of type `R`, which can be any type. It
153
- * can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
156
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
157
+ * `keyNodeEntryOrRaw` parameter can accept a value of type `R`, which can be any type. It
158
+ * can also accept a value of type `BTNRep<K, V, NODE>`, which represents a key, node,
154
159
  * entry, or raw element
155
160
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
156
161
  * data structure. It is an optional parameter, so it can be omitted if not needed.
@@ -159,12 +164,12 @@ export class AVLTreeMultiMap extends AVLTree {
159
164
  * be added once. However, you can specify a different value for `count` if you want to add
160
165
  * @returns a boolean value.
161
166
  */
162
- add(keyOrNodeOrEntryOrRaw, value, count = 1) {
163
- const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw, value, count);
167
+ add(keyNodeEntryOrRaw, value, count = 1) {
168
+ const [newNode, newValue] = this.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count);
164
169
  if (newNode === undefined)
165
170
  return false;
166
171
  const orgNodeCount = newNode?.count || 0;
167
- const inserted = super.add(newNode);
172
+ const inserted = super.add(newNode, newValue);
168
173
  if (inserted) {
169
174
  this._count += orgNodeCount;
170
175
  }
@@ -176,7 +181,7 @@ export class AVLTreeMultiMap extends AVLTree {
176
181
  *
177
182
  * The function overrides the delete method in a binary tree data structure, handling deletion of
178
183
  * nodes and maintaining balance in the tree.
179
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The `predicate`
184
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `predicate`
180
185
  * parameter in the `delete` method is used to specify the condition for deleting a node from the
181
186
  * binary tree. It can be a key, node, or entry that determines which
182
187
  * node(s) should be deleted.
@@ -189,11 +194,11 @@ export class AVLTreeMultiMap extends AVLTree {
189
194
  * method returns an array of `BinaryTreeDeleteResult` objects, each containing information about the
190
195
  * deleted node and whether balancing is needed in the tree.
191
196
  */
192
- delete(keyOrNodeOrEntryOrRaw, ignoreCount = false) {
197
+ delete(keyNodeEntryOrRaw, ignoreCount = false) {
193
198
  const deletedResult = [];
194
199
  if (!this.root)
195
200
  return deletedResult;
196
- const curr = this.getNode(keyOrNodeOrEntryOrRaw) ?? undefined;
201
+ const curr = this.getNode(keyNodeEntryOrRaw) ?? undefined;
197
202
  if (!curr)
198
203
  return deletedResult;
199
204
  const parent = curr?.parent ? curr.parent : undefined;
@@ -280,7 +285,10 @@ export class AVLTreeMultiMap extends AVLTree {
280
285
  return;
281
286
  const m = l + Math.floor((r - l) / 2);
282
287
  const midNode = sorted[m];
283
- this.add(midNode.key, midNode.value, midNode.count);
288
+ if (this._isMapMode)
289
+ this.add(midNode.key, undefined, midNode.count);
290
+ else
291
+ this.add(midNode.key, midNode.value, midNode.count);
284
292
  buildBalanceBST(l, m - 1);
285
293
  buildBalanceBST(m + 1, r);
286
294
  };
@@ -296,7 +304,10 @@ export class AVLTreeMultiMap extends AVLTree {
296
304
  if (l <= r) {
297
305
  const m = l + Math.floor((r - l) / 2);
298
306
  const midNode = sorted[m];
299
- this.add(midNode.key, midNode.value, midNode.count);
307
+ if (this._isMapMode)
308
+ this.add(midNode.key, undefined, midNode.count);
309
+ else
310
+ this.add(midNode.key, midNode.value, midNode.count);
300
311
  stack.push([m + 1, r]);
301
312
  stack.push([l, m - 1]);
302
313
  }
@@ -314,7 +325,12 @@ export class AVLTreeMultiMap extends AVLTree {
314
325
  */
315
326
  clone() {
316
327
  const cloned = this.createTree();
317
- this.bfs(node => cloned.add(node.key, node.value, node.count));
328
+ if (this._isMapMode)
329
+ this.bfs(node => cloned.add(node.key, undefined, node.count));
330
+ else
331
+ this.bfs(node => cloned.add(node.key, node.value, node.count));
332
+ if (this._isMapMode)
333
+ cloned._store = this._store;
318
334
  return cloned;
319
335
  }
320
336
  /**
@@ -323,9 +339,9 @@ export class AVLTreeMultiMap extends AVLTree {
323
339
  *
324
340
  * The `_swapProperties` function swaps the properties (key, value, count, height) between two nodes
325
341
  * in a binary search tree.
326
- * @param {R | BSTNKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
342
+ * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
327
343
  * that will be swapped with the `destNode`.
328
- * @param {R | BSTNKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
344
+ * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
329
345
  * node where the properties will be swapped with the source node.
330
346
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
331
347
  * If either `srcNode` or `destNode` is undefined, it returns `undefined`.
@@ -339,11 +355,13 @@ export class AVLTreeMultiMap extends AVLTree {
339
355
  if (tempNode) {
340
356
  tempNode.height = height;
341
357
  destNode.key = srcNode.key;
342
- destNode.value = srcNode.value;
358
+ if (!this._isMapMode)
359
+ destNode.value = srcNode.value;
343
360
  destNode.count = srcNode.count;
344
361
  destNode.height = srcNode.height;
345
362
  srcNode.key = tempNode.key;
346
- srcNode.value = tempNode.value;
363
+ if (!this._isMapMode)
364
+ srcNode.value = tempNode.value;
347
365
  srcNode.count = tempNode.count;
348
366
  srcNode.height = tempNode.height;
349
367
  }
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNKeyOrNodeOrEntry, BTNEntry } from '../../types';
9
+ import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep } 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
  /**
@@ -40,11 +40,11 @@ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V
40
40
  * 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
41
41
  * 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
42
  */
43
- export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, R, NODE, TREE> = AVLTree<K, V, R, NODE, AVLTreeNested<K, V, R, NODE>>> extends BST<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
43
+ export declare class AVLTree<K = any, V = any, R = object, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, R, NODE, TREE> = AVLTree<K, V, R, NODE, AVLTreeNested<K, V, R, NODE>>> extends BST<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
44
44
  /**
45
45
  * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,
46
46
  * entries, or raw elements.
47
- * @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` parameter is an
47
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
48
48
  * iterable object that can contain either keys, nodes, entries, or raw elements. These elements will
49
49
  * be used to initialize the AVLTree.
50
50
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
@@ -52,7 +52,7 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
52
52
  * keys), `allowDuplicates` (a boolean indicating whether duplicate keys are allowed), and
53
53
  * `nodeBuilder` (
54
54
  */
55
- constructor(keysOrNodesOrEntriesOrRaws?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
55
+ constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
56
56
  /**
57
57
  * The function creates a new AVL tree node with the given key and value.
58
58
  * @param {K} key - The key parameter is of type K, which represents the key of the node being
@@ -73,54 +73,54 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
73
73
  createTree(options?: AVLTreeOptions<K, V, R>): TREE;
74
74
  /**
75
75
  * The function checks if the input is an instance of AVLTreeNode.
76
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
77
- * `keyOrNodeOrEntryOrRaw` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
78
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRaw` is
76
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
77
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
78
+ * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
79
79
  * an instance of the `AVLTreeNode` class.
80
80
  */
81
- isNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R): keyOrNodeOrEntryOrRaw is NODE;
81
+ isNode(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): keyNodeEntryOrRaw is NODE;
82
82
  /**
83
83
  * Time Complexity: O(log n)
84
84
  * Space Complexity: O(1)
85
85
  *
86
86
  * The function overrides the add method of a class and inserts a key-value pair into a data
87
87
  * structure, then balances the path.
88
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
89
- * `keyOrNodeOrEntryOrRaw` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
88
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
89
+ * `keyNodeEntryOrRaw` can accept values of type `R`, `BTNRep<K, V, NODE>`, or
90
90
  * `RawElement`.
91
91
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
92
92
  * the key or node being added to the data structure.
93
93
  * @returns The method is returning a boolean value.
94
94
  */
95
- add(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V): boolean;
95
+ add(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): boolean;
96
96
  /**
97
97
  * Time Complexity: O(log n)
98
98
  * Space Complexity: O(1)
99
99
  *
100
100
  * The function overrides the delete method in a TypeScript class, performs deletion, and then
101
101
  * balances the tree if necessary.
102
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The `keyOrNodeOrEntryOrRaw`
102
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `keyNodeEntryOrRaw`
103
103
  * parameter in the `override delete` method can be one of the following types:
104
104
  * @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
105
105
  * method from the superclass (presumably a parent class) with the provided `predicate`, which could
106
106
  * be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
107
107
  * `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
108
108
  */
109
- delete(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R): BinaryTreeDeleteResult<NODE>[];
109
+ delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): BinaryTreeDeleteResult<NODE>[];
110
110
  /**
111
111
  * Time Complexity: O(1)
112
112
  * Space Complexity: O(1)
113
113
  *
114
114
  * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a
115
115
  * binary search tree.
116
- * @param {R | BSTNKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents either a node
116
+ * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents either a node
117
117
  * object (`NODE`) or a key-value pair (`R`) that is being swapped with another node.
118
- * @param {R | BSTNKeyOrNode<K, NODE>} destNode - The `destNode` parameter is either an instance of
119
- * `R` or an instance of `BSTNKeyOrNode<K, NODE>`.
118
+ * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter is either an instance of
119
+ * `R` or an instance of `BSTNOptKeyOrNode<K, NODE>`.
120
120
  * @returns The method is returning the `destNodeEnsured` object if both `srcNodeEnsured` and
121
121
  * `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
122
122
  */
123
- protected _swapProperties(srcNode: R | BSTNKeyOrNode<K, NODE>, destNode: R | BSTNKeyOrNode<K, NODE>): NODE | undefined;
123
+ protected _swapProperties(srcNode: R | BSTNOptKeyOrNode<K, NODE>, destNode: R | BSTNOptKeyOrNode<K, NODE>): NODE | undefined;
124
124
  /**
125
125
  * Time Complexity: O(1)
126
126
  * Space Complexity: O(1)
@@ -179,10 +179,10 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
179
179
  *
180
180
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
181
181
  * to restore balance in an AVL tree after inserting a node.
182
- * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} node - The `node` parameter can be of type `R` or
183
- * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
182
+ * @param {BTNRep<K, V, NODE> | R} node - The `node` parameter can be of type `R` or
183
+ * `BTNRep<K, V, NODE>`.
184
184
  */
185
- protected _balancePath(node: BTNKeyOrNodeOrEntry<K, V, NODE> | R): void;
185
+ protected _balancePath(node: BTNRep<K, V, NODE> | R): void;
186
186
  /**
187
187
  * Time Complexity: O(1)
188
188
  * Space Complexity: O(1)