directed-graph-typed 1.54.1 → 1.54.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +1 -1
  2. package/coverage/lcov-report/index.ts.html +2 -2
  3. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +21 -20
  4. package/dist/data-structures/binary-tree/avl-tree-counter.js +8 -7
  5. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -12
  6. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +2 -2
  7. package/dist/data-structures/binary-tree/avl-tree.d.ts +25 -21
  8. package/dist/data-structures/binary-tree/avl-tree.js +12 -8
  9. package/dist/data-structures/binary-tree/binary-tree.d.ts +173 -225
  10. package/dist/data-structures/binary-tree/binary-tree.js +239 -144
  11. package/dist/data-structures/binary-tree/bst.d.ts +62 -56
  12. package/dist/data-structures/binary-tree/bst.js +78 -122
  13. package/dist/data-structures/binary-tree/red-black-tree.d.ts +19 -25
  14. package/dist/data-structures/binary-tree/red-black-tree.js +7 -13
  15. package/dist/data-structures/binary-tree/tree-counter.d.ts +19 -19
  16. package/dist/data-structures/binary-tree/tree-counter.js +12 -12
  17. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +14 -14
  18. package/dist/data-structures/binary-tree/tree-multi-map.js +4 -4
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +2 -2
  21. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
  22. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  23. package/dist/types/data-structures/binary-tree/index.d.ts +1 -1
  24. package/dist/types/data-structures/binary-tree/index.js +1 -1
  25. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +1 -1
  26. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
  27. package/dist/utils/utils.d.ts +2 -2
  28. package/package.json +3 -3
  29. package/src/data-structures/binary-tree/avl-tree-counter.ts +30 -23
  30. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +25 -15
  31. package/src/data-structures/binary-tree/avl-tree.ts +35 -29
  32. package/src/data-structures/binary-tree/binary-tree.ts +469 -252
  33. package/src/data-structures/binary-tree/bst.ts +141 -143
  34. package/src/data-structures/binary-tree/red-black-tree.ts +27 -35
  35. package/src/data-structures/binary-tree/tree-counter.ts +33 -27
  36. package/src/data-structures/binary-tree/tree-multi-map.ts +25 -17
  37. package/src/index.ts +2 -2
  38. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -0
  39. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  40. package/src/types/data-structures/binary-tree/index.ts +1 -1
  41. package/src/types/data-structures/binary-tree/tree-counter.ts +1 -1
  42. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -1
  43. package/src/utils/utils.ts +2 -2
  44. /package/dist/types/data-structures/binary-tree/{rb-tree.d.ts → red-black-tree.d.ts} +0 -0
  45. /package/dist/types/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +0 -0
  46. /package/src/types/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
3
+ Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -83,8 +83,8 @@
83
83
  <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">/**
84
84
  * data-structure-typed
85
85
  *
86
- * @author Tyler Zeng
87
- * @copyright Copyright (c) 2022 Tyler Zeng &lt;zrwusa@gmail.com&gt;
86
+ * @author Pablo Zeng
87
+ * @copyright Copyright (c) 2022 Pablo Zeng &lt;zrwusa@gmail.com&gt;
88
88
  * @license MIT License
89
89
  */
90
90
  export { DirectedVertex, DirectedEdge, DirectedGraph, VertexId } from 'data-structure-typed';
@@ -5,10 +5,11 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { AVLTreeCounterOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType, OptNodeOrNull } from '../../types';
8
+ import type { AVLTreeCounterOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, EntryCallback, IterationType } from '../../types';
9
9
  import { IBinaryTree } from '../../interfaces';
10
10
  import { AVLTree, AVLTreeNode } from './avl-tree';
