tree-multimap-typed 2.2.7 → 2.3.0

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 +72 -75
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +72 -75
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +72 -75
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +72 -75
  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 -24
  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/tree-multimap-typed.js +70 -73
  18. package/dist/umd/tree-multimap-typed.js.map +1 -1
  19. package/dist/umd/tree-multimap-typed.min.js +3 -3
  20. package/dist/umd/tree-multimap-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 +52 -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
@@ -1194,9 +1194,9 @@ var BinaryTree = class extends IterableEntryBase {
1194
1194
  iterationType = "ITERATIVE";
1195
1195
  /**
1196
1196
  * Creates an instance of BinaryTree.
1197
- * @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.
1197
+ * @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.
1198
1198
  *
1199
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
1199
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
1200
1200
  * @param [options] - Configuration options for the tree.
1201
1201
  */
1202
1202
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -1209,7 +1209,7 @@ var BinaryTree = class extends IterableEntryBase {
1209
1209
  if (typeof toEntryFn === "function") this._toEntryFn = toEntryFn;
1210
1210
  else if (toEntryFn) throw TypeError("toEntryFn must be a function type");
1211
1211
  }
1212
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
1212
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
1213
1213
  }
1214
1214
  _isMapMode = true;
1215
1215
  /**
@@ -1423,10 +1423,20 @@ var BinaryTree = class extends IterableEntryBase {
1423
1423
  * @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).
1424
1424
  *
1425
1425
  * @param keyNodeOrEntry - The key, node, or entry to add.
1426
+ * @returns True if the addition was successful, false otherwise.
1427
+ */
1428
+ add(keyNodeOrEntry) {
1429
+ return this.set(keyNodeOrEntry);
1430
+ }
1431
+ /**
1432
+ * Adds or updates a new node to the tree.
1433
+ * @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).
1434
+ *
1435
+ * @param keyNodeOrEntry - The key, node, or entry to set or update.
1426
1436
  * @param [value] - The value, if providing just a key.
1427
1437
  * @returns True if the addition was successful, false otherwise.
1428
1438
  */
