undirected-graph-typed 1.53.8 → 1.53.9

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 (48) hide show
  1. package/dist/data-structures/base/iterable-entry-base.js +4 -4
  2. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +36 -17
  3. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +64 -35
  4. package/dist/data-structures/binary-tree/avl-tree.d.ts +12 -8
  5. package/dist/data-structures/binary-tree/avl-tree.js +19 -6
  6. package/dist/data-structures/binary-tree/binary-tree.d.ts +53 -40
  7. package/dist/data-structures/binary-tree/binary-tree.js +75 -71
  8. package/dist/data-structures/binary-tree/bst.d.ts +35 -30
  9. package/dist/data-structures/binary-tree/bst.js +54 -40
  10. package/dist/data-structures/binary-tree/red-black-tree.d.ts +34 -10
  11. package/dist/data-structures/binary-tree/red-black-tree.js +41 -43
  12. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +33 -17
  13. package/dist/data-structures/binary-tree/tree-multi-map.js +62 -36
  14. package/dist/data-structures/graph/abstract-graph.js +2 -2
  15. package/dist/data-structures/hash/hash-map.d.ts +1 -1
  16. package/dist/data-structures/hash/hash-map.js +5 -5
  17. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +10 -10
  18. package/dist/data-structures/linked-list/doubly-linked-list.js +12 -12
  19. package/dist/data-structures/linked-list/singly-linked-list.d.ts +10 -10
  20. package/dist/data-structures/linked-list/singly-linked-list.js +16 -16
  21. package/dist/interfaces/binary-tree.d.ts +3 -4
  22. package/dist/types/data-structures/base/base.d.ts +1 -1
  23. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
  24. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
  25. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +2 -3
  26. package/dist/types/data-structures/binary-tree/bst.d.ts +3 -4
  27. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +4 -5
  28. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +4 -5
  29. package/package.json +2 -2
  30. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  31. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +81 -54
  32. package/src/data-structures/binary-tree/avl-tree.ts +32 -15
  33. package/src/data-structures/binary-tree/binary-tree.ts +88 -83
  34. package/src/data-structures/binary-tree/bst.ts +87 -74
  35. package/src/data-structures/binary-tree/red-black-tree.ts +55 -54
  36. package/src/data-structures/binary-tree/tree-multi-map.ts +79 -49
  37. package/src/data-structures/graph/abstract-graph.ts +2 -2
  38. package/src/data-structures/hash/hash-map.ts +7 -7
  39. package/src/data-structures/linked-list/doubly-linked-list.ts +13 -13
  40. package/src/data-structures/linked-list/singly-linked-list.ts +17 -17
  41. package/src/interfaces/binary-tree.ts +3 -13
  42. package/src/types/data-structures/base/base.ts +1 -1
  43. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -4
  44. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -4
  45. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
  46. package/src/types/data-structures/binary-tree/bst.ts +3 -5
  47. package/src/types/data-structures/binary-tree/rb-tree.ts +4 -6
  48. package/src/types/data-structures/binary-tree/tree-multi-map.ts +4 -6
@@ -92,9 +92,9 @@ class RedBlackTree extends bst_1.BST {
92
92
  * This is the constructor function for a Red-Black Tree data structure in TypeScript.
93
93
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
94
94
  * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
95
- * initialize the RBTree with the provided elements.
95
+ * initialize the RedBlackTree with the provided elements.
96
96
  * @param [options] - The `options` parameter is an optional object that can be passed to the
97
- * constructor. It is of type `RBTreeOptions<K, V, R>`. This object can contain various options for
97
+ * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for
98
98
  * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
99
99
  * depend on the implementation
100
100
  */
@@ -130,13 +130,17 @@ class RedBlackTree extends bst_1.BST {
130
130
  return new RedBlackTreeNode(key, this._isMapMode ? undefined : value, color);
131
131
  }
132
132
  /**
133
- * The function creates a new Red-Black Tree with the specified options.
134
- * @param [options] - The `options` parameter is an optional object that contains additional
135
- * configuration options for creating the Red-Black Tree. It has the following properties:
136
- * @returns a new instance of a RedBlackTree object.
133
+ * The function `createTree` overrides the default implementation to create a Red-Black Tree with
134
+ * specified options in TypeScript.
135
+ * @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
136
+ * V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
137
+ * allows you to pass additional configuration options when creating a new Red-
138
+ * @returns A new instance of a RedBlackTree with the specified options and properties from the
139
+ * current object is being returned.
137
140
  */
141
+ // @ts-ignore
138
142
  createTree(options) {
139
- return new RedBlackTree([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, extractComparable: this._extractComparable, toEntryFn: this._toEntryFn }, options));
143
+ return new RedBlackTree([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn }, options));
140
144
  }
