data-structure-typed 1.52.5 → 1.52.7

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 (181) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +33 -30
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +156 -156
  5. package/dist/cjs/constants/index.d.ts +4 -0
  6. package/dist/cjs/constants/index.js +9 -0
  7. package/dist/cjs/constants/index.js.map +1 -0
  8. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +8 -1
  9. package/dist/cjs/data-structures/base/iterable-element-base.js +10 -1
  10. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
  11. package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +8 -1
  12. package/dist/cjs/data-structures/base/iterable-entry-base.js +10 -10
  13. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
  15. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +43 -44
  16. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +23 -24
  18. package/dist/cjs/data-structures/binary-tree/avl-tree.js +71 -64
  19. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +2 -2
  21. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +534 -402
  22. package/dist/cjs/data-structures/binary-tree/binary-tree.js +669 -598
  23. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  24. package/dist/cjs/data-structures/binary-tree/bst.d.ts +72 -65
  25. package/dist/cjs/data-structures/binary-tree/bst.js +115 -113
  26. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  27. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +21 -24
  28. package/dist/cjs/data-structures/binary-tree/rb-tree.js +40 -39
  29. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  30. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +2 -2
  31. package/dist/cjs/data-structures/binary-tree/segment-tree.js +2 -2
  32. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +28 -31
  33. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +44 -43
  34. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  35. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +2 -2
  36. package/dist/cjs/data-structures/graph/abstract-graph.js +7 -4
  37. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  38. package/dist/cjs/data-structures/graph/directed-graph.d.ts +2 -2
  39. package/dist/cjs/data-structures/graph/directed-graph.js +4 -2
  40. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  41. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +2 -2
  42. package/dist/cjs/data-structures/hash/hash-map.d.ts +2 -2
  43. package/dist/cjs/data-structures/hash/hash-map.js +1 -1
  44. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  45. package/dist/cjs/data-structures/heap/heap.js +3 -3
  46. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
  48. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +7 -7
  49. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  51. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +6 -6
  52. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  53. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  54. package/dist/cjs/data-structures/matrix/matrix.d.ts +2 -2
  55. package/dist/cjs/data-structures/matrix/navigator.d.ts +2 -2
  56. package/dist/cjs/data-structures/matrix/navigator.js +4 -2
  57. package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
  58. package/dist/cjs/data-structures/queue/deque.d.ts +3 -3
  59. package/dist/cjs/data-structures/queue/deque.js +29 -29
  60. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  61. package/dist/cjs/data-structures/queue/queue.d.ts +1 -1
  62. package/dist/cjs/data-structures/stack/stack.d.ts +2 -2
  63. package/dist/cjs/data-structures/tree/tree.js +2 -0
  64. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  65. package/dist/cjs/data-structures/trie/trie.d.ts +2 -2
  66. package/dist/cjs/data-structures/trie/trie.js +1 -1
  67. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  68. package/dist/cjs/index.d.ts +1 -0
  69. package/dist/cjs/index.js +1 -0
  70. package/dist/cjs/index.js.map +1 -1
  71. package/dist/cjs/interfaces/binary-tree.d.ts +2 -2
  72. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
  73. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -6
  74. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
  75. package/dist/mjs/constants/index.d.ts +4 -0
  76. package/dist/mjs/constants/index.js +5 -0
  77. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +8 -1
  78. package/dist/mjs/data-structures/base/iterable-element-base.js +10 -1
  79. package/dist/mjs/data-structures/base/iterable-entry-base.d.ts +8 -1
  80. package/dist/mjs/data-structures/base/iterable-entry-base.js +10 -10
  81. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
  82. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +44 -44
  83. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +23 -24
  84. package/dist/mjs/data-structures/binary-tree/avl-tree.js +72 -64
  85. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +2 -2
  86. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +534 -402
  87. package/dist/mjs/data-structures/binary-tree/binary-tree.js +668 -592
  88. package/dist/mjs/data-structures/binary-tree/bst.d.ts +72 -65
  89. package/dist/mjs/data-structures/binary-tree/bst.js +116 -112
  90. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +21 -24
  91. package/dist/mjs/data-structures/binary-tree/rb-tree.js +41 -38
  92. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +2 -2
  93. package/dist/mjs/data-structures/binary-tree/segment-tree.js +2 -2
  94. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +28 -31
  95. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +45 -42
  96. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +2 -2
  97. package/dist/mjs/data-structures/graph/abstract-graph.js +7 -4
  98. package/dist/mjs/data-structures/graph/directed-graph.d.ts +2 -2
  99. package/dist/mjs/data-structures/graph/directed-graph.js +4 -2
  100. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +2 -2
  101. package/dist/mjs/data-structures/hash/hash-map.d.ts +2 -2
  102. package/dist/mjs/data-structures/hash/hash-map.js +1 -1
  103. package/dist/mjs/data-structures/heap/heap.js +3 -3
  104. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
  105. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +7 -7
  106. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  107. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +6 -6
  108. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  109. package/dist/mjs/data-structures/matrix/matrix.d.ts +2 -2
  110. package/dist/mjs/data-structures/matrix/navigator.d.ts +2 -2
  111. package/dist/mjs/data-structures/matrix/navigator.js +4 -2
  112. package/dist/mjs/data-structures/queue/deque.d.ts +3 -3
  113. package/dist/mjs/data-structures/queue/deque.js +29 -29
  114. package/dist/mjs/data-structures/queue/queue.d.ts +1 -1
  115. package/dist/mjs/data-structures/stack/stack.d.ts +2 -2
  116. package/dist/mjs/data-structures/tree/tree.js +2 -0
  117. package/dist/mjs/data-structures/trie/trie.d.ts +2 -2
  118. package/dist/mjs/data-structures/trie/trie.js +1 -1
  119. package/dist/mjs/index.d.ts +1 -0
  120. package/dist/mjs/index.js +1 -0
  121. package/dist/mjs/interfaces/binary-tree.d.ts +2 -2
  122. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
  123. package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +1 -5
  124. package/dist/umd/data-structure-typed.js +1344 -1614
  125. package/dist/umd/data-structure-typed.min.js +10 -3
  126. package/dist/umd/data-structure-typed.min.js.map +1 -1
  127. package/eslint.config.mjs +69 -0
  128. package/package.json +30 -28
  129. package/src/constants/index.ts +4 -0
  130. package/src/data-structures/base/iterable-element-base.ts +11 -1
  131. package/src/data-structures/base/iterable-entry-base.ts +11 -19
  132. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +47 -50
  133. package/src/data-structures/binary-tree/avl-tree.ts +69 -71
  134. package/src/data-structures/binary-tree/binary-indexed-tree.ts +2 -2
  135. package/src/data-structures/binary-tree/binary-tree.ts +698 -726
  136. package/src/data-structures/binary-tree/bst.ts +123 -129
  137. package/src/data-structures/binary-tree/rb-tree.ts +44 -46
  138. package/src/data-structures/binary-tree/segment-tree.ts +2 -2
  139. package/src/data-structures/binary-tree/tree-multi-map.ts +48 -49
  140. package/src/data-structures/graph/abstract-graph.ts +6 -6
  141. package/src/data-structures/graph/directed-graph.ts +4 -4
  142. package/src/data-structures/graph/undirected-graph.ts +2 -2
  143. package/src/data-structures/hash/hash-map.ts +3 -3
  144. package/src/data-structures/heap/heap.ts +3 -3
  145. package/src/data-structures/linked-list/doubly-linked-list.ts +9 -9
  146. package/src/data-structures/linked-list/singly-linked-list.ts +8 -8
  147. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  148. package/src/data-structures/matrix/matrix.ts +2 -2
  149. package/src/data-structures/matrix/navigator.ts +4 -4
  150. package/src/data-structures/queue/deque.ts +31 -31
  151. package/src/data-structures/queue/queue.ts +1 -1
  152. package/src/data-structures/stack/stack.ts +2 -2
  153. package/src/data-structures/trie/trie.ts +3 -3
  154. package/src/index.ts +1 -0
  155. package/src/interfaces/binary-tree.ts +3 -3
  156. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -5
  157. package/test/config.ts +1 -7
  158. package/test/integration/all-in-one.test.ts +2 -2
  159. package/test/integration/avl-tree.test.ts +3 -3
  160. package/test/integration/bst.test.ts +19 -18
  161. package/test/integration/heap.test.js +6 -1
  162. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +39 -39
  163. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
  164. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +140 -112
  165. package/test/unit/data-structures/binary-tree/bst.test.ts +41 -13
  166. package/test/unit/data-structures/binary-tree/overall.test.ts +0 -6
  167. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +6 -6
  168. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +88 -34
  169. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +42 -42
  170. package/test/unit/data-structures/graph/abstract-graph.test.ts +1 -1
  171. package/test/unit/data-structures/graph/directed-graph.test.ts +4 -4
  172. package/test/unit/data-structures/graph/undirected-graph.test.ts +14 -2
  173. package/test/unit/data-structures/hash/hash-map.test.ts +1 -1
  174. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +1 -1
  175. package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
  176. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
  177. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +4 -4
  178. package/test/unit/data-structures/stack/stack.test.ts +6 -0
  179. package/test/unit/unrestricted-interconversion.test.ts +24 -24
  180. package/test/utils/big-o.ts +5 -4
  181. package/.eslintrc.js +0 -64