11
11
  export declare class AVLTreeCounterNode<K = any, V = any> extends AVLTreeNode<K, V> {
12
+ parent?: AVLTreeCounterNode<K, V>;
12
13
  /**
13
14
  * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
14
15
  * @param {K} key - The `key` parameter is of type `K` and represents the unique identifier
@@ -20,13 +21,12 @@ export declare class AVLTreeCounterNode<K = any, V = any> extends AVLTreeNode<K,
20
21
  * parameter when creating a new instance of the `BinaryTreeNode` class.
21
22
  */
22
23
  constructor(key: K, value?: V, count?: number);
23
- parent?: AVLTreeCounterNode<K, V>;
24
- _left?: OptNodeOrNull<AVLTreeCounterNode<K, V>>;
25
- get left(): OptNodeOrNull<AVLTreeCounterNode<K, V>>;
26
- set left(v: OptNodeOrNull<AVLTreeCounterNode<K, V>>);
27
- _right?: OptNodeOrNull<AVLTreeCounterNode<K, V>>;
28
- get right(): OptNodeOrNull<AVLTreeCounterNode<K, V>>;
29
- set right(v: OptNodeOrNull<AVLTreeCounterNode<K, V>>);
24
+ _left?: AVLTreeCounterNode<K, V> | null | undefined;
25
+ get left(): AVLTreeCounterNode<K, V> | null | undefined;
26
+ set left(v: AVLTreeCounterNode<K, V> | null | undefined);
27
+ _right?: AVLTreeCounterNode<K, V> | null | undefined;
28
+ get right(): AVLTreeCounterNode<K, V> | null | undefined;
29
+ set right(v: AVLTreeCounterNode<K, V> | null | undefined);
30
30
  }
31
31
  /**
32
32
  * The only distinction between a AVLTreeCounter and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
@@ -40,7 +40,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
40
40
  * behavior of the AVLTreeCounter. It can include properties such as `compareKeys` and
41
41
  * `compareValues` functions to define custom comparison logic for keys and values, respectively.
42
42
  */
43
- constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, AVLTreeCounterNode<K, V>> | R>, options?: AVLTreeCounterOptions<K, V, R>);
43
+ constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: AVLTreeCounterOptions<K, V, R>);
44
44
  protected _count: number;
45
45
  /**
46
46
  * The function calculates the sum of the count property of all nodes in a tree using depth-first
@@ -79,21 +79,21 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
79
79
  createTree(options?: AVLTreeCounterOptions<K, V, R>): AVLTreeCounter<K, V, R, MK, MV, MR>;
80
80
  /**
81
81
  * The function checks if the input is an instance of AVLTreeCounterNode.
82
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
83
- * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeCounterNode<K, V>>`.
82
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
83
+ * `keyNodeOrEntry` can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
84
84
  * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
85
85
  * an instance of the `AVLTreeCounterNode` class.
86
86
  */
87
- isNode(keyNodeOrEntry: BTNRep<K, V, AVLTreeCounterNode<K, V>>): keyNodeOrEntry is AVLTreeCounterNode<K, V>;
87
+ isNode(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is AVLTreeCounterNode<K, V>;
88
88
  /**
89
89
  * Time Complexity: O(log n)
90
90
  * Space Complexity: O(1)
91
91
  *
92
92
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
93
93
  * and update the count.
94
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The
94
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
95
95
  * `keyNodeOrEntry` parameter can accept a value of type `R`, which can be any type. It
96
- * can also accept a value of type `BTNRep<K, V, AVLTreeCounterNode<K, V>>`, which represents a key, node,
96
+ * can also accept a value of type `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`, which represents a key, node,
97
97
  * entry, or raw element
98
98
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
99
99
  * data structure. It is an optional parameter, so it can be omitted if not needed.
@@ -102,14 +102,14 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
102
102
  * be added once. However, you can specify a different value for `count` if you want to add
103
103
  * @returns a boolean value.
104
104
  */
105
- add(keyNodeOrEntry: BTNRep<K, V, AVLTreeCounterNode<K, V>>, value?: V, count?: number): boolean;
105
+ add(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): boolean;
106
106
  /**
107
107
  * Time Complexity: O(log n)
108
108
  * Space Complexity: O(1)
109
109
  *
110
110
  * The function overrides the delete method in a binary tree data structure, handling deletion of
111
111
  * nodes and maintaining balance in the tree.
112
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The `predicate`
112
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The `predicate`
113
113
  * parameter in the `delete` method is used to specify the condition for deleting a node from the
114
114
  * binary tree. It can be a key, node, or entry that determines which
115
115
  * node(s) should be deleted.
@@ -122,7 +122,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
122
122
  * method returns an array of `BinaryTreeDeleteResult` objects, each containing information about the
123
123
  * deleted node and whether balancing is needed in the tree.
124
124
  */
125
- delete(keyNodeOrEntry: BTNRep<K, V, AVLTreeCounterNode<K, V>>, ignoreCount?: boolean): BinaryTreeDeleteResult<AVLTreeCounterNode<K, V>>[];
125
+ delete(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, ignoreCount?: boolean): BinaryTreeDeleteResult<AVLTreeCounterNode<K, V>>[];
126
126
  /**
127
127
  * Time Complexity: O(1)
128
128
  * Space Complexity: O(1)
@@ -134,6 +134,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
134
134
  /**
135
135
  * Time Complexity: O(n log n)
136
136
  * Space Complexity: O(log n)
137
+ *
137
138
  * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
138
139
  * tree using either a recursive or iterative approach.
139
140
  * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
@@ -174,8 +175,8 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
174
175
  /**
175
176
  * The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into
176
177
  * a node object.
177
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The
178
- * `keyNodeOrEntry` parameter can be of type `R` or `BTNRep<K, V, AVLTreeCounterNode<K, V>>`.
178
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
179
+ * `keyNodeOrEntry` parameter can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
179
180
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
180
181
  * `override` function. It represents the value associated with the key in the data structure. If no
181
182
  * value is provided, it will default to `undefined`.
@@ -183,7 +184,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
183
184
  * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
184
185
  * @returns either a AVLTreeCounterNode<K, V> object or undefined.
185
186
  */
186
- protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: BTNRep<K, V, AVLTreeCounterNode<K, V>>, value?: V, count?: number): [AVLTreeCounterNode<K, V> | undefined, V | undefined];
187
+ protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): [AVLTreeCounterNode<K, V> | undefined, V | undefined];
187
188
  /**
188
189
  * Time Complexity: O(1)
189
190
  * Space Complexity: O(1)
@@ -105,8 +105,8 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
105
105
  }
106
106
  /**
107
107
  * The function checks if the input is an instance of AVLTreeCounterNode.
108
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The parameter
109
- * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeCounterNode<K, V>>`.
108
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
109
+ * `keyNodeOrEntry` can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
110
110
  * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
111
111
  * an instance of the `AVLTreeCounterNode` class.
112
112
  */
