avl-tree-typed 2.2.6 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/cjs/index.cjs +67 -69
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +67 -69
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +67 -69
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +67 -69
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +1 -1
  10. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +10 -10
  12. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +22 -23
  13. package/dist/types/data-structures/binary-tree/bst.d.ts +11 -11
  14. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
  15. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +1 -1
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -2
  17. package/dist/umd/avl-tree-typed.js +67 -69
  18. package/dist/umd/avl-tree-typed.js.map +1 -1
  19. package/dist/umd/avl-tree-typed.min.js +3 -3
  20. package/dist/umd/avl-tree-typed.min.js.map +1 -1
  21. package/package.json +2 -2
  22. package/src/data-structures/binary-tree/avl-tree-counter.ts +6 -6
  23. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +13 -13
  24. package/src/data-structures/binary-tree/avl-tree.ts +15 -15
  25. package/src/data-structures/binary-tree/binary-tree.ts +53 -55
  26. package/src/data-structures/binary-tree/bst.ts +21 -22
  27. package/src/data-structures/binary-tree/red-black-tree.ts +3 -3
  28. package/src/data-structures/binary-tree/tree-counter.ts +4 -4
  29. package/src/data-structures/binary-tree/tree-multi-map.ts +13 -13
@@ -1183,9 +1183,9 @@ var BinaryTreeNode = _BinaryTreeNode;
1183
1183
  var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1184
1184
  /**
1185
1185
  * Creates an instance of BinaryTree.
1186
- * @remarks Time O(N * M), where N is the number of items in `keysNodesEntriesOrRaws` and M is the tree size at insertion time (due to O(M) `add` operation). Space O(N) for storing the nodes.
1186
+ * @remarks Time O(N * M), where N is the number of items in `keysNodesEntriesOrRaws` and M is the tree size at insertion time (due to O(M) `set` operation). Space O(N) for storing the nodes.
1187
1187
  *
1188
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
1188
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
1189
1189
  * @param [options] - Configuration options for the tree.
1190
1190
  */
1191
1191
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -1214,7 +1214,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1214
1214
  if (typeof toEntryFn === "function") this._toEntryFn = toEntryFn;
1215
1215
  else if (toEntryFn) throw TypeError("toEntryFn must be a function type");
1216
1216
  }
1217
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
1217
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
1218
1218
  }
1219
1219
  /**
1220
1220
  * Gets whether the tree is in Map mode.
@@ -1421,10 +1421,20 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1421
1421
  * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
1422
1422
  *
1423
1423
  * @param keyNodeOrEntry - The key, node, or entry to add.
1424
+ * @returns True if the addition was successful, false otherwise.
1425
+ */
1426
+ add(keyNodeOrEntry) {
1427
+ return this.set(keyNodeOrEntry);
1428
+ }
1429
+ /**
1430
+ * Adds or updates a new node to the tree.
1431
+ * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation sets the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
1432
+ *
1433
+ * @param keyNodeOrEntry - The key, node, or entry to set or update.
1424
1434
  * @param [value] - The value, if providing just a key.
1425
1435
  * @returns True if the addition was successful, false otherwise.
1426
1436
  */