@@ -1,9 +1,9 @@
1
1
  import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
- import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, BTNKeyOrNodeOrEntry } from '../types';
2
+ import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNKeyOrNodeOrEntry, BTNPredicate } from '../types';
3
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>> {
4
4
  createNode(key: K, value?: NODE['value']): NODE;
5
5
  createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
6
6
  add(keyOrNodeOrEntryOrRawElement: BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
7
7
  addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
8
- delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[];
8
+ delete(predicate: R | BTNKeyOrNodeOrEntry<K, V, NODE> | BTNPredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
9
9
  }
@@ -1,5 +1,6 @@
1
1
  import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
2
2
  import { IterationType, OptValue } from '../../common';
3
+ import { DFSOperation } from "bst-typed";
3
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
6
  export type BinaryTreeOptions<K, V, R> = {
@@ -23,10 +24,7 @@ export type BinaryTreeDeleteResult<NODE> = {
23
24
  needBalanced: OptBTNOrNull<NODE>;
24
25
  };
25
26
  export type BTNCallback<NODE, D = any> = (node: NODE) => D;
26
- export declare enum DFSOperation {
27
- VISIT = 0,
28
- PROCESS = 1
29
- }
27
+ export type BTNPredicate<NODE> = (node: NODE) => boolean;
30
28
  export type DFSStackItem<NODE> = {
31
29
  opt: DFSOperation;
32
30
  node: OptBTNOrNull<NODE>;
@@ -1,9 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DFSOperation = void 0;
4
- var DFSOperation;
5
- (function (DFSOperation) {
6
- DFSOperation[DFSOperation["VISIT"] = 0] = "VISIT";
7
- DFSOperation[DFSOperation["PROCESS"] = 1] = "PROCESS";
8
- })(DFSOperation || (exports.DFSOperation = DFSOperation = {}));
9
3
  //# sourceMappingURL=binary-tree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binary-tree.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/binary-tree/binary-tree.ts"],"names":[],"mappings":";;;AAgCA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iDAAS,CAAA;IACT,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
1
+ {"version":3,"file":"binary-tree.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/binary-tree/binary-tree.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export declare enum DFSOperation {
2
+ VISIT = 0,
3
+ PROCESS = 1
4
+ }
@@ -0,0 +1,5 @@
1
+ export var DFSOperation;
2
+ (function (DFSOperation) {
3
+ DFSOperation[DFSOperation["VISIT"] = 0] = "VISIT";
4
+ DFSOperation[DFSOperation["PROCESS"] = 1] = "PROCESS";
5
+ })(DFSOperation || (DFSOperation = {}));
@@ -125,7 +125,14 @@ export declare abstract class IterableElementBase<E, R, C> {
125
125
  *
126
126
  * The print function logs the elements of an array to the console.
127
127
  */
128
- print(): E[];
128
+ toVisual(): E[];
129
+ /**
130
+ * Time Complexity: O(n)
131
+ * Space Complexity: O(n)
132
+ *
133
+ * The print function logs the elements of an array to the console.
134
+ */
135
+ print(): void;
129
136
  abstract isEmpty(): boolean;
130
137
  abstract clear(): void;
131
138
  abstract clone(): C;
@@ -180,7 +180,16 @@ export class IterableElementBase {
180
180
  *
181
181
  * The print function logs the elements of an array to the console.
182
182
  */
183
- print() {
183
+ toVisual() {
184
184
  return [...this];
185
185
  }
186
+ /**
187
+ * Time Complexity: O(n)
188
+ * Space Complexity: O(n)
189
+ *
190
+ * The print function logs the elements of an array to the console.
191
+ */
192
+ print() {
193
+ console.log(this.toVisual());
194
+ }
186
195
  }
@@ -151,7 +151,14 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
151
151
  *
152
152
  * The print function logs the elements of an array to the console.
153
153
  */
154
- print(): [K, V][] | string;
154
+ toVisual(): [K, V][] | string;
155
+ /**
156
+ * Time Complexity: O(n)
157
+ * Space Complexity: O(n)
158
+ *
159
+ * The print function logs the elements of an array to the console.
160
+ */
161
+ print(): void;
155
162
  abstract isEmpty(): boolean;
156
163
  abstract clear(): void;
157
164
  abstract clone(): any;
@@ -1,13 +1,4 @@
1
1
  export class IterableEntryBase {
2
- // protected _toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
3
- //
4
- // /**
5
- // * The function returns the value of the _toEntryFn property.
6
- // * @returns The function being returned is `this._toEntryFn`.
7
- // */
8
- // get toEntryFn() {
9
- // return this._toEntryFn;
10
- // }
11
2
  /**
12
3
  * Time Complexity: O(n)
13
4
  * Space Complexity: O(1)
@@ -230,7 +221,16 @@ export class IterableEntryBase {
230
221
  *
231
222
  * The print function logs the elements of an array to the console.
232
223
  */
233
- print() {
224
+ toVisual() {
234
225
  return [...this];
235
226
  }
227
+ /**
228
+ * Time Complexity: O(n)
229
+ * Space Complexity: O(n)
230
+ *
231
+ * The print function logs the elements of an array to the console.
232
+ */
233
+ print() {
234
+ console.log(this.toVisual());
235
+ }
236
236
  }
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
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, BTNCallback, BTNKeyOrNodeOrEntry, IterationType } from '../../types';
9
- import { BTNEntry } from '../../types';
8
+ import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNKeyOrNodeOrEntry, BTNPredicate, IterationType, BTNEntry } from '../../types';
10
9
  import { IBinaryTree } from '../../interfaces';
11
10
  import { AVLTree, AVLTreeNode } from './avl-tree';
12
11
  export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
@@ -40,13 +39,13 @@ export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeM
40
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> {
41
40
  /**
42
41
  * The constructor initializes a new AVLTreeMultiMap object with optional initial elements.
43
- * @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
42
+ * @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` parameter is an
44
43
  * iterable object that can contain either keys, nodes, entries, or raw elements.
45
44
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
46
45
  * behavior of the AVLTreeMultiMap. It can include properties such as `compareKeys` and
47
46
  * `compareValues` functions to define custom comparison logic for keys and values, respectively.
48
47
  */
49
- constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
48
+ constructor(keysOrNodesOrEntriesOrRaws?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
50
49
  protected _count: number;
51
50
  /**
52
51
  * The function calculates the sum of the count property of all nodes in a tree using depth-first
@@ -85,17 +84,17 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
85
84
  createTree(options?: AVLTreeMultiMapOptions<K, V, R>): TREE;
86
85
  /**
87
86
  * The function checks if the input is an instance of AVLTreeMultiMapNode.
88
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
89
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
90
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
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
91
90
  * an instance of the `AVLTreeMultiMapNode` class.
92
91
  */
93
- isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
92
+ isNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R): keyOrNodeOrEntryOrRaw is NODE;
94
93
  /**
95
94
  * The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
96
95
  * a node object.
97
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
98
- * `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
96
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The
97
+ * `keyOrNodeOrEntryOrRaw` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
99
98
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
100
99
  * `override` function. It represents the value associated with the key in the data structure. If no
101
100
  * value is provided, it will default to `undefined`.
@@ -103,15 +102,15 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
103
102
  * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
104
103
  * @returns either a NODE object or undefined.
105
104
  */
106
- keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
105
+ keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V, count?: number): NODE | undefined;
107
106
  /**
108
107
  * Time Complexity: O(log n)
109
108
  * Space Complexity: O(1)
110
109
  *
111
110
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
112
111
  * and update the count.
113
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
114
- * `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It
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
115
114
  * can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
116
115
  * entry, or raw element
117
116
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
@@ -121,27 +120,27 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
121
120
  * be added once. However, you can specify a different value for `count` if you want to add
122
121
  * @returns a boolean value.
123
122
  */
124
- add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
123
+ add(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V, count?: number): boolean;
125
124
  /**
126
125
  * Time Complexity: O(log n)
127
126
  * Space Complexity: O(1)
128
127
  *
129
- * The `delete` function in a binary tree data structure deletes a node based on its identifier and
130
- * returns the deleted node along with the parent node that needs to be balanced.
131
- * @param identifier - The identifier parameter is the value used to identify the node that needs to
132
- * be deleted from the binary tree. It can be of any type and is the return type of the callback
133
- * function.
134
- * @param {C} callback - The `callback` parameter is a function that is used to determine the
135
- * equality of nodes in the binary tree. It is optional and has a default value of
136
- * `this._DEFAULT_CALLBACK`. The `callback` function takes a single argument, which is the identifier
137
- * of a node, and returns a value that
138
- * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
139
- * being deleted. If set to true, the count of the node will not be considered and the node will be
140
- * deleted regardless of its count. If set to false (default), the count of the node will be taken
141
- * into account and the node
142
- * @returns an array of `BinaryTreeDeleteResult<NODE>`.
143
- */
144
- delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
128
+ * The function overrides the delete method in a binary tree data structure, handling deletion of
129
+ * nodes and maintaining balance in the tree.
130
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>} predicate - The `predicate`
131
+ * parameter in the `delete` method is used to specify the condition for deleting a node from the
132
+ * binary tree. It can be a key, node, entry, or a custom predicate function that determines which
133
+ * node(s) should be deleted.
134
+ * @param [ignoreCount=false] - The `ignoreCount` parameter in the `override delete` method is a
135
+ * boolean flag that determines whether to ignore the count of the node being deleted. If
136
+ * `ignoreCount` is set to `true`, the method will delete the node regardless of its count. If
137
+ * `ignoreCount` is set to
138
+ * @returns The `delete` method overrides the default delete behavior in a binary tree data
139
+ * structure. It takes a predicate or node to be deleted and an optional flag to ignore count. The
140
+ * method returns an array of `BinaryTreeDeleteResult` objects, each containing information about the
141
+ * deleted node and whether balancing is needed in the tree.
142
+ */
143
+ delete(predicate: BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
145
144
  /**
146
145
  * Time Complexity: O(1)
147
146
  * 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 keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
40
+ * @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` 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(keysOrNodesOrEntriesOrRawElements = [], options) {
46
+ constructor(keysOrNodesOrEntriesOrRaws = [], options) {
47
47
  super([], options);
48
- if (keysOrNodesOrEntriesOrRawElements)
49
- this.addMany(keysOrNodesOrEntriesOrRawElements);
48
+ if (keysOrNodesOrEntriesOrRaws)
49
+ this.addMany(keysOrNodesOrEntriesOrRaws);
50
50
  }
51
51
  _count = 0;
52
52
  /**
@@ -94,25 +94,26 @@ export class AVLTreeMultiMap extends AVLTree {
94
94
  createTree(options) {
95
95
  return new AVLTreeMultiMap([], {
96
96
  iterationType: this.iterationType,
97
- comparator: this.comparator,
97
+ comparator: this._comparator,
98
+ toEntryFn: this._toEntryFn,
98
99
  ...options
99
100
  });
100
101
  }
101
102
  /**
102
103
  * The function checks if the input is an instance of AVLTreeMultiMapNode.
103
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
104
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
105
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
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
106
107
  * an instance of the `AVLTreeMultiMapNode` class.
107
108
  */
108
- isNode(keyOrNodeOrEntryOrRawElement) {
109
- return keyOrNodeOrEntryOrRawElement instanceof AVLTreeMultiMapNode;
109
+ isNode(keyOrNodeOrEntryOrRaw) {
110
+ return keyOrNodeOrEntryOrRaw instanceof AVLTreeMultiMapNode;
110
111
  }
111
112
  /**
112
113
  * The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
113
114
  * a node object.
114
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
115
- * `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
115
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The
116
+ * `keyOrNodeOrEntryOrRaw` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
116
117
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
117
118
  * `override` function. It represents the value associated with the key in the data structure. If no
118
119
  * value is provided, it will default to `undefined`.
@@ -120,25 +121,25 @@ export class AVLTreeMultiMap extends AVLTree {
120
121
  * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
121
122
  * @returns either a NODE object or undefined.
122
123
  */
123
- keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value, count = 1) {
124
- if (keyOrNodeOrEntryOrRawElement === undefined || keyOrNodeOrEntryOrRawElement === null)
124
+ keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw, value, count = 1) {
125
+ if (keyOrNodeOrEntryOrRaw === undefined || keyOrNodeOrEntryOrRaw === null)
125
126
  return;
126
- if (this.isNode(keyOrNodeOrEntryOrRawElement))
127
- return keyOrNodeOrEntryOrRawElement;
128
- if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
129
- const [key, entryValue] = keyOrNodeOrEntryOrRawElement;
127
+ if (this.isNode(keyOrNodeOrEntryOrRaw))
128
+ return keyOrNodeOrEntryOrRaw;
129
+ if (this.isEntry(keyOrNodeOrEntryOrRaw)) {
130
+ const [key, entryValue] = keyOrNodeOrEntryOrRaw;
130
131
  if (key === undefined || key === null)
131
132
  return;
132
133
  if (this.isKey(key))
133
134
  return this.createNode(key, value ?? entryValue, count);
134
135
  }
135
- if (this.toEntryFn) {
136
- const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
136
+ if (this._toEntryFn) {
137
+ const [key, entryValue] = this._toEntryFn(keyOrNodeOrEntryOrRaw);
137
138
  if (this.isKey(key))
138
139
  return this.createNode(key, value ?? entryValue, count);
139
140
  }
140
- if (this.isKey(keyOrNodeOrEntryOrRawElement))
141
- return this.createNode(keyOrNodeOrEntryOrRawElement, value, count);
141
+ if (this.isKey(keyOrNodeOrEntryOrRaw))
142
+ return this.createNode(keyOrNodeOrEntryOrRaw, value, count);
142
143
  return;
143
144
  }
144
145
  /**
@@ -147,8 +148,8 @@ export class AVLTreeMultiMap extends AVLTree {
147
148
  *
148
149
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
149
150
  * and update the count.
150
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
151
- * `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It
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
152
153
  * can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
153
154
  * entry, or raw element
154
155
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
@@ -158,8 +159,8 @@ export class AVLTreeMultiMap extends AVLTree {
158
159
  * be added once. However, you can specify a different value for `count` if you want to add
159
160
  * @returns a boolean value.
160
161
  */
161
- add(keyOrNodeOrEntryOrRawElement, value, count = 1) {
162
- const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value, count);
162
+ add(keyOrNodeOrEntryOrRaw, value, count = 1) {
163
+ const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw, value, count);
163
164
  if (newNode === undefined)
164
165
  return false;
165
166
  const orgNodeCount = newNode?.count || 0;
@@ -173,27 +174,26 @@ export class AVLTreeMultiMap extends AVLTree {
173
174
  * Time Complexity: O(log n)
174
175
  * Space Complexity: O(1)
175
176
  *
176
- * The `delete` function in a binary tree data structure deletes a node based on its identifier and
177
- * returns the deleted node along with the parent node that needs to be balanced.
178
- * @param identifier - The identifier parameter is the value used to identify the node that needs to
179
- * be deleted from the binary tree. It can be of any type and is the return type of the callback
180
- * function.
181
- * @param {C} callback - The `callback` parameter is a function that is used to determine the
182
- * equality of nodes in the binary tree. It is optional and has a default value of
183
- * `this._DEFAULT_CALLBACK`. The `callback` function takes a single argument, which is the identifier
184
- * of a node, and returns a value that
185
- * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
186
- * being deleted. If set to true, the count of the node will not be considered and the node will be
187
- * deleted regardless of its count. If set to false (default), the count of the node will be taken
188
- * into account and the node
189
- * @returns an array of `BinaryTreeDeleteResult<NODE>`.
177
+ * The function overrides the delete method in a binary tree data structure, handling deletion of
178
+ * nodes and maintaining balance in the tree.
179
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>} predicate - The `predicate`
180
+ * parameter in the `delete` method is used to specify the condition for deleting a node from the
181
+ * binary tree. It can be a key, node, entry, or a custom predicate function that determines which
182
+ * node(s) should be deleted.
183
+ * @param [ignoreCount=false] - The `ignoreCount` parameter in the `override delete` method is a
184
+ * boolean flag that determines whether to ignore the count of the node being deleted. If
185
+ * `ignoreCount` is set to `true`, the method will delete the node regardless of its count. If
186
+ * `ignoreCount` is set to
187
+ * @returns The `delete` method overrides the default delete behavior in a binary tree data
188
+ * structure. It takes a predicate or node to be deleted and an optional flag to ignore count. The
189
+ * method returns an array of `BinaryTreeDeleteResult` objects, each containing information about the
190
+ * deleted node and whether balancing is needed in the tree.
190
191
  */
191
- delete(identifier, callback = this._DEFAULT_CALLBACK, ignoreCount = false) {
192
+ delete(predicate, ignoreCount = false) {
192
193
  const deletedResult = [];
193
194
  if (!this.root)
194
195
  return deletedResult;
195
- callback = this._ensureCallback(identifier, callback);
196
- const curr = this.getNode(identifier, callback) ?? undefined;
196
+ const curr = this.getNode(predicate) ?? undefined;
197
197
  if (!curr)
198
198
  return deletedResult;
199
199
  const parent = curr?.parent ? curr.parent : undefined;
@@ -235,7 +235,7 @@ export class AVLTreeMultiMap extends AVLTree {
235
235
  }
236
236
  }
237
237
  }
238
- this._size = this.size - 1;
238
+ this._size = this._size - 1;
239
239
  // TODO How to handle when the count of target node is lesser than current node's count
240
240
  if (orgCurrent)
241
241
  this._count -= orgCurrent.count;
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNKeyOrNodeOrEntry } from '../../types';
10
- import { BTNEntry } from '../../types';
9
+ import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNKeyOrNodeOrEntry, BTNPredicate, BTNEntry } from '../../types';
11
10
  import { IBinaryTree } from '../../interfaces';
12
11
  export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
13
12
  /**
@@ -45,7 +44,7 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
45
44
  /**
46
45
  * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,
47
46
  * entries, or raw elements.
48
- * @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
47
+ * @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` parameter is an
49
48
  * iterable object that can contain either keys, nodes, entries, or raw elements. These elements will
50
49
  * be used to initialize the AVLTree.
51
50
  * @param [options] - The `options` parameter is an optional object that can be used to customize the
@@ -53,7 +52,7 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
53
52
  * keys), `allowDuplicates` (a boolean indicating whether duplicate keys are allowed), and
54
53
  * `nodeBuilder` (
55
54
  */
56
- constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
55
+ constructor(keysOrNodesOrEntriesOrRaws?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
57
56
  /**
58
57
  * The function creates a new AVL tree node with the given key and value.
59
58
  * @param {K} key - The key parameter is of type K, which represents the key of the node being
@@ -74,40 +73,40 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
74
73
  createTree(options?: AVLTreeOptions<K, V, R>): TREE;
75
74
  /**
76
75
  * The function checks if the input is an instance of AVLTreeNode.
77
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
78
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
79
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
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
80
79
  * an instance of the `AVLTreeNode` class.
81
80
  */
82
- isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
81
+ isNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R): keyOrNodeOrEntryOrRaw is NODE;
83
82
  /**
84
83
  * Time Complexity: O(log n)
85
84
  * Space Complexity: O(1)
86
85
  *
87
86
  * The function overrides the add method of a class and inserts a key-value pair into a data
88
87
  * structure, then balances the path.
89
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
90
- * `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
88
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
89
+ * `keyOrNodeOrEntryOrRaw` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
91
90
  * `RawElement`.
92
91
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
93
92
  * the key or node being added to the data structure.
94
93
  * @returns The method is returning a boolean value.
95
94
  */
96
- add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
95
+ add(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V): boolean;
97
96
  /**
98
97
  * Time Complexity: O(log n)
99
98
  * Space Complexity: O(1)
100
99
  *
101
- * The function overrides the delete method of a binary tree class and performs additional operations
102
- * to balance the tree after deletion.
103
- * @param identifier - The `identifier` parameter is the value or condition used to identify the
104
- * node(s) to be deleted from the binary tree. It can be of any type that is compatible with the
105
- * binary tree's node type.
106
- * @param {C} callback - The `callback` parameter is a function that will be used to determine if a
107
- * node should be deleted or not. It is optional and has a default value of `this._DEFAULT_CALLBACK`.
108
- * @returns The method is returning an array of BinaryTreeDeleteResult<NODE> objects.
100
+ * The function overrides the delete method in a TypeScript class, performs deletion, and then
101
+ * balances the tree if necessary.
102
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>} predicate - The `predicate`
103
+ * parameter in the `override delete` method can be one of the following types:
104
+ * @returns The `delete` method is being overridden in this code snippet. It first calls the `delete`
105
+ * method from the superclass (presumably a parent class) with the provided `predicate`, which could
106
+ * be a key, node, entry, or a custom predicate. The result of this deletion operation is stored in
107
+ * `deletedResults`, which is an array of `BinaryTreeDeleteResult` objects.
109
108
  */
110
- delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeleteResult<NODE>[];
109
+ delete(predicate: BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
111
110
  /**
112
111
  * Time Complexity: O(1)
113
112
  * Space Complexity: O(1)
@@ -180,10 +179,10 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
180
179
  *
181
180
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
182
181
  * to restore balance in an AVL tree after inserting a node.
183
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or
182
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} node - The `node` parameter can be of type `R` or
184
183
  * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
185
184
  */
186
- protected _balancePath(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): void;
185
+ protected _balancePath(node: BTNKeyOrNodeOrEntry<K, V, NODE> | R): void;
187
186
  /**
188
187
  * Time Complexity: O(1)
189
188
  * Space Complexity: O(1)