@@ -119,9 +119,9 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
119
119
  *
120
120
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
121
121
  * and update the count.
122
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The
122
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
123
123
  * `keyNodeOrEntry` parameter can accept a value of type `R`, which can be any type. It
124
- * can also accept a value of type `BTNRep<K, V, AVLTreeCounterNode<K, V>>`, which represents a key, node,
124
+ * can also accept a value of type `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`, which represents a key, node,
125
125
  * entry, or raw element
126
126
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
127
127
  * data structure. It is an optional parameter, so it can be omitted if not needed.
@@ -147,7 +147,7 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
147
147
  *
148
148
  * The function overrides the delete method in a binary tree data structure, handling deletion of
149
149
  * nodes and maintaining balance in the tree.
150
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The `predicate`
150
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The `predicate`
151
151
  * parameter in the `delete` method is used to specify the condition for deleting a node from the
152
152
  * binary tree. It can be a key, node, or entry that determines which
153
153
  * node(s) should be deleted.
@@ -232,6 +232,7 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
232
232
  /**
233
233
  * Time Complexity: O(n log n)
234
234
  * Space Complexity: O(log n)
235
+ *
235
236
  * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
236
237
  * tree using either a recursive or iterative approach.
237
238
  * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
@@ -329,8 +330,8 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
329
330
  /**
330
331
  * The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into
331
332
  * a node object.
332
- * @param {BTNRep<K, V, AVLTreeCounterNode<K, V>>} keyNodeOrEntry - The
333
- * `keyNodeOrEntry` parameter can be of type `R` or `BTNRep<K, V, AVLTreeCounterNode<K, V>>`.
333
+ * @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
334
+ * `keyNodeOrEntry` parameter can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
334
335
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
335
336
  * `override` function. It represents the value associated with the key in the data structure. If no
336
337
  * value is provided, it will default to `undefined`.
@@ -5,10 +5,11 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { AVLTreeMultiMapOptions, BTNRep, OptNodeOrNull } from '../../types';
8
+ import { AVLTreeMultiMapOptions } from '../../types';
9
9
  import { AVLTree, AVLTreeNode } from './avl-tree';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  export declare class AVLTreeMultiMapNode<K = any, V = any> extends AVLTreeNode<K, V[]> {
12
+ parent?: AVLTreeMultiMapNode<K, V>;
12
13
  /**
13
14
  * This TypeScript constructor initializes an object with a key of type K and an array of values of
14
15
  * type V.
@@ -19,13 +20,12 @@ export declare class AVLTreeMultiMapNode<K = any, V = any> extends AVLTreeNode<K
19
20
  * type `V`.
20
21
  */