141
145
  /**
142
146
  * Time Complexity: O(1)
@@ -151,41 +155,6 @@ class RedBlackTree extends bst_1.BST {
151
155
  isNode(keyNodeEntryOrRaw) {
152
156
  return keyNodeEntryOrRaw instanceof RedBlackTreeNode;
153
157
  }
154
- // /**
155
- // * Time Complexity: O(1)
156
- // * Space Complexity: O(1)
157
- // */
158
- //
159
- // /**
160
- // * Time Complexity: O(1)
161
- // * Space Complexity: O(1)
162
- // *
163
- // * The function `keyValueNodeEntryRawToNodeAndValue` takes a key, value, or entry and returns a node if it is
164
- // * valid, otherwise it returns undefined.
165
- // * @param {BTNRep<K, V, NODE>} keyNodeEntryOrRaw - The key, value, or entry to convert.
166
- // * @param {V} [value] - The value associated with the key (if `keyNodeEntryOrRaw` is a key).
167
- // * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
168
- // */
169
- // override keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): NODE | undefined {
170
- //
171
- // if (keyNodeEntryOrRaw === null || keyNodeEntryOrRaw === undefined) return;
172
- // if (this.isNode(keyNodeEntryOrRaw)) return keyNodeEntryOrRaw;
173
- //
174
- // if (this._toEntryFn) {
175
- // const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw as R);
176
- // if (this.isKey(key)) return this.createNode(key, value ?? entryValue, 'RED');
177
- // }
178
- //
179
- // if (this.isEntry(keyNodeEntryOrRaw)) {
180
- // const [key, value] = keyNodeEntryOrRaw;
181
- // if (key === undefined || key === null) return;
182
- // else return this.createNode(key, value, 'RED');
183
- // }
184
- //
185
- // if (this.isKey(keyNodeEntryOrRaw)) return this.createNode(keyNodeEntryOrRaw, value, 'RED');
186
- //
187
- // return ;
188
- // }
189
158
  /**
190
159
  * Time Complexity: O(1)
191
160
  * Space Complexity: O(1)
@@ -308,6 +277,35 @@ class RedBlackTree extends bst_1.BST {
308
277
  results.push({ deleted: nodeToDelete, needBalanced: undefined });
309
278
  return results;
310
279
  }
280
+ /**
281
+ * Time Complexity: O(n)
282
+ * Space Complexity: O(n)
283
+ *
284
+ * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
285
+ * applying a callback to each entry in the original tree.
286
+ * @param callback - A function that will be called for each entry in the tree, with parameters
287
+ * representing the key, value, index, and the tree itself. It should return an entry for the new
288
+ * tree.
289
+ * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
290
+ * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
291
+ * Tree that will be created during the mapping process. These options could include things like
292
+ * custom comparators
293
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
294
+ * the value of `this` when executing the `callback` function. It allows you to set the context
295
+ * (value of `this`) for the callback function. This can be useful when you want to access properties
296
+ * or
297
+ * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
298
+ * provided callback function.
299
+ */
300
+ // @ts-ignore
301
+ map(callback, options, thisArg) {
302
+ const newTree = new RedBlackTree([], options);
303
+ let index = 0;
304
+ for (const [key, value] of this) {
305
+ newTree.add(callback.call(thisArg, key, value, index++, this));
306
+ }
307
+ return newTree;
308
+ }
311
309
  /**
312
310
  * Time Complexity: O(1)
313
311
  * Space Complexity: O(1)
@@ -372,7 +370,7 @@ class RedBlackTree extends bst_1.BST {
372
370
  if (!parent) {
373
371
  this._setRoot(node);
374
372
  }
375
- else if (node.key < parent.key) {
373
+ else if (this._compare(node.key, parent.key) < 0) {
376
374
  parent.left = node;
377
375
  }
378
376
  else {
@@ -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 { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, IterationType, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
8
+ import type { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType, RBTNColor, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
9
9
  import { IBinaryTree } from '../../interfaces';
10
10
  import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
11
11
  export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
@@ -35,7 +35,7 @@ export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMa
35
35
  */