1429
- add(keyNodeOrEntry, value) {
1439
+ set(keyNodeOrEntry, value) {
1430
1440
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
1431
1441
  if (newNode === void 0) return false;
1432
1442
  if (!this._root) {
@@ -1470,25 +1480,24 @@ var BinaryTree = class extends IterableEntryBase {
1470
1480
  return false;
1471
1481
  }
1472
1482
  /**
1473
- * Adds or updates a new node to the tree.
1474
- * @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).
1483
+ * Adds multiple items to the tree.
1484
+ * @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).
1475
1485
  *
1476
- * @param keyNodeOrEntry - The key, node, or entry to add or update.
1477
- * @param [value] - The value, if providing just a key.
1478
- * @returns True if the addition was successful, false otherwise.
1486
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
1487
+ * @returns An array of booleans indicating the success of each individual `set` operation.
1479
1488
  */
1480
- set(keyNodeOrEntry, value) {
1481
- return this.add(keyNodeOrEntry, value);
1489
+ addMany(keysNodesEntriesOrRaws) {
1490
+ return this.setMany(keysNodesEntriesOrRaws);
1482
1491
  }
1483
1492
  /**
1484
- * Adds multiple items to the tree.
1485
- * @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).
1493
+ * Adds or updates multiple items to the tree.
1494
+ * @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).
1486
1495
  *
1487
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
1496
+ * @param keysNodesEntriesOrRaws - An iterable of items to set or update.
1488
1497
  * @param [values] - An optional parallel iterable of values.
1489
- * @returns An array of booleans indicating the success of each individual `add` operation.
1498
+ * @returns An array of booleans indicating the success of each individual `set` operation.
1490
1499
  */
1491
- addMany(keysNodesEntriesOrRaws, values) {
1500
+ setMany(keysNodesEntriesOrRaws, values) {
1492
1501
  const inserted = [];
1493
1502
  let valuesIterator;
1494
1503
  if (values) {
@@ -1503,40 +1512,29 @@ var BinaryTree = class extends IterableEntryBase {
1503
1512
  }
1504
1513
  }
1505
1514
  if (this.isRaw(keyNodeEntryOrRaw)) keyNodeEntryOrRaw = this._toEntryFn(keyNodeEntryOrRaw);
1506
- inserted.push(this.add(keyNodeEntryOrRaw, value));
1515
+ inserted.push(this.set(keyNodeEntryOrRaw, value));
1507
1516
  }
1508
1517
  return inserted;
1509
1518
  }
1510
1519
  /**
1511
- * Adds or updates multiple items to the tree.
1512
- * @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).
1513
- *
1514
- * @param keysNodesEntriesOrRaws - An iterable of items to add or update.
1515
- * @param [values] - An optional parallel iterable of values.
1516
- * @returns An array of booleans indicating the success of each individual `add` operation.
1517
- */
1518
- setMany(keysNodesEntriesOrRaws, values) {
1519
- return this.addMany(keysNodesEntriesOrRaws, values);
1520
- }
1521
- /**
1522
- * Merges another tree into this one by adding all its nodes.
1523
- * @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`).
1520
+ * Merges another tree into this one by seting all its nodes.
1521
+ * @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`).
1524
1522
  *
1525
1523
  * @param anotherTree - The tree to merge.
1526
1524
  */
1527
1525
  merge(anotherTree) {
1528
- this.addMany(anotherTree, []);
1526
+ this.setMany(anotherTree, []);
1529
1527
  }
1530
1528
  /**
1531
1529
  * Clears the tree and refills it with new items.
1532
- * @remarks Time O(N) (for `clear`) + O(N * M) (for `addMany`) = O(N * M). Space O(M) (from `addMany`).
1530
+ * @remarks Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
1533
1531
  *
1534
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
1532
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
1535
1533
  * @param [values] - An optional parallel iterable of values.
1536
1534
  */
1537
1535
  refill(keysNodesEntriesOrRaws, values) {
1538
1536
  this.clear();
1539
- this.addMany(keysNodesEntriesOrRaws, values);
1537
+ this.setMany(keysNodesEntriesOrRaws, values);
1540
1538
  }
1541
1539
  /**
1542
1540
  * Deletes a node from the tree.
@@ -2201,7 +2199,7 @@ var BinaryTree = class extends IterableEntryBase {
2201
2199
  }
2202
2200
  /**
2203
2201
  * Clones the tree.
2204
- * @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.
2205
2203
  *
2206
2204
  * @returns A new, cloned instance of the tree.
2207
2205
  */
@@ -2212,7 +2210,7 @@ var BinaryTree = class extends IterableEntryBase {
2212
2210
  }
2213
2211
  /**
2214
2212
  * Creates a new tree containing only the entries that satisfy the predicate.
2215
- * @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.
2216
2214
  *
2217
2215
  * @param predicate - A function to test each [key, value] pair.
2218
2216
  * @param [thisArg] - `this` context for the predicate.
@@ -2221,7 +2219,7 @@ var BinaryTree = class extends IterableEntryBase {
2221
2219
  filter(predicate, thisArg) {
2222
2220
  const out = this._createInstance();
2223
2221
  let i = 0;
2224
- 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]);
2225
2223
  return out;
2226
2224
  }
2227
2225
  /**
@@ -2239,7 +2237,7 @@ var BinaryTree = class extends IterableEntryBase {
2239
2237
  map(cb, options, thisArg) {
2240
2238
  const out = this._createLike([], options);
2241
2239
  let i = 0;
2242
- 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));
2243
2241
  return out;
2244
2242
  }
2245
2243
  /**
@@ -2491,18 +2489,18 @@ var BinaryTree = class extends IterableEntryBase {
2491
2489
  return [this.createNode(keyNodeOrEntry, value), value];
2492
2490
  }
2493
2491
  /**
2494
- * (Protected) Helper for cloning. Performs a BFS and adds all nodes to the new tree.
2495
- * @remarks Time O(N * M) (O(N) BFS + O(M) `add` for each node).
2492
+ * (Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
2493
+ * @remarks Time O(N * M) (O(N) BFS + O(M) `set` for each node).
2496
2494
  *
2497
2495
  * @param cloned - The new, empty tree instance to populate.
2498
2496
  */
2499
2497
  _clone(cloned) {
2500
2498
  this.bfs(
2501
2499
  (node) => {
2502
- if (node === null) cloned.add(null);
2500
+ if (node === null) cloned.set(null);
2503
2501
  else {
2504
- if (this._isMapMode) cloned.add([node.key, this._store.get(node.key)]);
2505
- else cloned.add([node.key, node.value]);
2502
+ if (this._isMapMode) cloned.set([node.key, this._store.get(node.key)]);
2503
+ else cloned.set([node.key, node.value]);
2506
2504
  }
2507
2505
  },
2508
2506
  this._root,
@@ -2835,7 +2833,7 @@ var BST = class extends BinaryTree {
2835
2833
  * Creates an instance of BST.
2836
2834
  * @remarks Time O(N log N) or O(N^2) depending on `isBalanceAdd` in `addMany` and input order. Space O(N).
2837
2835
  *
2838
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
2836
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
2839
2837
  * @param [options] - Configuration options for the BST, including comparator.
2840
2838
  */
2841
2839
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -2849,7 +2847,7 @@ var BST = class extends BinaryTree {
2849
2847
  } else {
2850
2848
  this._comparator = this._createDefaultComparator();
2851
2849
  }
2852
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
2850
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
2853
2851
  }
2854
2852
  _root = void 0;
2855
2853
  /**
@@ -3065,11 +3063,11 @@ var BST = class extends BinaryTree {
3065
3063
  * Adds a new node to the BST based on key comparison.
3066
3064
  * @remarks Time O(log N), where H is tree height. O(N) worst-case (unbalanced tree), O(log N) average. Space O(1).
3067
3065
  *
3068
- * @param keyNodeOrEntry - The key, node, or entry to add.
3066
+ * @param keyNodeOrEntry - The key, node, or entry to set.
3069
3067
  * @param [value] - The value, if providing just a key.
3070
3068
  * @returns True if the addition was successful, false otherwise.
3071
3069
  */
3072
- add(keyNodeOrEntry, value) {
3070
+ set(keyNodeOrEntry, value) {
3073
3071
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
3074
3072
  if (newNode === void 0) return false;
3075
3073
  if (this._root === void 0) {
@@ -3106,24 +3104,24 @@ var BST = class extends BinaryTree {
3106
3104
  }
3107
3105
  /**
3108
3106
  * Adds multiple items to the tree.
3109
- * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced add).
3107
+ * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced set).
3110
3108
  * If false, adds items one by one. Time O(N * H), which is O(N^2) worst-case.
3111
3109
  * Space O(N) for sorting and recursion/iteration stack.
3112
3110
  *
3113
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
3111
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
3114
3112
  * @param [values] - An optional parallel iterable of values.
3115
3113
  * @param [isBalanceAdd=true] - If true, builds a balanced tree from the items.
3116
- * @param [iterationType=this.iterationType] - The traversal method for balanced add (recursive or iterative).
3117
- * @returns An array of booleans indicating the success of each individual `add` operation.
3114
+ * @param [iterationType=this.iterationType] - The traversal method for balanced set (recursive or iterative).
3115
+ * @returns An array of booleans indicating the success of each individual `set` operation.
3118
3116
  */
3119
- addMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {
3117
+ setMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {
3120
3118
  const inserted = [];
3121
3119
  const valuesIterator = values?.[Symbol.iterator]();
3122
3120
  if (!isBalanceAdd) {
3123
3121
  for (let kve of keysNodesEntriesOrRaws) {
3124
3122
  const val = valuesIterator?.next().value;
3125
3123
  if (this.isRaw(kve)) kve = this._toEntryFn(kve);
3126
- inserted.push(this.add(kve, val));
3124
+ inserted.push(this.set(kve, val));
3127
3125
  }
3128
3126
  return inserted;
3129
3127
  }
@@ -3151,9 +3149,9 @@ var BST = class extends BinaryTree {
3151
3149
  const { key, value, orgIndex } = arr[mid];
3152
3150
  if (this.isRaw(key)) {
3153
3151
  const entry = this._toEntryFn(key);
3154
- inserted[orgIndex] = this.add(entry);
3152
+ inserted[orgIndex] = this.set(entry);
3155
3153
  } else {
3156
- inserted[orgIndex] = this.add(key, value);
3154
+ inserted[orgIndex] = this.set(key, value);
3157
3155
  }
3158
3156
  _dfs(arr.slice(0, mid));
3159
3157
  _dfs(arr.slice(mid + 1));
@@ -3170,9 +3168,9 @@ var BST = class extends BinaryTree {
3170
3168
  const { key, value, orgIndex } = sorted[m];
3171
3169
  if (this.isRaw(key)) {
3172
3170
  const entry = this._toEntryFn(key);
3173
- inserted[orgIndex] = this.add(entry);
3171
+ inserted[orgIndex] = this.set(entry);
3174
3172
  } else {
3175
- inserted[orgIndex] = this.add(key, value);
3173
+ inserted[orgIndex] = this.set(key, value);
3176
3174
  }
3177
3175
  stack.push([m + 1, r]);
3178
3176
  stack.push([l, m - 1]);
@@ -3447,7 +3445,7 @@ var BST = class extends BinaryTree {
3447
3445
  const out = this._createLike([], options);
3448
3446
  let index = 0;
3449
3447
  for (const [key, value] of this) {
3450
- out.add(callback.call(thisArg, value, key, index++, this));
3448
+ out.set(callback.call(thisArg, value, key, index++, this));
3451
3449
  }
3452
3450
  return out;
3453
3451
  }
@@ -3503,7 +3501,6 @@ var BST = class extends BinaryTree {
3503
3501
  */
3504
3502
  _createDefaultComparator() {
3505
3503
  return (a, b) => {
3506
- debugger;
3507
3504
  if (isComparable(a) && isComparable(b)) {
3508
3505
  if (a > b) return 1;
3509
3506
  if (a < b) return -1;
@@ -4065,7 +4062,7 @@ var RedBlackTree = class extends BST {
4065
4062
  super([], options);
4066
4063
  this._root = this.NIL;
4067
4064
  if (keysNodesEntriesOrRaws) {
4068
- this.addMany(keysNodesEntriesOrRaws);
4065
+ this.setMany(keysNodesEntriesOrRaws);
4069
4066
  }
4070
4067
  }
4071
4068
  _root;
@@ -4113,7 +4110,7 @@ var RedBlackTree = class extends BST {
4113
4110
  * @param [value]- See parameter type for details.
4114
4111
  * @returns True if inserted or updated; false if ignored.
4115
4112
  */
4116
- add(keyNodeOrEntry, value) {
4113
+ set(keyNodeOrEntry, value) {
4117
4114
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
4118
4115
  if (!this.isRealNode(newNode)) return false;
4119
4116
  const insertStatus = this._insert(newNode);
@@ -4207,7 +4204,7 @@ var RedBlackTree = class extends BST {
4207
4204
  const out = this._createLike([], options);
4208
4205
  let index = 0;
4209
4206
  for (const [key, value] of this) {
4210
- out.add(callback.call(thisArg, value, key, index++, this));
4207
+ out.set(callback.call(thisArg, value, key, index++, this));
4211
4208
  }
4212
4209
  return out;
4213
4210
  }
@@ -4596,7 +4593,7 @@ var TreeMultiMap = class extends RedBlackTree {
4596
4593
  constructor(keysNodesEntriesOrRaws = [], options) {
4597
4594
  super([], { ...options });
4598
4595
  if (keysNodesEntriesOrRaws) {
4599
- this.addMany(keysNodesEntriesOrRaws);
4596
+ this.setMany(keysNodesEntriesOrRaws);
4600
4597
  }
4601
4598
  }
4602
4599
  createNode(key, value = []) {
@@ -4616,27 +4613,27 @@ var TreeMultiMap = class extends RedBlackTree {
4616
4613
  * Insert a value or a list of values into the multimap. If the key exists, values are appended.
4617
4614
  * @remarks Time O(log N + M), Space O(1)
4618
4615
  * @param keyNodeOrEntry - Key, node, or [key, values] entry.
4619
- * @param [value] - Single value to add when a bare key is provided.
4616
+ * @param [value] - Single value to set when a bare key is provided.
4620
4617
  * @returns True if inserted or appended; false if ignored.
4621
4618
  */
4622
- add(keyNodeOrEntry, value) {
4623
- if (this.isRealNode(keyNodeOrEntry)) return super.add(keyNodeOrEntry);
4619
+ set(keyNodeOrEntry, value) {
4620
+ if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
4624
4621
  const _commonAdd = /* @__PURE__ */ __name((key, values) => {
4625
4622
  if (key === void 0 || key === null) return false;
4626
- const _addToValues = /* @__PURE__ */ __name(() => {
4623
+ const _setToValues = /* @__PURE__ */ __name(() => {
4627
4624
  const existingValues = this.get(key);
4628
4625
  if (existingValues !== void 0 && values !== void 0) {
4629
4626
  for (const value2 of values) existingValues.push(value2);
4630
4627
  return true;
4631
4628
  }
4632
4629
  return false;
4633
- }, "_addToValues");
4634
- const _addByNode = /* @__PURE__ */ __name(() => {
4630
+ }, "_setToValues");
4631
+ const _setByNode = /* @__PURE__ */ __name(() => {
4635
4632
  const existingNode = this.getNode(key);
4636
4633
  if (this.isRealNode(existingNode)) {
4637
4634
  const existingValues = this.get(existingNode);
4638
4635
  if (existingValues === void 0) {
4639
- super.add(key, values);
4636
+ super.set(key, values);
4640
4637
  return true;
4641
4638
  }
4642
4639
  if (values !== void 0) {
@@ -4646,13 +4643,13 @@ var TreeMultiMap = class extends RedBlackTree {
4646
4643
  return false;
4647
4644
  }
4648
4645
  } else {
4649
- return super.add(key, values);
4646
+ return super.set(key, values);
4650
4647
  }
4651
- }, "_addByNode");
4648
+ }, "_setByNode");
4652
4649
  if (this._isMapMode) {
4653
- return _addByNode() || _addToValues();
4650
+ return _setByNode() || _setToValues();
4654
4651
  }
4655
- return _addToValues() || _addByNode();
4652
+ return _setToValues() || _setByNode();
4656
4653
  }, "_commonAdd");
4657
4654
  if (this.isEntry(keyNodeOrEntry)) {
4658
4655
  const [key, values] = keyNodeOrEntry;
@@ -4692,7 +4689,7 @@ var TreeMultiMap = class extends RedBlackTree {
4692
4689
  map(callback, options, thisArg) {
4693
4690
  const out = this._createLike([], options);
4694
4691
  let i = 0;
4695
- for (const [k, v] of this) out.add(callback.call(thisArg, v, k, i++, this));
4692
+ for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
4696
4693
  return out;
4697
4694
  }
4698
4695
  /**