21
22
  constructor(key: K, value: V[]);
22
- parent?: AVLTreeMultiMapNode<K, V>;
23
- _left?: OptNodeOrNull<AVLTreeMultiMapNode<K, V>>;
24
- get left(): OptNodeOrNull<AVLTreeMultiMapNode<K, V>>;
25
- set left(v: OptNodeOrNull<AVLTreeMultiMapNode<K, V>>);
26
- _right?: OptNodeOrNull<AVLTreeMultiMapNode<K, V>>;
27
- get right(): OptNodeOrNull<AVLTreeMultiMapNode<K, V>>;
28
- set right(v: OptNodeOrNull<AVLTreeMultiMapNode<K, V>>);
23
+ _left?: AVLTreeMultiMapNode<K, V> | null | undefined;
24
+ get left(): AVLTreeMultiMapNode<K, V> | null | undefined;
25
+ set left(v: AVLTreeMultiMapNode<K, V> | null | undefined);
26
+ _right?: AVLTreeMultiMapNode<K, V> | null | undefined;
27
+ get right(): AVLTreeMultiMapNode<K, V> | null | undefined;
28
+ set right(v: AVLTreeMultiMapNode<K, V> | null | undefined);
29
29
  }
30
30
  /**
31
31
  *
@@ -42,7 +42,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
42
42
  * `AVLTreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
43
43
  * additional options for configuring the AVLTreeMultiMap instance.
44
44
  */
45
- constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V[], AVLTreeMultiMapNode<K, V>> | R>, options?: AVLTreeMultiMapOptions<K, V[], R>);
45
+ constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | R>, options?: AVLTreeMultiMapOptions<K, V[], R>);
46
46
  /**
47
47
  * Time Complexity: O(1)
48
48
  * Space Complexity: O(1)
@@ -68,7 +68,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
68
68
  * empty array.
69
69
  */
70
70
  createNode(key: K): AVLTreeMultiMapNode<K, V>;
71
- add(node: BTNRep<K, V[], AVLTreeMultiMapNode<K, V>>): boolean;
71
+ add(node: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
72
72
  add(key: K, value: V): boolean;
73
73
  /**
74
74
  * Time Complexity: O(log n)
@@ -76,7 +76,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
76
76
  *
77
77
  * The function `deleteValue` removes a specific value from a key in an AVLTreeMultiMap data
78
78
  * structure and deletes the entire node if no values are left for that key.
79
- * @param {BTNRep<K, V[], AVLTreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
79
+ * @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
80
80
  * parameter in the `deleteValue` function can be either a `BTNRep` object representing a key-value
81
81
  * pair in the AVLTreeMultiMapNode, or just the key itself.
82
82
  * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
@@ -87,7 +87,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
87
87
  * `value` was successfully deleted from the array of values associated with the `keyNodeOrEntry`. If
88
88
  * the value was not found in the array, it returns `false`.
89
89
  */
90
- deleteValue(keyNodeOrEntry: BTNRep<K, V[], AVLTreeMultiMapNode<K, V>> | K, value: V): boolean;
90
+ deleteValue(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K, value: V): boolean;
91
91
  /**
92
92
  * Time Complexity: O(n)
93
93
  * Space Complexity: O(n)
@@ -94,7 +94,7 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
94
94
  *
95
95
  * The function `add` in TypeScript overrides the superclass method to add key-value pairs to an AVL
96
96
  * tree multi-map.
97
- * @param {BTNRep<K, V[], AVLTreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
97
+ * @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
98
98
  * parameter in the `override add` method can be either a key-value pair entry or just a key. If it
99
99
  * is a key-value pair entry, it will be in the format `[key, values]`, where `key` is the key and
100
100
  * `values`
@@ -147,7 +147,7 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
147
147
  *
148
148
  * The function `deleteValue` removes a specific value from a key in an AVLTreeMultiMap data
149
149
  * structure and deletes the entire node if no values are left for that key.
150
- * @param {BTNRep<K, V[], AVLTreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
150
+ * @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
151
151
  * parameter in the `deleteValue` function can be either a `BTNRep` object representing a key-value
152
152
  * pair in the AVLTreeMultiMapNode, or just the key itself.
153
153
  * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
@@ -6,9 +6,10 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, OptNodeOrNull } from '../../types';
9
+ import type { AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, EntryCallback } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  export declare class AVLTreeNode<K = any, V = any> extends BSTNode<K, V> {
12
+ parent?: AVLTreeNode<K, V>;
12
13
  /**
13
14
  * This TypeScript constructor function initializes an instance with a key and an optional value.
14
15
  * @param {K} key - The `key` parameter is typically used to uniquely identify an object or element
@@ -19,13 +20,12 @@ export declare class AVLTreeNode<K = any, V = any> extends BSTNode<K, V> {
19
20
  * default to `undefined`.
20
21
  */
21
22
  constructor(key: K, value?: V);
22
- parent?: AVLTreeNode<K, V>;
23
- _left?: OptNodeOrNull<AVLTreeNode<K, V>>;
24
- get left(): OptNodeOrNull<AVLTreeNode<K, V>>;
25
- set left(v: OptNodeOrNull<AVLTreeNode<K, V>>);
26
- _right?: OptNodeOrNull<AVLTreeNode<K, V>>;
27
- get right(): OptNodeOrNull<AVLTreeNode<K, V>>;
28
- set right(v: OptNodeOrNull<AVLTreeNode<K, V>>);
23
+ _left?: AVLTreeNode<K, V> | null | undefined;
24
+ get left(): AVLTreeNode<K, V> | null | undefined;
25
+ set left(v: AVLTreeNode<K, V> | null | undefined);
26
+ _right?: AVLTreeNode<K, V> | null | undefined;
27
+ get right(): AVLTreeNode<K, V> | null | undefined;
28
+ set right(v: AVLTreeNode<K, V> | null | undefined);
29
29
  }