36
36
  set count(value: number);
37
37
  }
38
- export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, R, NODE, TREE> = TreeMultiMap<K, V, R, NODE, TreeMultiMapNested<K, V, R, NODE>>> extends RedBlackTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
38
+ export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>> extends RedBlackTree<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
39
39
  /**
40
40
  * The constructor function initializes a TreeMultiMap object with optional initial data.
41
41
  * @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
@@ -83,20 +83,7 @@ export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends Tre
83
83
  * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
84
84
  * existing `iterationType` property. The returned value is casted as `TREE`.
85
85
  */
86
- createTree(options?: TreeMultiMapOptions<K, V, R>): TREE;
87
- /**
88
- * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
89
- * node based on the input.
90
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
91
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
92
- * @param {V} [value] - The `value` parameter is an optional value that represents the value
93
- * associated with the key in the node. It is used when creating a new node or updating the value of
94
- * an existing node.
95
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
96
- * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
97
- * @returns either a NODE object or undefined.
98
- */
99
- protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
86
+ createTree(options?: TreeMultiMapOptions<K, V, R>): TreeMultiMap<K, V, R, NODE>;
100
87
  /**
101
88
  * The function checks if the input is an instance of the TreeMultiMapNode class.
102
89
  * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
@@ -167,7 +154,36 @@ export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends Tre
167
154
  * The function overrides the clone method to create a deep copy of a tree object.
168
155
  * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
169
156
  */
170
- clone(): TREE;
157
+ clone(): TreeMultiMap<K, V, R, NODE>;
158
+ /**
159
+ * The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
160
+ * modified entries based on a provided callback.
161
+ * @param callback - The `callback` parameter is a function that will be called for each entry in the
162
+ * map. It takes four arguments:
163
+ * @param [options] - The `options` parameter in the `override map` function is of type
164
+ * `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
165
+ * options when creating a new `TreeMultiMap` instance within the `map` function. These options could
166
+ * include things like
167
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
168
+ * the value of `this` when executing the `callback` function. It allows you to set the context
169
+ * (value of `this`) for the callback function when it is called within the `map` function. This
170
+ * @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
171
+ * by the provided callback function.
172
+ */
173
+ map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: TreeMultiMapOptions<MK, MV, MR>, thisArg?: any): TreeMultiMap<MK, MV, MR, TreeMultiMapNode<MK, MV, TreeMultiMapNodeNested<MK, MV>>>;
174
+ /**
175
+ * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
176
+ * node based on the input.
177
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
178
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
179
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
180
+ * associated with the key in the node. It is used when creating a new node or updating the value of
181
+ * an existing node.
182
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
183
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
184
+ * @returns either a NODE object or undefined.
185
+ */
186
+ protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
171
187
  /**
172
188
  * Time Complexity: O(1)
173
189
  * Space Complexity: O(1)
@@ -98,43 +98,9 @@ class TreeMultiMap extends red_black_tree_1.RedBlackTree {
98
98
  * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
99
99
  * existing `iterationType` property. The returned value is casted as `TREE`.
100
100
  */