1427
- add(keyNodeOrEntry, value) {
1437
+ set(keyNodeOrEntry, value) {
1428
1438
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
1429
1439
  if (newNode === void 0) return false;
1430
1440
  if (!this._root) {
@@ -1468,25 +1478,25 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1468
1478
  return false;
1469
1479
  }
1470
1480
  /**
1471
- * Adds or updates a new node to the tree.
1472
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
1481
+ * Adds multiple items to the tree.
1482
+ * @remarks Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).
1473
1483
  *
1474
- * @param keyNodeOrEntry - The key, node, or entry to add or update.
1475
- * @param [value] - The value, if providing just a key.
1476
- * @returns True if the addition was successful, false otherwise.
1484
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
1485
+ * @param [values] - An optional parallel iterable of values.
1486
+ * @returns An array of booleans indicating the success of each individual `set` operation.
1477
1487
  */
1478
- set(keyNodeOrEntry, value) {
1479
- return this.add(keyNodeOrEntry, value);
1488
+ addMany(keysNodesEntriesOrRaws) {
1489
+ return this.setMany(keysNodesEntriesOrRaws);
1480
1490
  }
1481
1491
  /**
1482
- * Adds multiple items to the tree.
1483
- * @remarks Time O(N * M), where N is the number of items to add and M is the size of the tree at insertion (due to O(M) `add` operation). Space O(M) (from `add`) + O(N) (for the `inserted` array).
1492
+ * Adds or updates multiple items to the tree.
1493
+ * @remarks Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).
1484
1494
  *
1485
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
1495
+ * @param keysNodesEntriesOrRaws - An iterable of items to set or update.
1486
1496
  * @param [values] - An optional parallel iterable of values.
1487
- * @returns An array of booleans indicating the success of each individual `add` operation.
1497
+ * @returns An array of booleans indicating the success of each individual `set` operation.
1488
1498
  */
1489
- addMany(keysNodesEntriesOrRaws, values) {
1499
+ setMany(keysNodesEntriesOrRaws, values) {
1490
1500
  const inserted = [];
1491
1501
  let valuesIterator;
1492
1502
  if (values) {
@@ -1501,40 +1511,29 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1501
1511
  }
1502
1512
  }
1503
1513
  if (this.isRaw(keyNodeEntryOrRaw)) keyNodeEntryOrRaw = this._toEntryFn(keyNodeEntryOrRaw);
1504
- inserted.push(this.add(keyNodeEntryOrRaw, value));
1514
+ inserted.push(this.set(keyNodeEntryOrRaw, value));
1505
1515
  }
1506
1516
  return inserted;
1507
1517
  }
1508
1518
  /**
1509
- * Adds or updates multiple items to the tree.
1510
- * @remarks Time O(N * M), where N is the number of items to add and M is the size of the tree at insertion (due to O(M) `add` operation). Space O(M) (from `add`) + O(N) (for the `inserted` array).
1511
- *
1512
- * @param keysNodesEntriesOrRaws - An iterable of items to add or update.
1513
- * @param [values] - An optional parallel iterable of values.
1514
- * @returns An array of booleans indicating the success of each individual `add` operation.
1515
- */
1516
- setMany(keysNodesEntriesOrRaws, values) {
1517
- return this.addMany(keysNodesEntriesOrRaws, values);
1518
- }
1519
- /**
1520
- * Merges another tree into this one by adding all its nodes.
1521
- * @remarks Time O(N * M), same as `addMany`, where N is the size of `anotherTree` and M is the size of this tree. Space O(M) (from `add`).
1519
+ * Merges another tree into this one by seting all its nodes.
1520
+ * @remarks Time O(N * M), same as `setMany`, where N is the size of `anotherTree` and M is the size of this tree. Space O(M) (from `set`).
1522
1521
  *
1523
1522
  * @param anotherTree - The tree to merge.
1524
1523
  */
1525
1524
  merge(anotherTree) {
1526
- this.addMany(anotherTree, []);
1525
+ this.setMany(anotherTree, []);
1527
1526
  }
1528
1527
  /**
1529
1528
  * Clears the tree and refills it with new items.
1530
- * @remarks Time O(N) (for `clear`) + O(N * M) (for `addMany`) = O(N * M). Space O(M) (from `addMany`).
1529
+ * @remarks Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
1531
1530
  *
1532
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
1531
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
1533
1532
  * @param [values] - An optional parallel iterable of values.
1534
1533
  */
1535
1534
  refill(keysNodesEntriesOrRaws, values) {
1536
1535
  this.clear();
1537
- this.addMany(keysNodesEntriesOrRaws, values);
1536
+ this.setMany(keysNodesEntriesOrRaws, values);
1538
1537
  }
1539
1538
  /**
1540
1539
  * Deletes a node from the tree.
@@ -2200,7 +2199,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2200
2199
  }
2201
2200
  /**
2202
2201
  * Clones the tree.
2203
- * @remarks Time O(N * M), where N is the number of nodes and M is the tree size during insertion (due to `bfs` + `add`, and `add` is O(M)). Space O(N) for the new tree and the BFS queue.
2202
+ * @remarks Time O(N * M), where N is the number of nodes and M is the tree size during insertion (due to `bfs` + `set`, and `set` is O(M)). Space O(N) for the new tree and the BFS queue.
2204
2203
  *
2205
2204
  * @returns A new, cloned instance of the tree.
2206
2205
  */
@@ -2211,7 +2210,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2211
2210
  }
2212
2211
  /**
2213
2212
  * Creates a new tree containing only the entries that satisfy the predicate.
2214
- * @remarks Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion (O(N) iteration + O(M) `add` for each item). Space O(N) for the new tree.
2213
+ * @remarks Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion (O(N) iteration + O(M) `set` for each item). Space O(N) for the new tree.
2215
2214
  *
2216
2215
  * @param predicate - A function to test each [key, value] pair.
2217
2216
  * @param [thisArg] - `this` context for the predicate.
@@ -2220,7 +2219,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2220
2219
  filter(predicate, thisArg) {
2221
2220
  const out = this._createInstance();
2222
2221
  let i = 0;
2223
- for (const [k, v] of this) if (predicate.call(thisArg, v, k, i++, this)) out.add([k, v]);
2222
+ for (const [k, v] of this) if (predicate.call(thisArg, v, k, i++, this)) out.set([k, v]);
2224
2223
  return out;
2225
2224
  }
2226
2225
  /**
@@ -2238,7 +2237,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2238
2237
  map(cb, options, thisArg) {
2239
2238
  const out = this._createLike([], options);
2240
2239
  let i = 0;
2241
- for (const [k, v] of this) out.add(cb.call(thisArg, v, k, i++, this));
2240
+ for (const [k, v] of this) out.set(cb.call(thisArg, v, k, i++, this));
2242
2241
  return out;
2243
2242
  }
2244
2243
  /**
@@ -2484,18 +2483,18 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2484
2483
  return [this.createNode(keyNodeOrEntry, value), value];
2485
2484
  }
2486
2485
  /**
2487
- * (Protected) Helper for cloning. Performs a BFS and adds all nodes to the new tree.
2488
- * @remarks Time O(N * M) (O(N) BFS + O(M) `add` for each node).
2486
+ * (Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
2487
+ * @remarks Time O(N * M) (O(N) BFS + O(M) `set` for each node).
2489
2488
  *
2490
2489
  * @param cloned - The new, empty tree instance to populate.
2491
2490
  */
2492
2491
  _clone(cloned) {
2493
2492
  this.bfs(
2494
2493
  (node) => {
2495
- if (node === null) cloned.add(null);
2494
+ if (node === null) cloned.set(null);
2496
2495
  else {
2497
- if (this._isMapMode) cloned.add([node.key, this._store.get(node.key)]);
2498
- else cloned.add([node.key, node.value]);
2496
+ if (this._isMapMode) cloned.set([node.key, this._store.get(node.key)]);
2497
+ else cloned.set([node.key, node.value]);
2499
2498
  }
2500
2499
  },
2501
2500
  this._root,
@@ -2826,7 +2825,7 @@ var _BST = class _BST extends BinaryTree {
2826
2825
  * Creates an instance of BST.
2827
2826
  * @remarks Time O(N log N) or O(N^2) depending on `isBalanceAdd` in `addMany` and input order. Space O(N).
2828
2827
  *
2829
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
2828
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
2830
2829
  * @param [options] - Configuration options for the BST, including comparator.
2831
2830
  */
2832
2831
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -2847,7 +2846,7 @@ var _BST = class _BST extends BinaryTree {
2847
2846
  } else {
2848
2847
  this._comparator = this._createDefaultComparator();
2849
2848
  }
2850
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
2849
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
2851
2850
  }
2852
2851
  /**
2853
2852
  * Gets the root node of the tree.
@@ -3058,11 +3057,11 @@ var _BST = class _BST extends BinaryTree {
3058
3057
  * Adds a new node to the BST based on key comparison.
3059
3058
  * @remarks Time O(log N), where H is tree height. O(N) worst-case (unbalanced tree), O(log N) average. Space O(1).
3060
3059
  *
3061
- * @param keyNodeOrEntry - The key, node, or entry to add.
3060
+ * @param keyNodeOrEntry - The key, node, or entry to set.
3062
3061
  * @param [value] - The value, if providing just a key.
3063
3062
  * @returns True if the addition was successful, false otherwise.
3064
3063
  */
3065
- add(keyNodeOrEntry, value) {
3064
+ set(keyNodeOrEntry, value) {
3066
3065
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
3067
3066
  if (newNode === void 0) return false;
3068
3067
  if (this._root === void 0) {
@@ -3099,24 +3098,24 @@ var _BST = class _BST extends BinaryTree {
3099
3098
  }
3100
3099
  /**
3101
3100
  * Adds multiple items to the tree.
3102
- * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced add).
3101
+ * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced set).
3103
3102
  * If false, adds items one by one. Time O(N * H), which is O(N^2) worst-case.
3104
3103
  * Space O(N) for sorting and recursion/iteration stack.
3105
3104
  *
3106
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
3105
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
3107
3106
  * @param [values] - An optional parallel iterable of values.
3108
3107
  * @param [isBalanceAdd=true] - If true, builds a balanced tree from the items.
3109
- * @param [iterationType=this.iterationType] - The traversal method for balanced add (recursive or iterative).
3110
- * @returns An array of booleans indicating the success of each individual `add` operation.
3108
+ * @param [iterationType=this.iterationType] - The traversal method for balanced set (recursive or iterative).
3109
+ * @returns An array of booleans indicating the success of each individual `set` operation.
3111
3110
  */
3112
- addMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {
3111
+ setMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {
3113
3112
  const inserted = [];
3114
3113
  const valuesIterator = values == null ? void 0 : values[Symbol.iterator]();
3115
3114
  if (!isBalanceAdd) {
3116
3115
  for (let kve of keysNodesEntriesOrRaws) {
3117
3116
  const val = valuesIterator == null ? void 0 : valuesIterator.next().value;
3118
3117
  if (this.isRaw(kve)) kve = this._toEntryFn(kve);
3119
- inserted.push(this.add(kve, val));
3118
+ inserted.push(this.set(kve, val));
3120
3119
  }
3121
3120
  return inserted;
3122
3121
  }
@@ -3144,9 +3143,9 @@ var _BST = class _BST extends BinaryTree {
3144
3143
  const { key, value, orgIndex } = arr[mid];
3145
3144
  if (this.isRaw(key)) {
3146
3145
  const entry = this._toEntryFn(key);
3147
- inserted[orgIndex] = this.add(entry);
3146
+ inserted[orgIndex] = this.set(entry);
3148
3147
  } else {
3149
- inserted[orgIndex] = this.add(key, value);
3148
+ inserted[orgIndex] = this.set(key, value);
3150
3149
  }
3151
3150
  _dfs(arr.slice(0, mid));
3152
3151
  _dfs(arr.slice(mid + 1));
@@ -3163,9 +3162,9 @@ var _BST = class _BST extends BinaryTree {
3163
3162
  const { key, value, orgIndex } = sorted[m];
3164
3163
  if (this.isRaw(key)) {
3165
3164
  const entry = this._toEntryFn(key);
3166
- inserted[orgIndex] = this.add(entry);
3165
+ inserted[orgIndex] = this.set(entry);
3167
3166
  } else {
3168
- inserted[orgIndex] = this.add(key, value);
3167
+ inserted[orgIndex] = this.set(key, value);
3169
3168
  }
3170
3169
  stack.push([m + 1, r]);
3171
3170
  stack.push([l, m - 1]);
@@ -3440,7 +3439,7 @@ var _BST = class _BST extends BinaryTree {
3440
3439
  const out = this._createLike([], options);
3441
3440
  let index = 0;
3442
3441
  for (const [key, value] of this) {
3443
- out.add(callback.call(thisArg, value, key, index++, this));
3442
+ out.set(callback.call(thisArg, value, key, index++, this));
3444
3443
  }
3445
3444
  return out;
3446
3445
  }
@@ -3496,7 +3495,6 @@ var _BST = class _BST extends BinaryTree {
3496
3495
  */
3497
3496
  _createDefaultComparator() {
3498
3497
  return (a, b) => {
3499
- debugger;
3500
3498
  if (isComparable(a) && isComparable(b)) {
3501
3499
  if (a > b) return 1;
3502
3500
  if (a < b) return -1;
@@ -4058,14 +4056,14 @@ var AVLTreeNode = _AVLTreeNode;
4058
4056
  var _AVLTree = class _AVLTree extends BST {
4059
4057
  /**
4060
4058
  * Creates an instance of AVLTree.
4061
- * @remarks Time O(N log N) (from `addMany` with balanced add). Space O(N).
4059
+ * @remarks Time O(N log N) (from `setMany` with balanced set). Space O(N).
4062
4060
  *
4063
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
4061
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
4064
4062
  * @param [options] - Configuration options for the AVL tree.
4065
4063
  */
4066
4064
  constructor(keysNodesEntriesOrRaws = [], options) {
4067
4065
  super([], options);
4068
- if (keysNodesEntriesOrRaws) super.addMany(keysNodesEntriesOrRaws);
4066
+ if (keysNodesEntriesOrRaws) super.setMany(keysNodesEntriesOrRaws);
4069
4067
  }
4070
4068
  /**
4071
4069
  * (Protected) Creates a new AVL tree node.
@@ -4089,16 +4087,16 @@ var _AVLTree = class _AVLTree extends BST {
4089
4087
  return keyNodeOrEntry instanceof AVLTreeNode;
4090
4088
  }
4091
4089
  /**
4092
- * Adds a new node to the AVL tree and balances the tree path.
4093
- * @remarks Time O(log N) (O(H) for BST add + O(H) for `_balancePath`). Space O(H) for path/recursion.
4090
+ * Sets a new node to the AVL tree and balances the tree path.
4091
+ * @remarks Time O(log N) (O(H) for BST set + O(H) for `_balancePath`). Space O(H) for path/recursion.
4094
4092
  *
4095
- * @param keyNodeOrEntry - The key, node, or entry to add.
4093
+ * @param keyNodeOrEntry - The key, node, or entry to set.
4096
4094
  * @param [value] - The value, if providing just a key.
4097
4095
  * @returns True if the addition was successful, false otherwise.
4098
4096
  */
4099
- add(keyNodeOrEntry, value) {
4097
+ set(keyNodeOrEntry, value) {
4100
4098
  if (keyNodeOrEntry === null) return false;
4101
- const inserted = super.add(keyNodeOrEntry, value);
4099
+ const inserted = super.set(keyNodeOrEntry, value);
4102
4100
  if (inserted) this._balancePath(keyNodeOrEntry);
4103
4101
  return inserted;
4104
4102
  }
@@ -4150,7 +4148,7 @@ var _AVLTree = class _AVLTree extends BST {
4150
4148
  }
4151
4149
  /**
4152
4150
  * Creates a new AVLTree by mapping each [key, value] pair.
4153
- * @remarks Time O(N log N) (O(N) iteration + O(log M) `add` for each item into the new tree). Space O(N) for the new tree.
4151
+ * @remarks Time O(N log N) (O(N) iteration + O(log M) `set` for each item into the new tree). Space O(N) for the new tree.
4154
4152
  *
4155
4153
  * @template MK - New key type.
4156
4154
  * @template MV - New value type.
@@ -4164,7 +4162,7 @@ var _AVLTree = class _AVLTree extends BST {
4164
4162
  const out = this._createLike([], options);
4165
4163
  let index = 0;
4166
4164
  for (const [key, value] of this) {
4167
- out.add(callback.call(thisArg, value, key, index++, this));
4165
+ out.set(callback.call(thisArg, value, key, index++, this));
4168
4166
  }
4169
4167
  return out;
4170
4168
  }