30
30
  /**
31
31
  * 1. Height-Balanced: Each node's left and right subtrees differ in height by no more than one.
@@ -41,14 +41,15 @@ export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, M
41
41
  * This TypeScript constructor initializes an AVLTree with keys, nodes, entries, or raw data provided
42
42
  * in an iterable format.
43
43
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
44
- * iterable that can contain either `BTNRep<K, V, AVLTreeNode<K, V>>` objects or `R` objects. It is
44
+ * iterable that can contain either `
45
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` objects or `R` objects. It is
45
46
  * used to initialize the AVLTree with key-value pairs or raw data entries. If provided
46
47
  * @param [options] - The `options` parameter in the constructor is of type `AVLTreeOptions<K, V,
47
48
  * R>`. It is an optional parameter that allows you to specify additional options for configuring the
48
49
  * AVL tree. These options could include things like custom comparators, initial capacity, or any
49
50
  * other configuration settings specific
50
51
  */
51
- constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, AVLTreeNode<K, V>> | R>, options?: AVLTreeOptions<K, V, R>);
52
+ constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: AVLTreeOptions<K, V, R>);
52
53
  /**
53
54
  * Time Complexity: O(1)
54
55
  * Space Complexity: O(1)
@@ -78,39 +79,41 @@ export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, M
78
79
  * Space Complexity: O(1)
79
80
  *
80
81
  * The function checks if the input is an instance of AVLTreeNode.
81
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
82
- * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeNode<K, V>>`.
82
+ * @param {K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
83
+ * `keyNodeOrEntry` can be of type `R` or `
84
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `.
83
85
  * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
84
86
  * an instance of the `AVLTreeNode` class.
85
87
  */