101
+ // @ts-ignore
101
102
  createTree(options) {
102
- return new TreeMultiMap([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, extractComparable: this._extractComparable, toEntryFn: this._toEntryFn }, options));
103
- }
104
- /**
105
- * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
106
- * node based on the input.
107
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
108
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
109
- * @param {V} [value] - The `value` parameter is an optional value that represents the value
110
- * associated with the key in the node. It is used when creating a new node or updating the value of
111
- * an existing node.
112
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
113
- * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
114
- * @returns either a NODE object or undefined.
115
- */
116
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
117
- if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
118
- return [undefined, undefined];
119
- if (this.isNode(keyNodeEntryOrRaw))
120
- return [keyNodeEntryOrRaw, value];
121
- if (this.isEntry(keyNodeEntryOrRaw)) {
122
- const [key, entryValue] = keyNodeEntryOrRaw;
123
- if (key === undefined || key === null)
124
- return [undefined, undefined];
125
- const finalValue = value !== null && value !== void 0 ? value : entryValue;
126
- if (this.isKey(key))
127
- return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
128
- }
129
- if (this.isRaw(keyNodeEntryOrRaw)) {
130
- const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
131
- const finalValue = value !== null && value !== void 0 ? value : entryValue;
132
- if (this.isKey(key))
133
- return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
134
- }
135
- if (this.isKey(keyNodeEntryOrRaw))
136
- return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
137
- return [undefined, undefined];
103
+ return new TreeMultiMap([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn }, options));
138
104
  }
139
105
  /**
140
106
  * The function checks if the input is an instance of the TreeMultiMapNode class.
@@ -353,6 +319,7 @@ class TreeMultiMap extends red_black_tree_1.RedBlackTree {
353
319
  * The function overrides the clone method to create a deep copy of a tree object.
354
320
  * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
355
321
  */
322
+ // @ts-ignore
356
323
  clone() {
357
324
  const cloned = this.createTree();
358
325
  this.bfs(node => cloned.add(node.key, undefined, node.count));
@@ -360,6 +327,65 @@ class TreeMultiMap extends red_black_tree_1.RedBlackTree {
360
327
  cloned._store = this._store;
361
328
  return cloned;
362
329
  }
330
+ /**
331
+ * The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
332
+ * modified entries based on a provided callback.
333
+ * @param callback - The `callback` parameter is a function that will be called for each entry in the
334
+ * map. It takes four arguments:
335
+ * @param [options] - The `options` parameter in the `override map` function is of type
336
+ * `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
337
+ * options when creating a new `TreeMultiMap` instance within the `map` function. These options could
338
+ * include things like
339
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
340
+ * the value of `this` when executing the `callback` function. It allows you to set the context
341
+ * (value of `this`) for the callback function when it is called within the `map` function. This
342
+ * @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
343
+ * by the provided callback function.
344
+ */
345
+ // @ts-ignore
346
+ map(callback, options, thisArg) {
347
+ const newTree = new TreeMultiMap([], options);
348
+ let index = 0;
349
+ for (const [key, value] of this) {
350
+ newTree.add(callback.call(thisArg, key, value, index++, this));
351
+ }
352
+ return newTree;
353
+ }
354
+ /**
355
+ * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
356
+ * node based on the input.
357
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
358
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
359
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
360
+ * associated with the key in the node. It is used when creating a new node or updating the value of
361
+ * an existing node.
362
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
363
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
364
+ * @returns either a NODE object or undefined.
365
+ */
366
+ _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
367
+ if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
368
+ return [undefined, undefined];
369
+ if (this.isNode(keyNodeEntryOrRaw))
370
+ return [keyNodeEntryOrRaw, value];
371
+ if (this.isEntry(keyNodeEntryOrRaw)) {
372
+ const [key, entryValue] = keyNodeEntryOrRaw;
373
+ if (key === undefined || key === null)
374
+ return [undefined, undefined];
375
+ const finalValue = value !== null && value !== void 0 ? value : entryValue;
376
+ if (this.isKey(key))
377
+ return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
378
+ }
379
+ if (this.isRaw(keyNodeEntryOrRaw)) {
380
+ const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
381
+ const finalValue = value !== null && value !== void 0 ? value : entryValue;
382
+ if (this.isKey(key))
383
+ return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
384
+ }
385
+ if (this.isKey(keyNodeEntryOrRaw))
386
+ return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
387
+ return [undefined, undefined];
388
+ }
363
389
  /**
364
390
  * Time Complexity: O(1)
365
391
  * Space Complexity: O(1)
@@ -813,7 +813,7 @@ class AbstractGraph extends base_1.IterableEntryBase {
813
813
  const filtered = [];
814
814
  let index = 0;
815
815
  for (const [key, value] of this) {
816
- if (predicate.call(thisArg, value, key, index, this)) {
816
+ if (predicate.call(thisArg, key, value, index, this)) {
817
817
  filtered.push([key, value]);
818
818
  }
819
819
  index++;
@@ -837,7 +837,7 @@ class AbstractGraph extends base_1.IterableEntryBase {
837
837
  const mapped = [];
838
838
  let index = 0;
839
839
  for (const [key, value] of this) {
840
- mapped.push(callback.call(thisArg, value, key, index, this));
840
+ mapped.push(callback.call(thisArg, key, value, index, this));
841
841
  index++;
842
842
  }
843
843
  return mapped;
@@ -450,7 +450,7 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
450
450
  * @returns a new `LinkedHashMap` object with the values mapped according to the provided callback
451
451
  * function.
452
452
  */