86
- isNode(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): keyNodeOrEntry is AVLTreeNode<K, V>;
88
+ isNode(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is AVLTreeNode<K, V>;
87
89
  /**
88
90
  * Time Complexity: O(log n)
89
91
  * Space Complexity: O(log n)
90
92
  *
91
93
  * The function overrides the add method of a class and inserts a key-value pair into a data
92
94
  * structure, then balances the path.
93
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
94
- * `keyNodeOrEntry` can accept values of type `R`, `BTNRep<K, V, AVLTreeNode<K, V>>`
95
+ * @param { K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
96
+ * `keyNodeOrEntry` can accept values of type `R`, `
97
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `
95
98
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
96
99
  * the key or node being added to the data structure.
97
100
  * @returns The method is returning a boolean value.
98
101
  */
99
- add(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>, value?: V): boolean;
102
+ add(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
100
103
  /**
101
104
  * Time Complexity: O(log n)
102
105
  * Space Complexity: O(log n)
103
106
  *
104
107
  * The function overrides the delete method in a TypeScript class, performs deletion, and then
105
108
  * balances the tree if necessary.
106
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
109
+ * @param { K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
107
110
  * parameter in the `override delete` method can be one of the following types:
108
111
  * @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
109
112
  * method from the superclass (presumably a parent class) with the provided `predicate`, which could
110
113
  * be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
111
114
  * `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
112
115
  */
113
- delete(keyNodeOrEntry: BTNRep<K, V, AVLTreeNode<K, V>>): BinaryTreeDeleteResult<AVLTreeNode<K, V>>[];
116
+ delete(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): BinaryTreeDeleteResult<AVLTreeNode<K, V>>[];
114
117
  /**
115
118
  * Time Complexity: O(n)
116
119
  * Space Complexity: O(n)
@@ -213,10 +216,11 @@ export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, M
213
216
  *
214
217
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
215
218
  * to restore balance in an AVL tree after inserting a node.
216
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} node - The `node` parameter can be of type `R` or
217
- * `BTNRep<K, V, AVLTreeNode<K, V>>`.
219
+ * @param { K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } node - The `node` parameter can be of type `R` or
220
+ * `
221
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `.
218
222
  */
219
- protected _balancePath(node: BTNRep<K, V, AVLTreeNode<K, V>>): void;
223
+ protected _balancePath(node: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): void;
220
224
  /**
221
225
  * Time Complexity: O(1)
222
226
  * Space Complexity: O(1)
@@ -59,7 +59,8 @@ class AVLTree extends bst_1.BST {
59
59
  * This TypeScript constructor initializes an AVLTree with keys, nodes, entries, or raw data provided
60
60
  * in an iterable format.
61
61
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
62
- * iterable that can contain either `BTNRep<K, V, AVLTreeNode<K, V>>` objects or `R` objects. It is
62
+ * iterable that can contain either `
63
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` objects or `R` objects. It is
63
64
  * used to initialize the AVLTree with key-value pairs or raw data entries. If provided
64
65
  * @param [options] - The `options` parameter in the constructor is of type `AVLTreeOptions<K, V,
65
66
  * R>`. It is an optional parameter that allows you to specify additional options for configuring the
@@ -104,8 +105,9 @@ class AVLTree extends bst_1.BST {
104
105
  * Space Complexity: O(1)
105
106
  *
106
107
  * The function checks if the input is an instance of AVLTreeNode.
107
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
108
- * `keyNodeOrEntry` can be of type `R` or `BTNRep<K, V, AVLTreeNode<K, V>>`.
108
+ * @param {K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
109
+ * `keyNodeOrEntry` can be of type `R` or `
110
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `.
109
111
  * @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
110
112
  * an instance of the `AVLTreeNode` class.
111
113
  */
@@ -118,8 +120,9 @@ class AVLTree extends bst_1.BST {
118
120
  *
119
121
  * The function overrides the add method of a class and inserts a key-value pair into a data
120
122
  * structure, then balances the path.
121
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The parameter
122
- * `keyNodeOrEntry` can accept values of type `R`, `BTNRep<K, V, AVLTreeNode<K, V>>`
123
+ * @param { K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
124
+ * `keyNodeOrEntry` can accept values of type `R`, `
125
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `
123
126
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
124
127
  * the key or node being added to the data structure.
125
128
  * @returns The method is returning a boolean value.
@@ -138,7 +141,7 @@ class AVLTree extends bst_1.BST {
138
141
  *
139
142
  * The function overrides the delete method in a TypeScript class, performs deletion, and then
140
143
  * balances the tree if necessary.
141
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
144
+ * @param { K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
142
145
  * parameter in the `override delete` method can be one of the following types:
143
146
  * @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
144
147
  * method from the superclass (presumably a parent class) with the provided `predicate`, which could
@@ -464,8 +467,9 @@ class AVLTree extends bst_1.BST {
464
467
  *
465
468
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
466
469
  * to restore balance in an AVL tree after inserting a node.
467
- * @param {BTNRep<K, V, AVLTreeNode<K, V>>} node - The `node` parameter can be of type `R` or
468
- * `BTNRep<K, V, AVLTreeNode<K, V>>`.
470
+ * @param { K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } node - The `node` parameter can be of type `R` or
471
+ * `
472
+ K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `.
469
473
  */
470
474
  _balancePath(node) {
471
475
  node = this.ensureNode(node);