453
- map<VM>(callback: EntryCallback<K, V, VM>, thisArg?: any): LinkedHashMap<K, VM>;
453
+ map<MK, MV>(callback: EntryCallback<K, V, [MK, MV]>, thisArg?: any): LinkedHashMap<MK, MV>;
454
454
  /**
455
455
  * Time Complexity: O(n)
456
456
  * Space Complexity: O(1)
@@ -261,7 +261,7 @@ class HashMap extends base_1.IterableEntryBase {
261
261
  const resultMap = new HashMap();
262
262
  let index = 0;
263
263
  for (const [key, value] of this) {
264
- resultMap.set(key, callbackfn.call(thisArg, value, key, index++, this));
264
+ resultMap.set(key, callbackfn.call(thisArg, key, value, index++, this));
265
265
  }
266
266
  return resultMap;
267
267
  }
@@ -285,7 +285,7 @@ class HashMap extends base_1.IterableEntryBase {
285
285
  const filteredMap = new HashMap();
286
286
  let index = 0;
287
287
  for (const [key, value] of this) {
288
- if (predicate.call(thisArg, value, key, index++, this)) {
288
+ if (predicate.call(thisArg, key, value, index++, this)) {
289
289
  filteredMap.set(key, value);
290
290
  }
291
291
  }
@@ -758,7 +758,7 @@ class LinkedHashMap extends base_1.IterableEntryBase {
758
758
  const filteredMap = new LinkedHashMap();
759
759
  let index = 0;
760
760
  for (const [key, value] of this) {
761
- if (predicate.call(thisArg, value, key, index, this)) {
761
+ if (predicate.call(thisArg, key, value, index, this)) {
762
762
  filteredMap.set(key, value);
763
763
  }
764
764
  index++;
@@ -786,8 +786,8 @@ class LinkedHashMap extends base_1.IterableEntryBase {
786
786
  const mappedMap = new LinkedHashMap();
787
787
  let index = 0;
788
788
  for (const [key, value] of this) {
789
- const newValue = callback.call(thisArg, value, key, index, this);
790
- mappedMap.set(key, newValue);
789
+ const [newKey, newValue] = callback.call(thisArg, key, value, index, this);
790
+ mappedMap.set(newKey, newValue);
791
791
  index++;
792
792
  }
793
793
  return mappedMap;
@@ -533,6 +533,16 @@ export declare class DoublyLinkedList<E = any, R = any> extends IterableElementB
533
533
  * @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
534
534
  */
535
535
  get last(): E | undefined;
536
+ /**
537
+ * Time Complexity: O(n)
538
+ * Space Complexity: O(n)
539
+ *
540
+ * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
541
+ * given array.
542
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
543
+ * @returns The `fromArray` function returns a DoublyLinkedList object.
544
+ */
545
+ static fromArray<E>(data: E[]): DoublyLinkedList<E, any>;
536
546
  /**
537
547
  * Time Complexity: O(1)
538
548
  * Space Complexity: O(1)
@@ -867,16 +877,6 @@ export declare class DoublyLinkedList<E = any, R = any> extends IterableElementB
867
877
  * node, or predicate function in the doubly linked list.
868
878
  */
869
879
  countOccurrences(elementOrNode: E | DoublyLinkedListNode<E> | ((node: DoublyLinkedListNode<E>) => boolean)): number;
870
- /**
871
- * Time Complexity: O(n)
872
- * Space Complexity: O(n)
873
- *
874
- * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
875
- * given array.
876
- * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
877
- * @returns The `fromArray` function returns a DoublyLinkedList object.
878
- */
879
- static fromArray<E>(data: E[]): DoublyLinkedList<E, any>;
880
880
  /**
881
881
  * The function returns an iterator that iterates over the values of a linked list.
882
882
  */
@@ -557,6 +557,18 @@ class DoublyLinkedList extends base_1.IterableElementBase {
557
557
  var _a;
558
558
  return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
559
559
  }
560
+ /**
561
+ * Time Complexity: O(n)
562
+ * Space Complexity: O(n)
563
+ *
564
+ * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
565
+ * given array.
566
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
567
+ * @returns The `fromArray` function returns a DoublyLinkedList object.
568
+ */
569
+ static fromArray(data) {
570
+ return new DoublyLinkedList(data);
571
+ }
560
572
  /**
561
573
  * Time Complexity: O(1)
562
574
  * Space Complexity: O(1)
@@ -1184,18 +1196,6 @@ class DoublyLinkedList extends base_1.IterableElementBase {
1184
1196
  }
1185
1197
  return count;
1186
1198
  }
1187
- /**
1188
- * Time Complexity: O(n)
1189
- * Space Complexity: O(n)
1190
- *
1191
- * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
1192
- * given array.
1193
- * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
1194
- * @returns The `fromArray` function returns a DoublyLinkedList object.
1195
- */
1196
- static fromArray(data) {
1197
- return new DoublyLinkedList(data);
1198
- }
1199
1199
  /**
1200
1200
  * The function returns an iterator that iterates over the values of a linked list.
1201
1201
  */
@@ -72,6 +72,16 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
72
72
  * @returns The size of the object, which is a number.
73
73
  */
74
74
  get size(): number;
75
+ /**
76
+ * Time Complexity: O(n)
77
+ * Space Complexity: O(n)
78
+ *
79
+ * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
80
+ * array.
81
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
82
+ * @returns The `fromArray` function returns a `SinglyLinkedList` object.
83
+ */
84
+ static fromArray<E>(data: E[]): SinglyLinkedList<E, any>;
75
85
  /**
76
86
  * Time Complexity: O(1)
77
87
  * Space Complexity: O(1)
@@ -384,16 +394,6 @@ export declare class SinglyLinkedList<E = any, R = any> extends IterableElementB
384
394
  * The function `_getIterator` returns an iterable iterator that yields the values of a linked list.
385
395
  */
386
396
  protected _getIterator(): IterableIterator<E>;
387
- /**
388
- * Time Complexity: O(n)
389
- * Space Complexity: O(n)
390
- *
391
- * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
392
- * array.
393
- * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
394
- * @returns The `fromArray` function returns a `SinglyLinkedList` object.
395
- */
396
- static fromArray<E>(data: E[]): SinglyLinkedList<E, any>;
397
397
  /**
398
398
  * The _isPredicate function in TypeScript checks if the input is a function that takes a
399
399
  * SinglyLinkedListNode as an argument and returns a boolean.
@@ -90,6 +90,22 @@ class SinglyLinkedList extends base_1.IterableElementBase {
90
90
  get size() {
91
91
  return this._size;
92
92
  }
93
+ /**
94
+ * Time Complexity: O(n)
95
+ * Space Complexity: O(n)
96
+ *
97
+ * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
98
+ * array.
99
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
100
+ * @returns The `fromArray` function returns a `SinglyLinkedList` object.
101
+ */
102
+ static fromArray(data) {
103
+ const singlyLinkedList = new SinglyLinkedList();
104
+ for (const item of data) {
105
+ singlyLinkedList.push(item);
106
+ }
107
+ return singlyLinkedList;
108
+ }
93
109
  /**
94
110
  * Time Complexity: O(1)
95
111
  * Space Complexity: O(1)
@@ -690,22 +706,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
690
706
  current = current.next;
691
707
  }
692
708
  }
693
- /**
694
- * Time Complexity: O(n)
695
- * Space Complexity: O(n)
696
- *
697
- * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
698
- * array.
699
- * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
700
- * @returns The `fromArray` function returns a `SinglyLinkedList` object.
701
- */
702
- static fromArray(data) {
703
- const singlyLinkedList = new SinglyLinkedList();
704
- for (const item of data) {
705
- singlyLinkedList.push(item);
706
- }
707
- return singlyLinkedList;
708
- }
709
709
  /**
710
710
  * The _isPredicate function in TypeScript checks if the input is a function that takes a
711
711
  * SinglyLinkedListNode as an argument and returns a boolean.
@@ -1,8 +1,7 @@
1
- import { BinaryTree, BinaryTreeNode } from '../data-structures';
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>> {
1
+ import { BinaryTreeNode } from '../data-structures';
2
+ import type { BinaryTreeDeleteResult, BinaryTreeNodeNested, BTNRep, NodePredicate } from '../types';
3
+ export interface IBinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>> {
4
4
  createNode(key: K, value?: NODE['value']): NODE;
5
- createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
6
5
  add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;
7
6
  addMany(nodes: Iterable<BTNRep<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
8
7
  delete(predicate: R | BTNRep<K, V, NODE> | NodePredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
@@ -1,5 +1,5 @@
1
1
  import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
2
- export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
2
+ export type EntryCallback<K, V, R> = (key: K, value: V, index: number, container: IterableEntryBase<K, V>) => R;
3
3
  export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
4
4
  export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
5
5
  export type ReduceElementCallback<E, R, RT, C> = (accumulator: RT, element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
@@ -1,5 +1,4 @@
1
- import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
1
+ import { AVLTreeMultiMapNode } from '../../../data-structures';
2
2
  import type { AVLTreeOptions } from './avl-tree';
3
- export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type AVLTreeMultiMapNested<K, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
3
+ export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>;
5
4
  export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
@@ -1,5 +1,4 @@
1
- import { AVLTree, AVLTreeNode } from '../../../data-structures';
1
+ import { AVLTreeNode } from '../../../data-structures';
2
2
  import { BSTOptions } from './bst';
3
- export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type AVLTreeNested<K, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
3
+ export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>;
5
4
  export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -1,8 +1,7 @@
1
- import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
1
+ import { BinaryTreeNode } from '../../../data-structures';
2
2
  import { IterationType, OptValue } from '../../common';
3
3
  import { DFSOperation } from '../../../common';
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
- 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
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, any>>>>>>>>>>;
6
5
  export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;
7
6
  export type BinaryTreeOptions<K, V, R> = {
8
7
  iterationType?: IterationType;
@@ -1,10 +1,9 @@
1
- import { BST, BSTNode } from '../../../data-structures';
1
+ import { BSTNode } from '../../../data-structures';
2
2
  import type { BinaryTreeOptions } from './binary-tree';
3
3
  import { Comparable } from '../../utils';
4
- export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>;
6
5
  export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
7
- extractComparable?: (key: K) => Comparable;
6
+ specifyComparable?: (key: K) => Comparable;
8
7
  isReverse?: boolean;
9
8
  };
10
9
  export type BSTNOptKey<K> = K | undefined;